LED Demo for Tech Con 2014
Dependencies: EthernetInterface PololuLedStripx mbed-rtos mbed nanoservice_client_1_12_X
Fork of LPC1768_LWM2M_Client by
Diff: main.cpp
- Revision:
- 1:09a525977925
- Parent:
- 0:9101343a70cd
- Child:
- 2:4166c3e5b321
diff -r 9101343a70cd -r 09a525977925 main.cpp --- a/main.cpp Tue Jul 22 23:58:23 2014 +0000 +++ b/main.cpp Sat Sep 27 21:53:28 2014 +0000 @@ -1,15 +1,10 @@ #include "mbed.h" #include "EthernetInterface.h" -#include "C12832_lcd.h" #include "nsdl_support.h" #include "dbg.h" -// Include various resources -#include "temperature.h" +// Include resources #include "light.h" -#include "gps.h" -#include "relay.h" -static C12832_LCD lcd; Serial pc(USBTX, USBRX); // tx, rx // **************************************************************************** @@ -20,19 +15,19 @@ #define DHCP /* Manual IP configurations, if DHCP not defined */ -#define IP "10.45.0.206" +#define IP "10.0.0.199" #define MASK "255.255.255.0" -#define GW "10.45.0.1" +#define GW "10.0.0.1" // NSP configuration /* Change this IP address to that of your NanoService Platform installation */ //static const char* NSP_ADDRESS = "217.140.101.20"; /* public mbed demo server */ -static const char* NSP_ADDRESS = "192.168.1.220"; /* demo NSP, web interface at http://nanoservice-demo.mbed.org*/ -//static const char* NSP_ADDRESS = "192.168.1.200"; /* demo NSP, web interface at http://nanoservice-demo.mbed.org*/ +static const char* NSP_ADDRESS = "23.99.99.252"; // barista.cloudapp.net +//static const char* NSP_ADDRESS = "192.168.1.200"; static const int NSP_PORT = 5683; -char endpoint_name[16] = "mbed-"; +char endpoint_name[24] = "mbed-LED-booth-1"; uint8_t ep_type[] = {"mbed_device"}; -uint8_t lifetime_ptr[] = {"1200"}; +uint8_t lifetime_ptr[] = {"60"}; // **************************************************************************** // Ethernet initialization @@ -41,25 +36,19 @@ static void ethernet_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(); + NSDL_DEBUG("eth.init\r\n"); #else eth.init(IP, MASK, GW); + NSDL_DEBUG("eth.init\r\n"); #endif if(eth.connect(30000) == 0) 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()); - NSDL_DEBUG("IP Address:%s ", eth.getIPAddress()); } @@ -79,8 +68,6 @@ NSDL_DEBUG("name: %s", endpoint_name); NSDL_DEBUG("NSP=%s - port %d\n", NSP_ADDRESS, NSP_PORT); - lcd.locate(0,22); - lcd.printf("EP name:%s\n", endpoint_name); } // **************************************************************************** @@ -112,10 +99,7 @@ nsdl_create_static_resource(resource_ptr, sizeof("dev/mdl")-1, (uint8_t*) "dev/mdl", 0, 0, (uint8_t*) "NSDL-C mbed device", sizeof("NSDL-C mbed device")-1); // Dynamic resources - create_temperature_resource(resource_ptr); create_light_resource(resource_ptr); - create_gps_resource(resource_ptr); - create_relay_resource(resource_ptr); /* Register with NSP */ endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t*)endpoint_name, ep_type, lifetime_ptr); @@ -135,9 +119,6 @@ int main() { - lcd.cls(); - lcd.locate(0,0); - lcd.printf("mbed NanoService demo"); NSDL_DEBUG("mbed NanoService Example App 0.1\n"); // Initialize Ethernet interface first