Simple Mbed Cloud client application using features of K64 & K66 including Ethernet and SD Card

Fork of mbed-cloud-example_K64_K66 by Mac Lobdell

DEPRECATED

This example application is not maintained and not recommended. It uses an old version of Mbed OS, Pelion DM, and Arm toolchain. It doesn't work with Mbed Studio.

Please use: https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-pelion/

Revision:
5:c18fab181ede
Parent:
4:a107dae867fb
Child:
6:254a7e7fbef1
diff -r a107dae867fb -r c18fab181ede main.cpp
--- a/main.cpp	Wed Feb 14 15:09:00 2018 +0000
+++ b/main.cpp	Wed Feb 14 17:26:42 2018 -0600
@@ -29,6 +29,10 @@
 // Placeholder to hardware that trigger events (timer, button, etc)
 Ticker timer;
 
+// Placeholder for storage
+SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
+FATFileSystem fs("sd");
+
 // Pointers to the resources that will be created in main_application().
 static MbedCloudClientResource* pattern_ptr;
 
@@ -42,12 +46,13 @@
 }
 
 void pattern_updated(const char *) {
-    printf("PUT received, new value: %s\n", pattern_ptr->get_value());
+    printf("PUT received, new value: %s\n", pattern_ptr->get_value().c_str());
     // Placeholder for PUT action
 }
 
 void blink_callback(void *) {
-    const char *pattern = pattern_ptr->get_value();
+    String pattern_str = pattern_ptr->get_value();
+    const char *pattern = pattern_str.c_str();
     printf("POST received. LED pattern = %s\n", pattern);
     // Placeholder for POST action
     // The pattern is something like 500:200:500, so parse that.
@@ -72,10 +77,6 @@
     // Placeholder for network
     EthernetInterface net;
 
-    // Placeholder for storage
-    SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
-    FATFileSystem fs("sd");
-
     printf("Start Simple Mbed Cloud Client\n");
 
     // Initialize SD card
@@ -129,17 +130,17 @@
     button->set_value("0");
     button->methods(M2MMethod::GET);
     button->observable(true);
-    button->attach_notification(M2MMethod::GET, (void*)button_callback);
+    button->attach_notification_callback(button_callback);
 
     MbedCloudClientResource *pattern = mbedClient.create_resource("3201/0/5853", "pattern_resource");
     pattern->set_value("500:500:500:500");
     pattern->methods(M2MMethod::GET | M2MMethod::PUT);
-    pattern->attach(M2MMethod::PUT, (void*)pattern_updated);
+    pattern->attach_put_callback(pattern_updated);
     pattern_ptr = pattern;
 
     MbedCloudClientResource *blink = mbedClient.create_resource("3201/0/5850", "blink_resource");
     blink->methods(M2MMethod::POST);
-    blink->attach(M2MMethod::POST, (void*)blink_callback);
+    blink->attach_post_callback(blink_callback);
 
     mbedClient.register_and_connect();