/**
*  @brief  Create Tcp Server Connection
*
*  @param  Host port (string)
*  @param  Function pointer to data handler function
*
*  @return Connection id
*/
uint8_t GS_API_CreateTcpServerConnection(char* port, GS_API_DataHandler cidDataHandler){
     uint8_t cidStr[] = " ";
     uint16_t cid = GS_API_INVALID_CID;
 	 unsigned int response_timeout_temp;

   	 response_timeout_temp = GS_Api_GetResponseTimeoutHandle();
 	 GS_Api_SetResponseTimeoutHandle(TIMEOUT_RESPONSE_INTERVAL_HIGH);

     if(!gs_api_handle_cmd_resp(AtLibGs_TcpServer_Start((int8_t*)port)))
     {
    	  GS_Api_SetResponseTimeoutHandle(response_timeout_temp);
          return cid;
     }

     if(AtLib_ParseTcpServerStartResponse(cidStr)){
          // need to convert from ASCII to numeric
          cid = gs_api_parseCidStr(cidStr);
          if(cid != GS_API_INVALID_CID){
               cidDataHandlers[cid] = cidDataHandler;
          }
     }

     GS_Api_SetResponseTimeoutHandle(response_timeout_temp);
     return cid;
}
Esempio n. 2
0
uint8_t GS_API_CreateTcpServerConnection(char* port, GS_API_DataHandler cidDataHandler){
     uint8_t cidStr[] = " ";
     uint16_t cid = GS_API_INVALID_CID;

     if(!gs_api_handle_cmd_resp(AtLibGs_TcpServer_Start((int8_t*)port))) {
          return cid;
	}
   
     if(AtLib_ParseTcpServerStartResponse(cidStr)){
          // need to convert from ASCII to numeric
          cid = gs_api_parseCidStr(cidStr);
          if(cid != GS_API_INVALID_CID){
               cidDataHandlers[cid] = cidDataHandler;
         }
     }
  
     return cid;
}