cellular port
Dependencies: Beep C027_Support C12832 LM75B MMA7660 mbed-rtos mbed nsdl_lib
This is a port of the NSDL HelloWorld for cellular.
To run the example you need a C027 and the ARM mbed application shield. The example uses cellular instead of ethernet and takes the true position from the GPS instead of using a fixed position.
Diff: resources/light.cpp
- Revision:
- 10:443e7f741c8e
- Parent:
- 8:bd9096c4784c
- Child:
- 11:fa12b9f50538
--- a/resources/light.cpp Fri Jun 06 15:16:37 2014 +0000 +++ b/resources/light.cpp Tue Jun 17 07:05:29 2014 +0000 @@ -6,8 +6,10 @@ #define LIGHT_RES_ID "lt/0/dim" -extern Serial pc; -static PwmOut led1(LED1); +static PwmOut led1(LED); +static PwmOut led2(D8); +static PwmOut led3(D9); +static PwmOut led4(D5); /* 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) @@ -17,7 +19,7 @@ int led_state = 0; char led_dimm_temp[4]; - pc.printf("light callback\r\n"); + printf("light callback\r\n"); if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET) { @@ -40,6 +42,9 @@ led_dimm = led_dimm/100; led1.write(led_dimm); + led2.write(1.f - led_dimm); + led3.write(1.f - led_dimm); + led4.write(1.f - 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); @@ -52,5 +57,9 @@ int create_light_resource(sn_nsdl_resource_info_s *resource_ptr) { nsdl_create_dynamic_resource(resource_ptr, sizeof(LIGHT_RES_ID)-1, (uint8_t*)LIGHT_RES_ID, 0, 0, 0, &light_resource_cb, (SN_GRS_GET_ALLOWED | SN_GRS_PUT_ALLOWED)); + static float led_dimm = 0; + led2.write(1.f - led_dimm); + led3.write(1.f - led_dimm); + led4.write(1.f - led_dimm); return 0; } \ No newline at end of file