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:
- 114:b11bb96c09f3
- Parent:
- 113:888e262ff0a9
- Child:
- 116:2296cf274661
--- a/source/WiFiManager.cpp Sat May 18 10:50:49 2019 +0000 +++ b/source/WiFiManager.cpp Sat May 18 15:44:48 2019 +0000 @@ -50,6 +50,7 @@ WiFiManager::~WiFiManager() { + delete network; } //#define DISABLE_WATCHDOG @@ -113,7 +114,13 @@ return true; } - +void WiFiManager::getWiFiInstance() +{ + network = WiFiInterface::get_default_instance(); + if (!network) { + dbg_printf(LOG, "ERROR: No WiFiInterface found.\n"); + } +} void WiFiManager::runMain(){ nsapi_error_t error; @@ -417,6 +424,12 @@ nsapi_size_or_error_t WiFiManager::scanNetworks() { + getWiFiInstance(); + if(network == NULL) + { + dbg_printf(LOG, "\n [WIFI-MAN] Error instantiating WiFi!! \n"); + return 0; + } nsapi_error_t error; dbg_printf(LOG, "\n [WIFI-MAN] About to start scan for WiFi networks\n"); lastScanCount = network->scan(NULL, 0); @@ -429,6 +442,12 @@ // nsapi_size_t ncount) nsapi_size_or_error_t WiFiManager::getAvailableAPs(nsapi_size_t ncount) { + getWiFiInstance(); + if(network == NULL) + { + dbg_printf(LOG, "\n [WIFI-MAN] Error instantiating WiFi!! \n"); + return 0; + } WiFiAccessPoint *ap; nsapi_size_or_error_t count; count = ncount; @@ -739,6 +758,12 @@ nsapi_error_t WiFiManager::connect() { + getWiFiInstance(); + if(network == NULL) + { + dbg_printf(LOG, "\n [WIFI-MAN] Error instantiating WiFi!! \n"); + return 0; + } nsapi_error_t error; dbg_printf(LOG, "\n [WIFI-MAN] About to connect to WiFi network\n"); network->attach(callback(this, &WiFiManager::status_callback));