Red Hat Summit NanoService Demo for LPC1768 App Board using OMA Lightweight Objects
Dependencies: Beep C12832_lcd EthernetInterface LM75B MMA7660 mbed-rtos mbed nsdl_lib
Fork of LWM2M_NanoService_Ethernet by
Revision 32:7f3f1ef700e3, committed 2014-04-29
- Comitter:
- sam_grove
- Date:
- Tue Apr 29 00:41:05 2014 +0000
- Parent:
- 31:7ce5bef2d369
- Commit message:
- mbed emt node
Changed in this revision
diff -r 7ce5bef2d369 -r 7f3f1ef700e3 main.cpp --- a/main.cpp Tue Apr 29 00:29:55 2014 +0000 +++ b/main.cpp Tue Apr 29 00:41:05 2014 +0000 @@ -32,9 +32,9 @@ /* Change this IP address to that of your NanoService Platform installation */ static const char* NSP_ADDRESS = "208.111.39.209"; /* demo NSP, web interface at http://208.111.39.209/ */ static const int NSP_PORT = 5683; -char endpoint_name[20] = "mbed-station-"; +char endpoint_name[20] = "mbed-emt-"; char mbed_uid[33]; // for creating unique name for the board -uint8_t ep_type[] = {"mbed_station"}; +uint8_t ep_type[] = {"mbed_emt"}; uint8_t lifetime_ptr[] = {"60"}; static const char* FIRMWARE_VER = "25"; // Committed revision number char* mac; @@ -122,7 +122,7 @@ // Static resources nsdl_create_static_resource(resource_ptr, sizeof("3/0/0")-1, (uint8_t*) "3/0/0", 0, 0, (uint8_t*) "ARM", sizeof("ARM")-1); - nsdl_create_static_resource(resource_ptr, sizeof("3/0/1")-1, (uint8_t*) "3/0/1", 0, 0, (uint8_t*) "LPC1768 station", sizeof("LPC1768 station")-1); + nsdl_create_static_resource(resource_ptr, sizeof("3/0/1")-1, (uint8_t*) "3/0/1", 0, 0, (uint8_t*) "LPC1768 emt", sizeof("LPC1768 emt")-1); nsdl_create_static_resource(resource_ptr, sizeof("3/0/2")-1, (uint8_t*) "3/0/2", 0, 0, (uint8_t*) mbed_uid, sizeof(mbed_uid)-1); nsdl_create_static_resource(resource_ptr, sizeof("3/0/3")-1, (uint8_t*) "3/0/3", 0, 0, (uint8_t*) FIRMWARE_VER, strlen(FIRMWARE_VER)); #ifdef DHCP @@ -137,9 +137,9 @@ // Dynamic resources create_temperature_resource(resource_ptr); - create_light_resource(resource_ptr); + //create_light_resource(resource_ptr); create_gps_resource(resource_ptr); - //create_relay_resource(resource_ptr); + create_relay_resource(resource_ptr); #ifdef USE_RGBLED NSDL_DEBUG("Enabling RGB LED due to USE_RGBLED=%d\n", USE_RGBLED);
diff -r 7ce5bef2d369 -r 7f3f1ef700e3 resources/gps.cpp --- a/resources/gps.cpp Tue Apr 29 00:29:55 2014 +0000 +++ b/resources/gps.cpp Tue Apr 29 00:41:05 2014 +0000 @@ -7,7 +7,7 @@ #define GPS_RES_ID "gps/loc" extern Serial pc; -static uint8_t res_gps_val[] = {"34.154779, -118.465937"}; +static uint8_t res_gps_val[] = {"34.156541, -118.422498"}; /* Only GET method allowed */ static uint8_t gps_resource_cb(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto)
diff -r 7ce5bef2d369 -r 7f3f1ef700e3 resources/relay.cpp --- a/resources/relay.cpp Tue Apr 29 00:29:55 2014 +0000 +++ b/resources/relay.cpp Tue Apr 29 00:41:05 2014 +0000 @@ -10,6 +10,17 @@ extern Serial pc; static Beep buzzer(p26); +static DigitalOut r(p21); +static DigitalOut b(p22); +static Ticker flash; + +void rbHandler(void) +{ + r = !r; + b = !b; + buzzer.beep(1000, 0.1f); +} + /* Only GET and PUT method allowed */ static uint8_t relay_resource_cb(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto) { @@ -32,13 +43,18 @@ { if(*(received_coap_ptr->payload_ptr) == '1') { - buzzer.beep(1000,0); + flash.attach(&rbHandler, 0.2f); + r = 1; + b = 0; relay_state = '1'; } else if(*(received_coap_ptr->payload_ptr) == '0') { buzzer.nobeep(); + flash.detach(); + r = 1; + b = 1; relay_state = '0'; } coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CHANGED); @@ -54,5 +70,7 @@ int create_relay_resource(sn_nsdl_resource_info_s *resource_ptr) { nsdl_create_dynamic_resource(resource_ptr, sizeof(RELAY_RES_ID)-1, (uint8_t*)RELAY_RES_ID, 0, 0, 0, &relay_resource_cb, (SN_GRS_GET_ALLOWED | SN_GRS_PUT_ALLOWED)); + r = 1; + b = 1; return 0; } \ No newline at end of file