Sensinode NSDL demo with WiFi interface

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

Fork of NSDL_HelloWorld by Sensinode

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Mon May 12 06:02:52 2014 +0000
Parent:
7:6b068978be9a
Commit message:
Initial release

Changed in this revision

EthernetInterface.lib Show diff for this revision Revisions of this file
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
nsdl_support.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6b068978be9a -r f5f58eb0af34 EthernetInterface.lib
--- a/EthernetInterface.lib	Tue Oct 22 10:50:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#dd9794ce1d64
diff -r 6b068978be9a -r f5f58eb0af34 WiflyInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WiflyInterface.lib	Mon May 12 06:02:52 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/mbed/code/WiflyInterface/#a27cf731e79a
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();
diff -r 6b068978be9a -r f5f58eb0af34 mbed.bld
--- a/mbed.bld	Tue Oct 22 10:50:05 2013 +0000
+++ b/mbed.bld	Mon May 12 06:02:52 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file
diff -r 6b068978be9a -r f5f58eb0af34 nsdl_support.cpp
--- a/nsdl_support.cpp	Tue Oct 22 10:50:05 2013 +0000
+++ b/nsdl_support.cpp	Mon May 12 06:02:52 2014 +0000
@@ -4,10 +4,10 @@
 #include "nsdl_support.h"
 #include "mbed.h"
 #include "rtos.h"
-#include "EthernetInterface.h"
+#include "WiflyInterface.h"
 
 extern Serial pc;
-extern EthernetInterface eth;
+extern WiflyInterface wifly;
 extern Endpoint nsp;
 extern UDPSocket server;
 extern char endpoint_name[16];