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

Files at this revision

API Documentation at this revision

Comitter:
screamer
Date:
Tue Apr 08 18:40:52 2014 +0000
Child:
1:ced62d2a69f9
Commit message:
Initial revision

Changed in this revision

WiflyInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WiflyInterface.lib	Tue Apr 08 18:40:52 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/components/code/WiflyInterface/#f2439377c172
--- /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);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Apr 08 18:40:52 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file