Okundu Omeni
/
wifi-https-ble-sm-uart-atcmd-5-13-1
this is using the mbed os version 5-13-1
Diff: source/WiFiManager.cpp
- Branch:
- PassingRegression
- Revision:
- 111:3ab1d9644835
- Parent:
- 110:c722dda4f2ff
- Child:
- 112:a0999ea4ece0
--- a/source/WiFiManager.cpp Thu May 09 13:21:12 2019 +0000 +++ b/source/WiFiManager.cpp Fri May 10 13:45:50 2019 +0000 @@ -183,6 +183,10 @@ wifiBusy = 1; backgroundTaskCompleted = false; set_internet_config(); + // Wait for callback semaphore +#ifdef DNANUDGE_DEBUG + callback_semaphore.wait(); +#endif int msecCount = 0; while(!backgroundTaskCompleted && msecCount < 1000) { @@ -492,9 +496,34 @@ void WiFiManager::gethostbyname() { nsapi_value_or_error_t value_or_error; - value_or_error = network->gethostbyname_async(internet_config.url, +#ifdef DNANUDGE_DEBUG + SocketAddress * addr = new SocketAddress; + bool res; + res = addr->set_ip_address("8.8.8.8"); + if(res) + { + dbg_printf(LOG, "[WIFI-MAN] added ip address %s\r\n", addr->get_ip_address()); + } + else + { + dbg_printf(LOG, "[WIFI-MAN] Error adding ip address \r\n"); + } + network->add_dns_server(*addr); +#endif + char * serverAddress = new char[100]; + char *p = strstr(internet_config.url, "//"); + if(p != NULL) + { + strcpy(serverAddress,p+2); + } + else + { + strcpy(serverAddress,internet_config.url); + } + value_or_error = network->gethostbyname_async(serverAddress, callback(this, &WiFiManager::gethostbyname_callback), NSAPI_UNSPEC); + if(value_or_error >= NSAPI_ERROR_OK) // success { dbg_printf(LOG, "[WIFI-MAN] hostname translation successful value_or_error = %d\r\n", value_or_error); @@ -741,8 +770,14 @@ } -void WiFiManager::gethostbyname_callback(nsapi_error_t result, SocketAddress *address) +void WiFiManager::gethostbyname_callback(nsapi_error_t res, SocketAddress *addr) { + nsapi_error_t result = res; + SocketAddress *address = new SocketAddress; + address = addr; +#ifdef DNANUDGE_DEBUG + callback_semaphore.release(); +#endif dbg_printf(LOG, "gethostbyname_callback called... result = %d \r\n", result); print_memory_info(); responseBytes = new uint8_t[HOSTNAME_RESPONSE_LEN]; //malloc(HOSTNAME_RESPONSE_LEN);