Seeed wifi shield hello world program

Dependencies:   WiflyInterface mbed

Fork of Wifly_HelloWorld by Samuel Mokrani

Revision:
6:73c142780ad9
Parent:
5:867d16e948eb
--- a/main.cpp	Fri Aug 24 13:52:40 2012 +0000
+++ b/main.cpp	Fri Nov 08 21:44:01 2013 +0000
@@ -7,15 +7,28 @@
 *     - p9 and p10 are for the serial communication
 *     - p25 is for the reset pin
 *     - p26 is for the connection status
-*     - "mbed" is the ssid of the network
+*     - "hotspot_name" is the ssid of the network
 *     - "password" is the password
-*     - WPA is the security
+*     - WPA is the security method
 */
-WiflyInterface wifly(p9, p10, p25, p26, "mbed", "password", WPA);
+WiflyInterface eth(p9, p10, p25, p26, "hotspot_name", "password", WPA);
+
+int main()
+{
+    int s = eth.init(); //Use DHCP
 
-int main() {
-    wifly.init(); // use DHCP
-    while (!wifly.connect()); // join the network
-    printf("IP Address is %s\n\r", wifly.getIPAddress());
-    wifly.disconnect();
-}
\ No newline at end of file
+    if( s != NULL ) {
+        printf( "Could not initialise. Will halt!\n" );
+        exit( 0 );
+    }
+
+    s = eth.connect(); // set up the chip and join the network
+
+    if( s == false ) {
+        printf( "Could not connect. Will halt!\n" );
+        exit( 0 );
+    } else {
+        // print the IP address of the shield
+        printf( "IP: %s\n", eth.getIPAddress() );
+    }
+}