IoTerop recently published a limited (but functional) version of their IOWA SDK. IOWA is a LwM2M stack to help you "Accelerate IoT development, build secure and manageable IoT solutions faster than ever."
In this part, you'll learn about the main concepts of LwM2M and how to use IOWA to create your first Client.
The Open Mobile Alliance's Lightweight Machine-to-Machine is an IoT device management standard.Important Links
The IOWA Github repository: https://github.com/IOTEROP/IOWA
The IOWA online documentation: https://ioterop.github.io/IOWA/LwM2M Concepts
- LwM2M Client/Device
The LwM2M Client/Device is the entity being managed by the LwM2M Server. The LwM2M Client presents resources for the LwM2M Server to manipulate.
- LwM2M Server
The LwM2M Server is the entity managing the LwM2M Devices. It can Read, Write, Execute, Create, or Delete the Devices resources.
- LwM2M Bootstrap Server
The LwM2M Bootstrap Server is a special LwM2M Server. It is the only Server allowed to provision or delete Server Accounts on LwM2M Devices. It can Read (LwM2M 1.1), Write, Create, and Delete the Devices resources.
- LwM2M Resource
A LwM2M Resource is a data item presented by the LwM2M Device. A resource has a data type, a list of allowed operations, and a unique URI. Operations on resources are Read, Write, and Execute.
- LwM2M Objects
The LwM2M Objects are a group of Device resources essential for some Device features such as firmware updates, connectivity monitoring, physical sensor, etc. Standardized LwM2M Objects contain mandatory resources to support and optional resources for implementation.
A LwM2M Device can have several instances of the same LwM2M Object.
All the Device resources are part of a LwM2M Object.
- LwM2M Object Instance
Some LwM2M Objects are defined as multi-instance objects, meaning that a LwM2M Device can have several instances of the same LwM2M Object. Instances are identified by numerical instance IDs.
When a LwM2M Object is defined as a single-instance, the instance ID is always 0.
- LwM2M URI
Resources and Objects have well-known IDs. The URI to a LwM2M resource is in the form:
Object_ID ["/" Object_Instance_ID ["/" Resource_ID ["/" Resource_Instance_ID]]]
A URI can address an object, an object instance, a resource, or a resource instance (i.e., an element when the resource is an array).
- Server Account
A Server Account is a data set enabling a LwM2M Device to connect to a LwM2M Server. It includes the Server URI and the Security Keys to use.
Bootstrapping is the process by which the Device retrieves the Server Accounts. The information can come from factory settings, a SmartCard, or a LwM2M Bootstrap Server.
A LwM2M Server can only manage Devices registered with it. When registering with the Bootstrap Server, the Device communicates only its unique ID.
The LwM2M Server can subscribe to one or several readable Device resources. When the value of the resource changes, the Device sends a Notification message to the Server containing the new value of the resource.
The Lifetime is the validity period of a LwM2M Device registration to the LwM2M Server. When this lifetime expires, the Server should no longer try to manage the Device.
- Queue Mode
Devices may go in stand-by mode and thus not be reachable by the LwM2M Servers at any time. To cope with this, the Device requests the Server to operate in Queue Mode. In this mode, the Device will initiate the communication with the Server (when sending a Notification or a Registration Update message). In the meantime, the Server is expected to queue its requests (hence the name).
- SMS Trigger
An SMS Trigger is a special SMS sent to the Device. Upon reception of this SMS, the Device will either register to the Server or send a Registration Update message.Now, let's play with the code.
As said, creating a LwM2M device with IOWA is very simple...you need just 6 API calls for a working device, no less, no more!
int main(int argc,
iowaH = iowa_init(NULL);
iowa_client_configure(iowaH, "IOWA_Sample_Client", NULL, NULL);
iowa_client_add_server(iowaH, 1234, "coap://iowa-server.ioterop.com:5683", 0, 0, IOWA_SEC_NONE);
* "Main loop"
while (result == IOWA_COAP_NO_ERROR)
result = iowa_step(iowaH, 5);
Want to try this on your PC? Let's go :
Under Linux (e.g.: Ubuntu 20.04), please be sure to have the following packages:
sudo apt install build-essentials
sudo apt install cmake
cmake, as it is used to make porting the stack under various OSs easier.
Now, get the IOWA code from the IOWA repository:
git clone --recurse-submodules https://github.com/IOTEROP/IOWA.git
(don't forget the --recuse-submodules option)
Now, enter IOWA (the repository), create and enter in a build subdirectory:
We use CMake to configure our make. The usual command line is:
cmake -DCMAKE_BUILD_TYPE=Debug ..
but if you want to specify your device name (e.g.: MyHacksterDev), you can use:
cmake -DCMAKE_BUILD_TYPE=Debug -DIOWA_DEV_NAME="MyHacksterDev" ..
Now, we are ready to build all the samples provided on the IOWA repository (under samples):
make -j$(nproc) could be used to compile faster (with all the CPU cores/threads available)
All the samples are now ready to be launched. Let's have a look at the Baseline Sample (aka the Patient Zero)
The sample is designed to :
- configure a simple client (
- register this client on the IOWA server (
- run this client for 120seconds (
- unregister gracefully and stop(
In the build directory, change to samples/01-baseline_client and run the sample code:
And you should see this kind of screen:
...let me introduce CONNECTicut !!!
CONNECTicut is IoTerop's test server, fully compliant with LwM2M specifications. On the server, you can interact with your device (event thought, on this sample, actions are limited)
So, point your browser to https://iowa-server.ioterop.com/ and see your device running:
Device management is something really needed in the IoT industry. IOWA solution is a piece of code that easily be ported to various hardware and OSes. Add security, OTA, and other features without reinventing the wheel!