StdPJ/Core/Src/APP/BSP/ug96/ug96.c
/**
  * @brief  Get Packet Switch Registration Status
  * @param  Obj: pointer to module handle
  * @retval Registration Status.
  */
@brief  Get Packet Switch Registration Status
@param  Obj: pointer to module handle
@retval Registration Status.
@brief Get Packet Switch Registration Status @param Obj : pointer to module handle @retval Registration Status .
UG96_NetworkRegistrationState_t  UG96_GetPsNetworkRegistrationStatus(Ug96Object_t *Obj)
{
  int8_t received_string[3];
  int16_t val;
  UG96_NetworkRegistrationState_t ret = UG96_NRS_ERROR;
  char *align_ptr;
  char *cgreg_ptr;
  if (Obj->SimInfo.SimStatus == UG96_SIM_READY)
  {
    if (RET_OK == AT_ExecuteCommand(Obj, UG96_TOUT_300, (uint8_t *)"AT+CGREG?\r\n", RET_OK | RET_ERROR | RET_CME_ERROR))
    {
      cgreg_ptr = strstr((char *) Obj->CmdResp,"+CGREG:");
      if (NULL != cgreg_ptr)
      {
        align_ptr = cgreg_ptr + sizeof("+CGREG:");
        strncpy((char *)received_string,  align_ptr+2, 1);
        strncpy((char *)received_string+1,  "\r\n", 2);
        val = atoi((char *)received_string);
        ret = (UG96_NetworkRegistrationState_t) val;
      }
    }
  }
  return ret;
}
UG96_NetworkRegistrationState_t UG96_GetPsNetworkRegistrationStatus ( Ug96Object_t * Obj ) { int8_t received_string [ 3 ] ; int16_t val ; UG96_NetworkRegistrationState_t ret = UG96_NRS_ERROR ; char * align_ptr ; char * cgreg_ptr ; if ( Obj -> SimInfo . SimStatus == UG96_SIM_READY ) { if ( RET_OK == AT_ExecuteCommand ( Obj , UG96_TOUT_300 , ( uint8_t * ) " \r \n " , RET_OK | RET_ERROR | RET_CME_ERROR ) ) { cgreg_ptr = strstr ( ( char * ) Obj -> CmdResp , " " ) ; if ( NULL != cgreg_ptr ) { align_ptr = cgreg_ptr + sizeof ( " " ) ; strncpy ( ( char * ) received_string , align_ptr + 2 , 1 ) ; strncpy ( ( char * ) received_string + 1 , " \r \n " , 2 ) ; val = atoi ( ( char * ) received_string ) ; ret = ( UG96_NetworkRegistrationState_t ) val ; } } } return ret ; }
@brief  Get Packet Switch Registration Status
 @param  Obj: pointer to module handle
 @retval Registration Status.
@brief Get Packet Switch Registration Status @param Obj : pointer to module handle @retval Registration Status .
/* +CGREG: is in the response*/