Example program for the SeeedStudio WiFi Shield V2.0, based on UART serial port connectivity (D0/D1 pins). This program connects to WiFi hotspot, obtains an IP using DHCP and downloads http://mbed.org/media/uploads/mbed_official/hello.txt

Dependencies:   WiflyInterface mbed

Revision:
0:f2524261196f
Child:
1:ced62d2a69f9
diff -r 000000000000 -r f2524261196f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Apr 08 18:40:52 2014 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+#include "WiflyInterface.h"
+
+/**
+ * D1 - TX pin (RX on the WiFi side)
+ * D0 - RX pin (TX on the WiFi side)
+ * NC - Reset pin
+ * LED1 - TCP status pin
+ * "ssid" - hostspot name
+ * "password" - hotspot passowrd
+ * security method - NONE, WEP_128, WPA, WPA2
+ */
+WiflyInterface wifi(D1, D0, NC, LED1, "hotspot", "", NONE);
+Serial pc(USBTX, USBRX);
+
+int main()
+{
+    int s = wifi.init(); // Use DHCP
+    if( s != NULL ) {
+        printf("Could not initialise. Halting!\n");
+        exit(0);
+    }
+
+    while (1) {
+        s = wifi.connect(); // Set up the chip and join the network
+
+        if( s == false ) {
+            printf("Could not connect. Retrying!\n");
+            wait(3);
+            continue;
+        } else {
+            // Print the IP address every second
+            while(1) {
+                printf("Got IP: %s\n", wifi.getIPAddress());
+                wait(1);
+            }
+        }
+    }
+}