Simple app demonstrating network join feature of WiConnect Host Library.

Dependencies:   WiConnect mbed

Revision:
15:cb58cdbc914a
Parent:
14:e0b452b47655
diff -r e0b452b47655 -r cb58cdbc914a example.cpp
--- a/example.cpp	Mon Oct 27 21:18:25 2014 +0000
+++ b/example.cpp	Mon Nov 03 23:49:14 2014 +0000
@@ -22,12 +22,11 @@
 // Look for this name in your WiFi settings
 // (e.g. your phone's list of WiFi networks in the WiFi settings menu)
 // tip: add double-quotes around SSID to add spaces to name
-#define NETWORK_SSID "hackathon"
+#define NETWORK_SSID "<YOUR SSID>"
 
 // This is the password of your WiFi network
 // Leave as empty string (e.g "") to connect to OPEN network
-#define NETWORK_PASSWORD ""
-
+#define NETWORK_PASSWORD "<YOUR PASSWORD>"
 
 
 
@@ -55,7 +54,6 @@
 
 
 
-
 /******************************************************************************
  * Starting point of application
  */
@@ -78,7 +76,6 @@
     // The internal buffer will be dynamically allocated
     Wiconnect wiconnect(serialConfig, 256, NULL, WICONNECT_RESET_PIN);
 
-
     //-------------------------------------------------------------------------
     // STEP 2: Initiate Communication with WiFi Module
     //-------------------------------------------------------------------------
@@ -86,7 +83,7 @@
     printf("Initializing WiConnect Library...\r\n");
 
     // Initialize communication with WiFi module
-    if(wiconnect.init(true) != WICONNECT_SUCCESS)
+    if(wiconnect.init() != WICONNECT_SUCCESS)
     {
         printf("Failed to initialize communication with WiFi module!\r\n"
                 "Make sure the wires are connected correctly\r\n");
@@ -102,11 +99,14 @@
     
     // optional step, set the channel mask to force module to associate to networks on specific channels
     // this command enables all channels
-    wiconnect.setSetting("wlan.scan.mask", (uint32_t)0x3FFF);
+    char tmpBuffer[8];
+    wiconnect.setSetting("wlan.scan.channel_mask", StringUtil::hexToStr(tmpBuffer, 0x3FFF));
 
     if(WICONNECT_FAILED(result, wiconnect.join(NETWORK_SSID, NETWORK_PASSWORD)))
     {
-        printf("Failed to send join command: %d\r\n", result);
+        NetworkJoinResult joinResult;
+        wiconnect.getNetworkJoinResult(&joinResult);
+        printf("Failed to send join command: %d. Join result: %s\r\n", result, Wiconnect::networkJoinResultToStr(joinResult));
         for(;;); // infinite loop
     }