Example program for MTS WiFi Shield. Test that you can connect to a network.

Dependencies:   SocketModem mbed

Files at this revision

API Documentation at this revision

Comitter:
mfiore
Date:
Sat Jan 04 21:02:31 2014 +0000
Parent:
5:19044863e45c
Child:
7:25269711fb2c
Commit message:
put wifi->ping() in a while loop for robustness; change default Wifi::SecurityMode to Wifi::WPA since we're giving out access to our router

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Jan 04 20:29:00 2014 +0000
+++ b/main.cpp	Sat Jan 04 21:02:31 2014 +0000
@@ -14,7 +14,7 @@
     //Set the network parameters
     std::string ssid = "belkin54g";
     std::string securityKey = "hackathon";
-    Wifi::SecurityType securityType = Wifi::NONE;
+    Wifi::SecurityType securityType = Wifi::WPA;
 
     //Wait for wifi module to boot up
     for (int i = 10; i >= 0; i = i - 2) {
@@ -35,13 +35,10 @@
     printf("Set DHCP: %s\n\r", getCodeNames(wifi->setDeviceIP("DHCP")).c_str());
     printf("Connect: %s\n\r", wifi->connect() ? "Success" : "Failure");
     printf("Is Connected: %s\n\r", wifi->isConnected() ? "True" : "False");
-    printf("Ping Server: %s\n\r", wifi->ping("8.8.8.8") ? "Success" : "Failed");
-
-    //Disconnect from network
-    printf("Disconnecting...\n\r");
-    wifi->disconnect();
-    printf("Is Connected: %s\n\r", wifi->isConnected() ? "True" : "False");
-
-    printf("End Program\n\r");
-    while(1);
+    
+    //Ping 
+    while (true) {
+        printf("Ping Server: %s\n\r", wifi->ping("8.8.8.8") ? "Success" : "Failed");
+        wait(3);
+    }
 }