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.
Diff: main.cpp
- Revision:
- 6:254a7e7fbef1
- Parent:
- 5:c18fab181ede
- Child:
- 8:ace9e5de6491
diff -r c18fab181ede -r 254a7e7fbef1 main.cpp
--- a/main.cpp Wed Feb 14 17:26:42 2018 -0600
+++ b/main.cpp Thu Feb 15 10:14:35 2018 -0600
@@ -111,9 +111,6 @@
printf("IP address %s\n", ip_addr);
}
- // 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.
client = &mbedClient;
@@ -144,6 +141,14 @@
mbedClient.register_and_connect();
+ // Wait for client to finish registering
+ while (!mbedClient.is_client_registered()) {
+ wait_ms(100);
+ }
+
+ // Placeholder for callback to update local resource when GET comes.
+ timer.attach(&button_press, 5.0);
+
// Check if client is registering or registered, if true sleep and repeat.
while (mbedClient.is_register_called()) {
static int button_count = 0;