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 MBED_DEMOS

Revision:
32:7f3f1ef700e3
Parent:
8:f0ecb62bda47
--- 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