Simple Mbed Cloud Client application using features of K64 & K66

Connect to Mbed Cloud!

This example was customized a bit for FRDM-K66 and FRDM-K64F.

It depends on having an SD Card plugged in for storage of credentials. It could be changed later to use a SPI flash or other storage on a shield or wired in.

The app keeps track of how many times switch 2 (SW2) is pressed. The value can be retrieved via a GET request to Mbed Cloud.

Also, it will blink a pattern based on milisecond (ms) timing values that can be sent from Mbed Cloud. The pattern can be sent with a PUT request and the blinking sequence can be triggered by a POST request.

Revision:
4:a107dae867fb
Parent:
2:6ed27f413b30
Child:
5:c18fab181ede
diff -r bd00f3af8f03 -r a107dae867fb main.cpp
--- a/main.cpp	Wed Feb 14 13:22:50 2018 +0000
+++ b/main.cpp	Wed Feb 14 15:09:00 2018 +0000
@@ -26,7 +26,8 @@
 #include "FATFileSystem.h"
 #include "EthernetInterface.h"
 
-InterruptIn button(BUTTON1);
+// Placeholder to hardware that trigger events (timer, button, etc)
+Ticker timer;
 
 // Pointers to the resources that will be created in main_application().
 static MbedCloudClientResource* pattern_ptr;
@@ -109,8 +110,8 @@
         printf("IP address %s\n", ip_addr);
     }
 
-    // Placeholder for GET requests. Initialize button interrupt.
-    button.fall(&button_press);
+    // Placeholder for callback to update local resource when GET comes.
+    timer.attach(&button_press, 5.0);
 
     SimpleMbedCloudClient mbedClient(&net);
     // Save pointer to mbedClient so that other functions can access it.
@@ -149,7 +150,7 @@
 
         if (button_pressed) {
             button_pressed = false;
-            printf("Button clicked %d times\r\n", ++button_count);
+            printf("Simulated button clicked %d times\r\n", ++button_count);
             button->set_value(button_count);
         }
     }