Pelion test

Revision:
4:7c58c47eca55
Parent:
0:6d2053b84a92
Child:
7:826cdcc3c8ec
diff -r c8de11b0ce7c -r 7c58c47eca55 main.cpp
--- a/main.cpp	Wed Dec 26 12:33:36 2018 +0900
+++ b/main.cpp	Fri Feb 15 12:53:56 2019 +0900
@@ -21,6 +21,10 @@
 #include "simple-mbed-cloud-client.h"
 #include "FATFileSystem.h"
 
+// Include photo and icon jpeg data
+#include "icon.h"
+#include "photo.h"
+
 // An event queue is a very useful structure to debounce information between contexts (e.g. ISR and normal threads)
 // This is great because things such as network operations are illegal in ISR, so updating a resource in a button's fall() function is not allowed
 EventQueue eventQueue;
@@ -36,6 +40,7 @@
 // Declaring pointers for access to Pelion Device Management Client resources outside of main()
 MbedCloudClientResource *button_res;
 MbedCloudClientResource *pattern_res;
+MbedCloudClientResource *res_camera_capture;
 
 void button_press() {
     int v = button_res->get_value_int() + 1;
@@ -43,6 +48,18 @@
     button_res->set_value(v);
 
     printf("User button clicked %d times\n", v);    
+    M2MResource* m2m_res = res_camera_capture->get_m2m_resource();
+    if(v % 2 == 0) {
+        m2m_res->set_value((const uint8_t *)data_icon, data_icon_len);
+    } else {
+        m2m_res->set_value((const uint8_t *)data_photo, data_photo_len);
+    }  
+}
+
+void res_camera_capture_callback(MbedCloudClientResource *resource, const NoticationDeliveryStatus status)
+{
+    printf("camera notification, status: %s (%d)\n", 
+    	MbedCloudClientResource::delivery_status_to_string(status), status);
 }
 
 /**
@@ -135,6 +152,12 @@
     pattern_res->methods(M2MMethod::GET | M2MMethod::PUT);
     pattern_res->attach_put_callback(pattern_updated);
 
+	res_camera_capture = client.create_resource("3200/0/4014", "CameraCapture");
+    res_camera_capture->set_value(0);
+    res_camera_capture->methods(M2MMethod::GET);
+    res_camera_capture->observable(true);
+    res_camera_capture->attach_notification_callback(res_camera_capture_callback);
+
     MbedCloudClientResource *blink_res = client.create_resource("3201/0/5850", "blink_action");
     blink_res->methods(M2MMethod::POST);
     blink_res->attach_post_callback(blink_callback);