StdPJ/Core/Src/APP/BSP/ug96/ug96.c
/**
  * @brief  Stop Client connection.
  * @param  Obj: pointer to module handle
  * @param  conn: pointer to the connection structure
  * @retval Operation Status.
  */
@brief  Stop Client connection.
@param  Obj: pointer to module handle
@param  conn: pointer to the connection structure
@retval Operation Status.
@brief Stop Client connection . @param Obj : pointer to module handle @param conn : pointer to the connection structure @retval Operation Status .
UG96_Return_t  UG96_CloseClientConnection(Ug96Object_t *Obj, UG96_Conn_t *conn)
{
  UG96_Return_t ret = UG96_RETURN_ERROR;
  uint32_t tickstart = Obj->GetTickCb();
  uint32_t unackedbytes = 1; 
  Obj->fops.IO_FlushBuffer();
  while ( (TimeLeftFromExpiration(tickstart, Obj->GetTickCb(), UG96_TOUT_5000) > 0)
         && (unackedbytes != 0))
  {
    snprintf(CmdString,24,"AT+QISEND=%d,0\r\n", conn->ConnectID);
    AT_ExecuteCommand(Obj, UG96_TOUT_300, (uint8_t *) CmdString, RET_ERROR | RET_SEND);
    AT_RetrieveData(Obj, Obj->CmdResp, 0, RET_CRLF, UG96_TOUT_300);
    ParseQISEND((char *) Obj->CmdResp, &unackedbytes);
    AT_RetrieveData(Obj, Obj->CmdResp, 0, RET_OK, UG96_TOUT_SHORT);
#ifdef UG96_DBG
    printf("Unack'ed data in modem: %d bytes\n", unackedbytes);
#endif
  }
  snprintf(CmdString, 24, "AT+QICLOSE=%d,%d\r\n", conn->ConnectID, 15);
  ret = (UG96_Return_t) AT_ExecuteCommand(Obj, UG96_TOUT_5000, (uint8_t *)CmdString, RET_OK | RET_ERROR);
#ifdef UG96_DBG
  printf("                UG96_CloseClientConnection(), ret value: %d \n", ret);
#endif
  return ret;
}
UG96_Return_t UG96_CloseClientConnection ( Ug96Object_t * Obj , UG96_Conn_t * conn ) { UG96_Return_t ret = UG96_RETURN_ERROR ; uint32_t tickstart = Obj -> GetTickCb ( ) ; uint32_t unackedbytes = 1 ; Obj -> fops . IO_FlushBuffer ( ) ; while ( ( TimeLeftFromExpiration ( tickstart , Obj -> GetTickCb ( ) , UG96_TOUT_5000 ) > 0 ) && ( unackedbytes != 0 ) ) { snprintf ( CmdString , 24 , " \r \n " , conn -> ConnectID ) ; AT_ExecuteCommand ( Obj , UG96_TOUT_300 , ( uint8_t * ) CmdString , RET_ERROR | RET_SEND ) ; AT_RetrieveData ( Obj , Obj -> CmdResp , 0 , RET_CRLF , UG96_TOUT_300 ) ; ParseQISEND ( ( char * ) Obj -> CmdResp , & unackedbytes ) ; AT_RetrieveData ( Obj , Obj -> CmdResp , 0 , RET_OK , UG96_TOUT_SHORT ) ; #ifdef UG96_DBG printf ( " \n " , unackedbytes ) ; #endif } snprintf ( CmdString , 24 , " \r \n " , conn -> ConnectID , 15 ) ; ret = ( UG96_Return_t ) AT_ExecuteCommand ( Obj , UG96_TOUT_5000 , ( uint8_t * ) CmdString , RET_OK | RET_ERROR ) ; #ifdef UG96_DBG printf ( " \n " , ret ) ; #endif return ret ; }
@brief  Stop Client connection.
@brief Stop Client connection .
/* Unknown by default, consider not NULL */ /* Make the modem TX buffer is emtpy, i.e. sent packets have been acked
      or close socket anyway after 2 seconds delay */ /* Update SocketInfo for next iteration*/ /* OK */