C application HTTP failing when re-establishing a connection -


i'm developping application run on bosch device - xdk - http://xdk.bosch-connectivity.com/.

at moment, have task implements http client , sends post requests server. however, main purpose of application able move between areas network coverage/no coverage. means i'm suspending/re-starting task implements http client.

so i'm having problem http client in following scenario: start application in region coverage, move region no coverage , finally, go again region coverage. that's here i'm getting problems. moment, can't connect anymore http client.

i'll post here pieces of code of application can suggest me alterations solve problem. functions such httpclient_initrequest, httpmsg_setrequrl, msg_prependpartfactory, ..., belong api provided xdk.

void appinitsystem(xtimerhandle xtimer) {     (void) (xtimer);      return_t retvalue = failure;     retcode_t wlanret = rc_platform_error;      wlanret = wlan_init();     if (wlanret != rc_ok){         printf("network init/connection failed %i \r\n", wlanret);         assert(0);     }      wlanret = pal_initialize();     if (wlanret != rc_ok){         printf("pal , network initialize %i \r\n", wlanret);         assert(0);     }      pal_socketmonitorinit();      /* start http client */     wlanret = httpclient_initialize();     if (wlanret != rc_ok){         printf("failed initialize http client\r\n ");         assert(0);     }      if (rc_ok != pal_getipaddress((uint8_t*) "52.58.121.5", &destaddr))        return;      retvalue = createtasks();     if (retvalue == failure)         assert(0); }  retcode_t wlan_init(void) {     wli_connectstatus_t retconnection;     nci_ipsettings_t myipsettings;     char ipaddress[pal_ip_address_size] = { 0 };     ip_address_t* ipaddresshex = ip_getmyipaddr();     wli_connectssid_t connectssid;     wli_connectpassphrase_t connectpassphrase;     nci_return_t returnvalue = nci_failure;     int32_t result = int32_c(-1);     if (wli_success != wli_init())         return (rc_platform_error);      connectssid = (wli_connectssid_t) wlan_connect_wpa_ssid;     connectpassphrase = (wli_connectpassphrase_t) wlan_connect_wpa_pass;      /*dhcp */     returnvalue = nci_setipdhcp(null);     if (returnvalue != nci_success){         printf("error in setting ip dhcp\n\r");         return (rc_platform_error);     }      if (wli_success == wli_connectwpa(connectssid, connectpassphrase, null){          returnvalue = nci_getipsettings(&myipsettings);         if (nci_success == returnvalue){             *ipaddresshex = basics_htonl(myipsettings.ipv4);             result = ip_convertaddrtostring(ipaddresshex, ipaddress);             if (result < 0){                 printf("couldn't convert ip address string format \r\n ");                 return (rc_platform_error);             }             printf("connected wpa network \r\n ");             printf(" ip address of device %s \r\n ", ipaddress);             return (rc_ok);         }         else{             printf("error in getting ip settings\n\r");             return (rc_platform_error);         }     }    else       return (rc_platform_error);     return rc_ok; }   /* task calls nttp client */ void dataoffload(void* handle) {     (void) handle;       (;;){          ....          http_connserver(null);          ...          vtaskdelay(1000/porttick_rate_ms);      }  }  void http_connserver(void * pvparameters){      retcode_t rc = rc_ok;     msg_t* msg_ptr;     ip_port_t destport = (ip_port_t) dest_port_number;     static callable_t sentcallable;     char const *url_ptr = "/";       callable_t * callable_pointer;     callable_pointer = callable_assign(&sentcallable, http_callbackonsent);     if (callable_pointer == null)         return;      rc = httpclient_initrequest(&destaddr, ip_convertinttoport(destport), &msg_ptr);     if (rc != rc_ok || msg_ptr == null)         return;      rc = msg_prependpartfactory( msg_ptr, &http_setcontent);     if (rc != rc_ok)        return;      rc = httpmsg_setrequrl(msg_ptr, url_ptr);     if (rc != rc_ok)          return;      httpmsg_setreqmethod(msg_ptr, http_method_post);      rc = httpclient_pushrequest(msg_ptr, &sentcallable,         http_clientresponsecallback);     if (rc != rc_ok){         printf("failed httpclient_pushrequest \r\n  ");         return;     } } 


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -