Clark Jarvis / Mbed OS mbed-cloud-example-lpc546xx

Fork of mbed-cloud-example-lpc546xx by Mac Lobdell

Revision:
5:e521ea1f4c22
Child:
6:19cb3d7341c6
diff -r 5994ee6e8f63 -r e521ea1f4c22 Code_Additions.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Code_Additions.txt	Thu Oct 11 14:29:07 2018 +0000
@@ -0,0 +1,49 @@
+
+
+
+static MbedCloudClientResource* rate_ptr;
+
+// Mbed Cloud Client resource setup
+MbedCloudClientResource *button = mbedClient.create_resource("3200/0/5501", "button_resource");
+button->set_value("0");
+button->methods(M2MMethod::GET);
+button->observable(true);
+button->attach_notification_callback(button_callback);
+
+MbedCloudClientResource *rate = mbedClient.create_resource("3201/0/5853", "blink_rate_resource");
+rate->set_value("500");
+rate->methods(M2MMethod::GET | M2MMethod::PUT);
+rate->observable(false);
+rate->attach_put_callback(blink_rate_updated);
+rate_ptr = rate;
+
+MbedCloudClientResource *blink = mbedClient.create_resource("3201/0/5850", "blink_enable_resource");
+blink->methods(M2MMethod::POST);
+blink->attach_post_callback(blink_enable_callback);
+    
+
+
+
+    
+void blink_rate_updated(const char *) {
+    printf("PUT received, Storing LED Blink Rate: %s (ms)\r\n", rate_ptr->get_value().c_str());
+}
+
+void blink_enable_callback(void *) {
+    String pattern_str = rate_ptr->get_value();
+    const char *rate = pattern_str.c_str();
+    printf("POST received. Enabling LED Blink Rate = %s (ms)\n", rate);
+
+    float value = atoi(rate_ptr->get_value().c_str())/1000.0;
+    timer.detach();
+    timer.attach(&led_toggle,value);
+}
+
+void button_callback(const M2MBase& object, const NoticationDeliveryStatus status)
+{
+    printf("Button notification. Callback: (%s)\n", object.uri_path());
+}
+
+
+
+button->set_value(button_count);