Device Management for Mbed OS
Pelion Client is an abstraction of Device Management Client, and lets Mbed OS devices use Pelion Device Management services. Pelion Client:
- Provides LwM2M Resources, which are variables that sync automatically through Device Management. Pelion Client makes it possible to expose sensors, actuators and other variables to a cloud service.
- Supports firmware updates with just a few lines of code.
- Runs separately from your main application; it does not take over your main loop.
- Helps avoid blocking network operations in interrupt contexts, by automatically deferring actions to a separate thread.
- Provides end-to-end Greentea tests for Device Management.
This guide builds on the quick connect guide, which creates a cloud-connected application for supported Mbed OS boards. The guide covers:
- Hardware requirements.
- Adding the library to an application.
- A list of example applications for different boards.
- Configuring the application and bootloader.
- Validation and testing.
- Troubleshooting.
Tip: To learn more about Device Management Client, see the API documentation and the tutorials.
Device Management for your Mbed OS application
Requirements
Not every device (microcontroller, module or board) is capable of running device management features. You can add or extend some hardware capabilities, such as connectivity, storage and TRNG. Others are impossible or inconvenient to extend (for example, RAM or flash).
The minimum requirements to add device management feature to your application are:
- RAM: 128 KiB or more.
- Flash: 512 KiB or more.
- Real Time Clock (RTC).
- (Optional but recommended) True Random Number Generator (TRNG).
- A storage device: SD card, SPI flash, QSPI flash or data flash.
- IP connectivity: Ethernet, Wi-Fi, cellular or 6LoWPAN.
Additionally, we recommend the latest version of Mbed OS support the device and any additional complementary hardware components, or that they have support for the APIs provided in the latest releases of Mbed OS.
Useful references:
Adding Device Management connectivity to your application
-
Add Pelion Client to your Mbed OS project:
Note: the library is called
simple-mbed-cloud-client
.$ mbed add https://github.com/ARMmbed/simple-mbed-cloud-client
If you do not have an Mbed OS project to add, you can create one with
mbed new <your_application_name>
and then runmbed add
. -
Reference the library from the
main.cpp
file, and add network and storage drivers. -
Initialize the
simple-mbed-cloud-client
library:#include "simple-mbed-cloud-client.h" #include <Block device> #include <Filesystem> #include <Network> int main() { /* Initialize connectivity */ NetworkInterface *net = NetworkInterface::get_default_instance(); net->connect(); /* Initialize storage */ BlockDevice *bd = BlockDevice::get_default_instance(); <Filesystem> fs("fs", &bd); /* Initialize SimpleMbedCloudClient */ SimpleMbedCloudClient client(net, &bd, &fs); client.init(); /* Create resource */ MbedCloudClientResource *variable; variable = client.create_resource("3201/0/5853", "variable"); variable->set_value("assign new value"); variable->methods(M2MMethod::GET | M2MMethod::PUT); }
-
Configure the API key for your Device Management account by specifying the API key as the global
mbed
configuration:$ mbed config -G CLOUD_SDK_API_KEY <your-api-key>
Tip: If you don't have an API key available, log in to Device Management Portal, navigate to
Access Management
andAPI keys
, and create a new one. -
Install the Device Management certificate:
$ mbed dm init -d "<your company name.com>" --model-name "<product model identifier>"
This creates your private and public key pair and also initializes various .c
files with these credentials, so you can use Connect and (firmware) Update device management features.
Example applications
To help you start quickly, refer to the application example. It demonstrates how to connect to the Device Management service, register Resources and get ready to receive a firmware update.
There are also several board-specific applications that focus on providing more elaborate hardware features with Mbed OS and Device Management. These are available in the Device Management quick start. See the reference table, organized by vendor name, for details: