/**
*  @brief  Join WiFi netwrk
*
*  @param  Network Configuration struct
*
*  @return True if successfully joined
*/
bool GS_API_JoinWiFiNetwork(HOST_APP_NETWORK_CONFIG_T* apiNetCfg){
	bool joined = false;
	unsigned int response_timeout_temp;

	response_timeout_temp = GS_Api_GetResponseTimeoutHandle();
	GS_Api_SetResponseTimeoutHandle(TIMEOUT_RESPONSE_INTERVAL_HIGH);

	AtLib_FlushIncomingMessage();
	// Associate
	if(gs_api_handle_cmd_resp(AtLibGs_Assoc((int8_t *) apiNetCfg->ssid,(int8_t*)"", (int8_t *) apiNetCfg->channel)))
	{
	     if (gs_api_handle_cmd_resp(AtLibGs_DHCPSet(1)))
	     {
	    	 char ip[16];

	    	 if (AtLib_ParseWlanConnIp((uint8_t *) ip) == true)
	    		 joined = true;
	     }
	     // Clear all data handler functions
	     memset(cidDataHandlers, 0, sizeof(cidDataHandlers));
	}

	GS_Api_SetResponseTimeoutHandle(response_timeout_temp);
	return joined;
}
Beispiel #2
0
void GS_API_Init(char *port){
     GS_HAL_init(port);

     //GS_HAL_send("\r\n", 2);
        
     // Flush buffer until we get a valid response
     AtLib_FlushIncomingMessage();

     // Try to reset
     //if(AtLibGs_Reset() == HOST_APP_MSG_ID_APP_RESET)
     //     GS_API_Printf("Reset OK");
     //else
     //     GS_API_Printf("Reset Fail");

     // Turn off echo
     AtLibGs_SetEcho(0);

     // Turn on Bulk Data
     AtLibGs_BData(1);

     // Read saved network parameters
     //gs_api_readNetworkConfig();
     AtLib_FlushIncomingMessage();
}