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 14:5acd59fec679, committed 2014-03-26
- Comitter:
- zdshelby
- Date:
- Wed Mar 26 22:33:45 2014 +0000
- Parent:
- 13:b52d83adc1ab
- Child:
- 15:db022645bcc1
- Commit message:
- - Fixed IP address resources
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
resources/light.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Mar 26 22:16:52 2014 +0000 +++ b/main.cpp Wed Mar 26 22:33:45 2014 +0000 @@ -32,7 +32,7 @@ char mbed_uid[33]; // for creating unique name for the board uint8_t ep_type[] = {"mbed_lpc1768_appboard"}; uint8_t lifetime_ptr[] = {"60"}; -static const char* FIRMWARE_VER = "0.91"; // Used in static resource +static const char* FIRMWARE_VER = "14"; // Committed revision number char* mac; char* ipAddr; char* gateway; @@ -120,10 +120,14 @@ nsdl_create_static_resource(resource_ptr, sizeof("3/0/1")-1, (uint8_t*) "3/0/1", 0, 0, (uint8_t*) "LPC1768 App Board", sizeof("LPC1768 App Board")-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, sizeof(FIRMWARE_VER)); - nsdl_create_static_resource(resource_ptr, sizeof("4/0/0")-1, (uint8_t*) "4/0/0", 0, 0, (uint8_t*) "Ethernet", sizeof("Ethernet")-1); - nsdl_create_static_resource(resource_ptr, sizeof("4/0/1")-1, (uint8_t*) "4/0/1", 0, 0, (uint8_t*) "Ethernet", sizeof("Ethernet")-1); - nsdl_create_static_resource(resource_ptr, sizeof("4/0/4")-1, (uint8_t*) "4/0/4", 0, 0, (uint8_t*) ipAddr, 15); - nsdl_create_static_resource(resource_ptr, sizeof("4/0/5")-1, (uint8_t*) "4/0/5", 0, 0, (uint8_t*) gateway, 15); + #ifdef DHCP + nsdl_create_static_resource(resource_ptr, sizeof("4/0/0")-1, (uint8_t*) "4/0/0", 0, 0, (uint8_t*) "Ethernet DHCP", sizeof("Ethernet DHCP")-1); + #else + nsdl_create_static_resource(resource_ptr, sizeof("4/0/0")-1, (uint8_t*) "4/0/0", 0, 0, (uint8_t*) "Ethernet Static", sizeof("Ethernet Static")-1); + #endif + nsdl_create_static_resource(resource_ptr, sizeof("4/0/1")-1, (uint8_t*) "4/0/1", 0, 0, (uint8_t*) "Ethernet (Static, DHCP)", sizeof("Ethernet (Static, DHCP)")-1); + nsdl_create_static_resource(resource_ptr, sizeof("4/0/4")-1, (uint8_t*) "4/0/4", 0, 0, (uint8_t*) ipAddr, strlen(ipAddr)); + nsdl_create_static_resource(resource_ptr, sizeof("4/0/5")-1, (uint8_t*) "4/0/5", 0, 0, (uint8_t*) gateway, strlen(gateway)); nsdl_create_static_resource(resource_ptr, sizeof("3/0/16")-1, (uint8_t*) "3/0/16", 0, 0, (uint8_t*) "UDP", sizeof("UDP")-1); // Dynamic resources @@ -152,7 +156,7 @@ { lcd.cls(); lcd.locate(0,0); - lcd.printf("NanoService LWM2M %s", FIRMWARE_VER); + lcd.printf("NanoService LWM2M r%s", FIRMWARE_VER); NSDL_DEBUG("NanoService LWM2M Demo for LPC1768 App Board\n"); // Initialize Ethernet interface first
--- a/resources/light.cpp Wed Mar 26 22:16:52 2014 +0000 +++ b/resources/light.cpp Wed Mar 26 22:33:45 2014 +0000 @@ -7,10 +7,9 @@ #define LIGHT_RES_ID "311/0/5851" extern Serial pc; -//PwmOut led1(LED1); static PwmOut led2(LED2); static PwmOut led3(LED3); -//PwmOut led4(LED4); + /* Only GET and PUT method allowed */ static uint8_t light_resource_cb(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto) @@ -42,10 +41,8 @@ led_dimm = atof(led_dimm_temp); led_dimm = led_dimm/100; - //led1.write(led_dimm); led2.write(led_dimm); led3.write(led_dimm); - //led4.write(led_dimm); coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CHANGED); sn_nsdl_send_coap_message(address, coap_res_ptr);