Integrate LWM2M Devices

In this chapter it is described how devices can be integrated via the standard protocol LWM2M with IoT Creators

LWM2M is a much more powerful protocol in comparison to the simple UDP. This comes with additional steps required to correctly register your device into iotcreators.

Let's see the important steps, similar for all LWM2M devices.

Provisioning the device

Provisioning the device is similar to what happens with the other protocols, except when using bootstrap.

Unfortunately, the portal does not support lwm2m device creation yet, so everything will need to be done through the api.

Register you application endpoint

Before being able to use the following API calls, you will need to register your API endpoint, otherwise most of the API functionalities will not be available.

📘

Register an application endpoint

Register application URL

Registering a device (no bootstrap)

The concept here is similar to the other protocols. A device needs to be registered into the portal in order to be trusted by the platform. Since lwm2m supports encryption, here you will find how to register a device with PSK encryption:

📘

Register a device with or without PSK encryption (no bootstrap)

Add LWM2M device

Registering a device (with bootstrap)

Coming soon!

Adding minimum subscriptions

There is a very recommended minimum set of subscriptions that you should enable on the device, in order to receive updates and registrations from it.

Suggestion is to create such subcriptions, see here:

📘

Create update, registration and deregistration subscription

Create update, registration, deregistration subscription

Working modes

Usually, LWM2M devices, to save batteries, only wake up at pre-defined times. Every time a device connects, it will send an update event to your application endpoint.

The device will signal its rx mode (technically called "binding mode" during the first registration, that will generally be either "U" or "UQ".

U mode

In short, binding mode U (unqueued) means that the device will only be listening to one-shot reads/writes for a defined time after every update, by standard 120 seconds.

UQ mode

UQ mode (queued) means that every read/write send when the device is sleeping will be queued and the queue will be flushed to the device as soon as it sends it periodic update.

Thus, depending on the working mode of the device, your application endpoint should take care of performing resource operations at the right time.

Reading/writing/observing resources

Despite what happens with the other portocols, where the communication is initiated by the device (at predefined times usually), the data send in LWM2M is triggered by the server.

Thus, your application will need to trigger the desired resource operation at the appropriate time.

Reading

To read a resource, take a look at this API guide:

📘

Read LWM2M resource

Read LWM2M resource

Writing

To write a resource, just take a look a this API guide:

📘

Write LWM2M resource

Write LWM2M resource

Observing

If you observe a resource, its value will be automatically sent by the device at every update, thus avoiding the need of explicitely request a read.

To observe a resouce, you have to create a subscription for that resource.

📘

Create a subscription

Use this API Create subscription and for resourcePath just input the desired resource.

For example, to listen to resource 3/0/3, just use the body

{
 "resourcePath": "3/0/3" 
}