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, committed 2018-02-14
- Comitter:
- MarceloSalazar
- Date:
- Wed Feb 14 15:09:00 2018 +0000
- Parent:
- 3:bd00f3af8f03
- Child:
- 5:c18fab181ede
- Commit message:
- Remove useless README.md
Changed in this revision
| README.md | Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/README.md Wed Feb 14 13:22:50 2018 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-# Simple Mbed Cloud Client application
-
-### Overview
-
-This is a reference application for platform vendors. It demonstrates how to create a simple Mbed Cloud Client application that can connect to Mbed Cloud, register resources and get ready to receive a firmware update.
-
-It's intenteded to be forked and customized to add platform specific features (sensors, actuators) and configure the connectivity and storage to work **out-of-the-box**.
-The Simple Mbed Cloud Client application is intended to work in **developer mode** only. For production considerations, please read the following [document].
-
-### Setup process
-
-This is a summary of the process for developers to get started and get a device connected to Mbed Cloud.
-
-#### Mbed Online IDE
-
-- Import application into the Online IDE
-- Add API key to stablish connection to Mbed Cloud
-- Install developer certificate
-- Compile & program
-
-#### Mbed CLI tools
-
-- Import application in developer's desktop:
-
-```
-mbed import https://github.com/ARMmbed/simple-mbed-cloud-client-example
-cd simple-mbed-cloud-client-example
-```
-- Download developer certificate from Mbed Cloud
-
-- Compile & program
-
-```
-mbed compile -t <toolchain> -m <target> -c -f
-```
-
-### Porting to a new platform
-
-The hardware requirements for Mbed OS platforms to support Mbed Cloud Client as shown [here].
-This template application works with the [FRDM-K64F](https://os.mbed.com/platforms/FRDM-K64F/) platform by default.
-
-However, adding a new platform requires the following:
-
-- Fork the template and create an example application for your platform in https://os.mbed.com
-- Modify `mbed_app.json` with corresponding addresses to match your platform memory map.
-
-```
- "K64F": {
- "target.mbed_app_start": "0x00020400",
- "update-client.application-details": "0x00020000",
- "update-client.bootloader-details": "0x172e4"
- }
-```
-- [Optional] Change connectivity interface. By default uses Ethernet. See lines [xxx].
-- [Optional] Change the filesystem and/or the block device for storage. By default uses FAT filesystem over SD card. See lines [xxx].
-- Create a [bootloader binary](TBD) according to addresses specified in `mbed_app.json`. The booloader has to use the same storage configuration specified in the application.
-
-### Known issues
-
-None.
-
--- 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);
}
}