![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
MQTT_PM25
Dependencies: mbed-os-example-wifi-DISCO_IOTBOARD_MQTT MQTT
Diff: main.cpp
- Revision:
- 37:3a31525e2971
- Parent:
- 35:052c1ba06ce7
- Child:
- 44:63be19b7a3db
--- a/main.cpp Wed Sep 27 11:15:04 2017 +0100 +++ b/main.cpp Fri Sep 29 10:15:04 2017 +0100 @@ -59,7 +59,7 @@ } } -void scan_demo(WiFiInterface *wifi) +int scan_demo(WiFiInterface *wifi) { WiFiAccessPoint *ap; @@ -81,6 +81,7 @@ printf("%d networks available.\n", count); delete[] ap; + return count; } void http_demo(NetworkInterface *net) @@ -132,11 +133,17 @@ int main() { + int count = 0; + printf("WiFi example\n\n"); - scan_demo(&wifi); + count = scan_demo(&wifi); + if (count == 0) { + printf("No WIFI APNs found - can't continue further.\n"); + return -1; + } - printf("\nConnecting...\n"); + printf("\nConnecting to %s...\n", MBED_CONF_APP_WIFI_SSID); int ret = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2); if (ret != 0) { printf("\nConnection error\n");