More advanced 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 MBED_DEMOS

Committer:
sstark
Date:
Tue Apr 08 01:02:06 2014 +0000
Revision:
20:84ee332ba360
Parent:
8:f0ecb62bda47
Properly use the RGB_LED define to exclude the creation of the RGB resource, and encapsulate the RGB PwmOut object in an RBG class to avoid having the pins activated when they were initialized statically.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 2:7e489126fe7a 1 // GPS resource implementation
bogdanm 2:7e489126fe7a 2
bogdanm 2:7e489126fe7a 3 #include "mbed.h"
bogdanm 2:7e489126fe7a 4 #include "nsdl_support.h"
bogdanm 2:7e489126fe7a 5 #include "gps.h"
bogdanm 2:7e489126fe7a 6
bogdanm 2:7e489126fe7a 7 #define GPS_RES_ID "gps/loc"
bogdanm 2:7e489126fe7a 8
bogdanm 2:7e489126fe7a 9 extern Serial pc;
zdshelby 8:f0ecb62bda47 10 static uint8_t res_gps_val[] = {"41.3575123, 2.1249663"};
bogdanm 2:7e489126fe7a 11
bogdanm 2:7e489126fe7a 12 /* Only GET method allowed */
bogdanm 2:7e489126fe7a 13 static uint8_t gps_resource_cb(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto)
bogdanm 2:7e489126fe7a 14 {
bogdanm 2:7e489126fe7a 15 sn_coap_hdr_s *coap_res_ptr = 0;
bogdanm 2:7e489126fe7a 16 static float led_dimm = 0;
bogdanm 2:7e489126fe7a 17 int led_state = 0;
bogdanm 2:7e489126fe7a 18 char led_dimm_temp[4];
bogdanm 2:7e489126fe7a 19
bogdanm 2:7e489126fe7a 20 pc.printf("gps callback\r\n");
bogdanm 2:7e489126fe7a 21
bogdanm 2:7e489126fe7a 22 coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
bogdanm 2:7e489126fe7a 23
bogdanm 2:7e489126fe7a 24 led_state = led_dimm * 100;
bogdanm 2:7e489126fe7a 25 sprintf(led_dimm_temp, "%d", led_state);
bogdanm 2:7e489126fe7a 26
bogdanm 2:7e489126fe7a 27 coap_res_ptr->payload_len = sizeof(res_gps_val)-1;
bogdanm 2:7e489126fe7a 28 coap_res_ptr->payload_ptr = (uint8_t*)res_gps_val;
bogdanm 2:7e489126fe7a 29
bogdanm 2:7e489126fe7a 30 sn_nsdl_send_coap_message(address, coap_res_ptr);
bogdanm 2:7e489126fe7a 31
bogdanm 2:7e489126fe7a 32 sn_coap_parser_release_allocated_coap_msg_mem(coap_res_ptr);
bogdanm 2:7e489126fe7a 33
bogdanm 2:7e489126fe7a 34 return 0;
bogdanm 2:7e489126fe7a 35 }
bogdanm 2:7e489126fe7a 36
bogdanm 2:7e489126fe7a 37 int create_gps_resource(sn_nsdl_resource_info_s *resource_ptr)
bogdanm 2:7e489126fe7a 38 {
zdshelby 8:f0ecb62bda47 39 nsdl_create_dynamic_resource(resource_ptr, sizeof(GPS_RES_ID)-1, (uint8_t*)GPS_RES_ID, 0, 0, 1, &gps_resource_cb, SN_GRS_GET_ALLOWED);
bogdanm 2:7e489126fe7a 40 return 0;
bogdanm 2:7e489126fe7a 41 }