ACKme
/
wiconnect-http_get_example
Simple app demonstrating the HTTP GET feature of the WiConnect Host Library.
Diff: example.cpp
- Revision:
- 11:b7a7a7d3b805
- Parent:
- 6:f6cf38fba1d4
--- 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 }