StdPJ/Core/Src/APP/BSP/ug96/ug96.c
/**
  * @brief  Get UART Configuration.
  * @param  Obj: pointer to module handle
  * @param  pconf: pointer to UART config structure
  * @retval Operation Status.
  */
@brief  Get UART Configuration.
@param  Obj: pointer to module handle
@param  pconf: pointer to UART config structure
@retval Operation Status.
@brief Get UART Configuration . @param Obj : pointer to module handle @param pconf : pointer to UART config structure @retval Operation Status .
UG96_Return_t  UG96_GetUARTConfig(Ug96Object_t *Obj, UG96_UARTConfig_t *pconf)
{
  UG96_Return_t ret = UG96_RETURN_ERROR;
  char *align_ptr;
  uint8_t rts, cts;
  ret = (UG96_Return_t) AT_ExecuteCommand(Obj, UG96_TOUT_300, (uint8_t *)"AT+IPR?\r\n", RET_OK | RET_ERROR);
  if (ret == RET_OK)
  {
    align_ptr = strstr((char *) Obj->CmdResp,"+IPR:") + sizeof("+IPR:");
    Obj->UART_Config.BaudRate = ParseNumber(align_ptr, NULL);
  }
  ret = (UG96_Return_t) AT_ExecuteCommand(Obj, UG96_TOUT_300, (uint8_t *)"AT+IFC?\r\n", RET_OK | RET_ERROR);
  if (ret == RET_OK)
  {
    align_ptr = strstr((char *) Obj->CmdResp,"+IFC:") + sizeof("+IPR:");
    rts = ParseNumber(align_ptr, NULL);
    cts = ParseNumber(align_ptr+2, NULL);
    if (rts == 2)
    {
      if (cts == 2)
      {
        pconf->FlowControl = UG96_UART_FLW_CTL_RTS_CTS;
      }
      else
      {
        pconf->FlowControl = UG96_UART_FLW_CTL_RTS;
      }
    }
    else
    {
      if (cts == 2)
      {
        pconf->FlowControl = UG96_UART_FLW_CTL_CTS;
      }
      else
      {
        pconf->FlowControl = UG96_UART_FLW_CTL_NONE;
      }
    }
  }
  return ret;
}
UG96_Return_t UG96_GetUARTConfig ( Ug96Object_t * Obj , UG96_UARTConfig_t * pconf ) { UG96_Return_t ret = UG96_RETURN_ERROR ; char * align_ptr ; uint8_t rts , cts ; ret = ( UG96_Return_t ) AT_ExecuteCommand ( Obj , UG96_TOUT_300 , ( uint8_t * ) " \r \n " , RET_OK | RET_ERROR ) ; if ( ret == RET_OK ) { align_ptr = strstr ( ( char * ) Obj -> CmdResp , " " ) + sizeof ( " " ) ; Obj -> UART_Config . BaudRate = ParseNumber ( align_ptr , NULL ) ; } ret = ( UG96_Return_t ) AT_ExecuteCommand ( Obj , UG96_TOUT_300 , ( uint8_t * ) " \r \n " , RET_OK | RET_ERROR ) ; if ( ret == RET_OK ) { align_ptr = strstr ( ( char * ) Obj -> CmdResp , " " ) + sizeof ( " " ) ; rts = ParseNumber ( align_ptr , NULL ) ; cts = ParseNumber ( align_ptr + 2 , NULL ) ; if ( rts == 2 ) { if ( cts == 2 ) { pconf -> FlowControl = UG96_UART_FLW_CTL_RTS_CTS ; } else { pconf -> FlowControl = UG96_UART_FLW_CTL_RTS ; } } else { if ( cts == 2 ) { pconf -> FlowControl = UG96_UART_FLW_CTL_CTS ; } else { pconf -> FlowControl = UG96_UART_FLW_CTL_NONE ; } } } return ret ; }
@brief  Get UART Configuration.
@brief Get UART Configuration .