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 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.
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
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)
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
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".
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 (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.
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.
To read a resource, take a look at this API guide:
Read LWM2M resource
To write a resource, just take a look a this API guide:
Write LWM2M resource
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
Updated 5 months ago