Plant Monitoring CS
Revision 37:3a31525e2971, committed 2017-09-29
- Comitter:
- mbed_official
- Date:
- Fri Sep 29 10:15:04 2017 +0100
- Parent:
- 36:aa0b6789bbd2
- Child:
- 38:eb18932eacc5
- Commit message:
- Continue exmaple only if WIFI APNs are found
Stop the example if there are 0 APNs found in the scan.
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-wifi
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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");