This example has been deprecated and is no longer maintained.
Please migrate your example application to mbed-os-example-pelion
(aka Simple Mbed Cloud Client template)
This is a template application to showcase device management capabilities. It demonstrates how to create a simple application that can connect to the Pelion IoT Platform service, register resources and get ready to receive a firmware update.
It's intended to be forked and customized to add platform-specific features (such as sensors and actuators) and configure the connectivity and storage to work out-of-the-box. The template application works in developer mode by default.
There is a mirror version of the stable (master) template application on this location to facilitate the fork and publish on https://os.mbed.com.
There are a number of applications that make usage of the Simple Pelion DM Client library.
The Pelion Quick-Start is an initiative to support Mbed Partner's platforms while delivering a great User Experience to Mbed Developers.
This is a summary of the process for developers to get started and get a device connected to Pelion Device Management.
- Import the application into the Online IDE.
- Add the API key to establish connection.
- Install the developer certificate.
- Compile and program.
-
Import the application into your desktop:
mbed import https://github.com/ARMmbed/pelion-ready-example cd pelion-ready-example
-
Configure the API key for your Pelion Portal account.
If you don't have an API key available, then login in Pelion IoT Platform portal, navigate to 'Access Management', 'API keys' and create a new one. Then specify the API key as global
mbed
configuration:mbed config -G CLOUD_SDK_API_KEY <your-api-key>
-
Install the device management certificate:
mbed dm init -d "company.com" --model-name "product-model" -q --force
-
Compile and program:
mbed compile -t <toolchain> -m <target> -f
The template example uses a ticker object to periodically fire a software interrupt to simulate button presses. Let’s say you want to make an actual button press.
By default, there is a Ticker object, which fires every five seconds and invokes a callback function:
Ticker timer;
timer.attach(eventQueue.event(&fake_button_press), 5.0);
This callback function changes the button_res
resource:
void fake_button_press() {
int v = button_res->get_value_int() + 1;
button_res->set_value(v);
printf("Simulated button clicked %d times\n", v);
}
If you want to change this to an actual button, here is how to do it:
-
Remove:
Ticker timer; timer.attach(eventQueue.event(&fake_button_press), 5.0);
-
Declare an
InterruptIn
object on the button, and attach the callback function to thefall
handler:InterruptIn btn(BUTTON1); btn.fall(eventQueue.event(&fake_button_press), 5.0);
-
Rename
fake_button_press
toreal_button_press
.
Mbed OS 5.10 and Mbed CLI 1.9 simplifies the process to enable and perform Firmware Updates. Here is a summary on how to configure the device and verify its correct behaviour.
For full documentation about bootloaders and firmware update, read the following documents:
- Introduccion to bootloaders
- Creating and using a bootloader
- Bootloader configuration in Mbed OS
- Mbed Bootloader for Pelion Device Management Client
- Updating devices with Arm Mbed CLI
This is a summary to use Arm Mbed OS managed bootloaders.
Follow these steps to generate a manifest, compile and perform a firmware update of your device:
-
Configure the API key for your Pelion account.
If you don't have an API key available, then login in Pelion IoT Platform portal, navigate to 'Access Management', 'API keys' and create a new one. Then specify the API key as global
mbed
configuration:mbed config -G CLOUD_SDK_API_KEY <your-api-key>
-
Initialize the device management feature:
mbed dm init -d "company.com" --model-name "product-model" -q --force
-
Compile the application, include the firware update credentials generated before, merge with the bootloader and program the device:
mbed compile -t <toolchain> -m <target> -c -f
-
Open a serial terminal, verify the application boots and is able to register to the Device Management service. Write down the
<endpoint ID>
, as it's required to identify the device to perform a firmware update. -
Update the firmware of the device through Mbed CLI:
mbed dm update device -D <device ID> -t <toolchain> -m <target>
Inspect the logs on the device to see the update progress. It should look similar to:
Firmware download requested Authorization granted Downloading: [+++- ] 6 %
When the download completes, the firmware is verified. If everything is OK, the firmware update is applied, the device reboots and attemps to connect to the Device Management service again. The
<endpoint ID>
should be preserved.
The Simple Pelion Client provides Greentea tests to confirm your platform works as expected. The network and storage configuration is already defined in Mbed OS 5.10, but you may want to override the configuration in mbed_app.json
.
For details on Simple Pelion Client testing, refer to the documentation here.
This template application contains a working application and tests passing for the K64F
and K66F
platforms.