LwM2M
Example on GitHub (opens in a new tab)
Model
Problem: Suppose you have a device that transmits battery level data via the LwM2M protocol. According to the documentation in the package, the battery level information is on the path /3/0/9:
- 3 - object number (Device);
- 0 - object instance number;
- 9 - resource number (Battery Level)
To connect the device to the platform, create a LwM2M model for it.
The template model already has the required parameter. By searching through the model you can see which parameters are already present, and which ones you need to add. on your own.
LwM2M Argument Formation in detail
Also, the template model pre-defines a useful Observe command for this resource. Setting a constant observe will allow us to learn about changes in the in the battery charge as soon as it happens, otherwise we would have to send the Read command all the time. to send a Read command all the time.
LwM2M Action Formation in detail
View a preview of the object with the model you created by clicking the Show preview.
If you wish, select an icon to display the object on the map, or upload your own image.
Model to import (opens in a new tab)
Object
Create an object for your device. Select the model you just created. Then enter the identifier that is used as the UniqueEndpointName of the device. Specify the name of the object.
Click the Save button.
Connection
To connect the device to the platform, specify
-
host dev.rightech.io
-
port 5683
Tip: In the absence of a real device, use the Eclipse Wakaama client to test LwM2M.
Its launch for this example looks as follows:
> ./lwm2mclient -4 -h dev.rightech.io -n test_device -c
Make sure the data from the device is sent and displayed in the interface.
Send the OBSERVE Battery Level command.
Now the battery level will change in the object interface when it is actually change on the device.
Tip: You can hide parameters that have not yet received data by turning off Inactive Parameters