Sensinode NSDL demo with WiFi interface

Dependencies:   Beep C12832_lcd LM75B MMA7660 WiflyInterface mbed-rtos mbed nsdl_lib

Fork of NSDL_HelloWorld by Sensinode

Revision:
8:f5f58eb0af34
Parent:
7:6b068978be9a
diff -r 6b068978be9a -r f5f58eb0af34 main.cpp
--- a/main.cpp	Tue Oct 22 10:50:05 2013 +0000
+++ b/main.cpp	Mon May 12 06:02:52 2014 +0000
@@ -1,5 +1,5 @@
 #include "mbed.h"
-#include "EthernetInterface.h"
+#include "WiflyInterface.h"
 #include "C12832_lcd.h"
 #include "nsdl_support.h"
 #include "dbg.h"
@@ -33,32 +33,31 @@
 uint8_t lifetime_ptr[] = {"1200"};
 
 // ****************************************************************************
-// Ethernet initialization
+// WiFly interface initialization
 
-EthernetInterface eth;
+WiflyInterface wifly(p9, p10, p30, p29, "ssid", "password", WPA);
 
-static void ethernet_init()
+static void wifly_init()
 {
     char mbed_uid[33]; // for creating unique name for the board
 
     /* Initialize network */
-#ifdef DHCP
     NSDL_DEBUG("DHCP in use\r\n");
-    eth.init();
-#else
-    eth.init(IP, MASK, GW);
-#endif
-    if(eth.connect(30000) == 0)
-        pc.printf("Connect OK\n\r");
+    wifly.init();
+
+    while(!wifly.connect())
+        ;
+        
+    pc.printf("Connect OK\n\r");
 
     mbed_interface_uid(mbed_uid);
     mbed_uid[32] = '\0';
     strncat(endpoint_name, mbed_uid + 27, 15 - strlen(endpoint_name));
 
     lcd.locate(0,11);
-    lcd.printf("IP:%s", eth.getIPAddress());
+    lcd.printf("IP:%s", wifly.getIPAddress());
 
-    NSDL_DEBUG("IP Address:%s ", eth.getIPAddress());
+    NSDL_DEBUG("IP Address:%s ", wifly.getIPAddress());
 }
 
 // ****************************************************************************
@@ -138,8 +137,8 @@
     lcd.printf("mbed NanoService demo");
     NSDL_DEBUG("mbed NanoService Example App 0.1\n");
     
-    // Initialize Ethernet interface first
-    ethernet_init();
+    // Initialize Wifly interface first
+    wifly_init();
     
     // Initialize NSP node
     nsp_init();