Simple app demonstrating network join feature of WiConnect Host Library.

Dependencies:   WiConnect mbed

Files at this revision

API Documentation at this revision

Comitter:
dan_ackme
Date:
Mon Nov 03 23:49:14 2014 +0000
Parent:
14:e0b452b47655
Commit message:
Fixed bug in channel mask setting

Changed in this revision

WiConnect.lib Show annotated file Show diff for this revision Revisions of this file
example.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/WiConnect.lib	Mon Oct 27 21:18:25 2014 +0000
+++ b/WiConnect.lib	Mon Nov 03 23:49:14 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/ACKme/code/WiConnect/#b2bdbc018665
+http://mbed.org/teams/ACKme/code/WiConnect/#9b690d76eedf
--- 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
     }