Simple app demonstrating the HTTP GET feature of the WiConnect Host Library.

Dependencies:   WiConnect mbed

Files at this revision

API Documentation at this revision

Comitter:
dan_ackme
Date:
Mon Nov 03 23:58:14 2014 +0000
Parent:
10:040d4294960c
Commit message:
Specify network credentials in example.

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	Sun Sep 07 02:14:49 2014 +0000
+++ b/WiConnect.lib	Mon Nov 03 23:58:14 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/ACKme/code/WiConnect/#2d7ef60a9f2a
+http://mbed.org/teams/ACKme/code/WiConnect/#9b690d76eedf
--- a/example.cpp	Sun Sep 07 02:14:49 2014 +0000
+++ b/example.cpp	Mon Nov 03 23:58:14 2014 +0000
@@ -19,10 +19,18 @@
  */
 
 // the URL of the webpage to GET
-#define HTTP_URL "http://ack.me"
+#define HTTP_URL "http://mbed.org/"
 
 
+// This is the name of your WiFi network
+// 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 "<YOUR SSID>"
 
+// This is the password of your WiFi network
+// Leave as empty string (e.g "") to connect to OPEN network
+#define NETWORK_PASSWORD "<YOUR PASSWORD>"
 
 
 /******************************************************************************
@@ -87,6 +95,15 @@
                 "Make sure the wires are connected correctly\r\n");
         for(;;); // infinite loop
     }
+    
+    printf("Joining Wi-Fi network: %s\r\n", NETWORK_SSID);
+    if(wiconnect.join(NETWORK_SSID, NETWORK_PASSWORD) != WICONNECT_SUCCESS)
+    {
+        NetworkJoinResult joinResult;
+        wiconnect.getNetworkJoinResult(&joinResult);
+        printf("Failed to send join command. Join result: %s\r\n", Wiconnect::networkJoinResultToStr(joinResult));
+        for(;;); // infinite loop
+    }
 
 
     //-------------------------------------------------------------------------
@@ -104,7 +121,7 @@
     // NOTE: the module must have valid network credentials
     if(wiconnect.httpGet(socket, HTTP_URL) != WICONNECT_SUCCESS)
     {
-        printf("Failed to issue HTTP request. Does the module have valid network credentials?\r\n");
+        printf("Failed to issue HTTP request\r\n");
         for(;;); // infinite loop
     }