NSP demo runnig over WiFi
Dependencies: Beep C12832_lcd LM75B MMA7660 WiflyInterface mbed-rtos mbed nsdl_lib
Fork of NSDL_HelloWorld by
Diff: main.cpp
- Revision:
- 8:c809b5c65a96
- Parent:
- 7:6b068978be9a
diff -r 6b068978be9a -r c809b5c65a96 main.cpp --- a/main.cpp Tue Oct 22 10:50:05 2013 +0000 +++ b/main.cpp Thu Oct 24 14:10:19 2013 +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" @@ -15,7 +15,11 @@ // **************************************************************************** // Configuration section -// Ethernet configuration +// WiFi configuration (edit this) +#define WIFI_SSID "" +#define WIFI_SECURITY WPA // NONE, WEP_128 or WPA +#define WIFI_PASSWORD "" + /* Define this to enable DHCP, otherwise manual address configuration is used */ #define DHCP @@ -33,22 +37,22 @@ uint8_t lifetime_ptr[] = {"1200"}; // **************************************************************************** -// Ethernet initialization +// WiFi initialization -EthernetInterface eth; +static WiflyInterface wifly(p9, p10, p30, p29, WIFI_SSID, WIFI_PASSWORD, WIFI_SECURITY); -static void ethernet_init() +static void wifi_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(); + wifly.init(); #else - eth.init(IP, MASK, GW); + wifly.init(IP, MASK, GW); #endif - if(eth.connect(30000) == 0) + if(wifly.connect() == 0) pc.printf("Connect OK\n\r"); mbed_interface_uid(mbed_uid); @@ -56,9 +60,9 @@ 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()); } // **************************************************************************** @@ -139,7 +143,7 @@ NSDL_DEBUG("mbed NanoService Example App 0.1\n"); // Initialize Ethernet interface first - ethernet_init(); + wifi_init(); // Initialize NSP node nsp_init();