Docs
LwM2M
Lightweight Machine-to-Machine (LwM2M) is a protocol designed to simplify messaging and device management for resource-constrained devices. The Blockbax Platform provides a native integration where it acts as LwM2M server for various operations from the LwM2M protocol using a pre-shared key (PSK) for encryption and authentication. To connect your LwM2M device the following configuration can be used:
| Property | Value |
|---|---|
| LwM2M server URL | coaps://coap.blockbax.com |
| Port number | 5684 (default CoAP port) |
| User identity | The public part of your pre-shared key and can be suffixed if you want to reuse a key for multiple connections. Only one connection is allowed per identity, when a connection already exists for an identity when a new connection is attempted, the existing client is disconnected. |
| Pre-shared key | The secret part of your pre-shared key |
Using this protocol we support several operations in which your device can interact with the platform or vice versa.
| Operation | Description |
|---|---|
| READ | A read command can be initiated by the LwM2M server, which will read one or more objects from the device, e.g. to read its location. |
| WRITE | A write command can be initiated by the LwM2M server, which allows you to write a value to a specific resource, e.g. turning lights on or off. |
| EXECUTE | An execute command can be initiated by the LwM2M server, which allows you do execute a specific action on the device, e.g. to reboot the device. |
| SEND | A command initiated by the device itself, it can be used to send data about itself to the LwM2M server. |
All commands that need to be initiated by the LwM2M server, can be initiated using an action. To receive commands successfully the device needs to register with the endpoint equal to the subject external id, e.g. urn:imei:35045779321354. Currently, the LwM2M server only supports the media type application/senml+cbor, most devices will support this. If yours doesn’t feel free to contact us.
The LwM2M server also supports queue mode. If commands get send to your device while it is in queue mode, the commands will get stored on the server. When the device ‘wakes up’, it will receive all the commands (in order of when they were received).
The measurements that gets received by the server (either by a SEND or a READ command), will get mapped to specific subjects in the following way:
- The subject external ID will be the endpoint that the client connects to
- The path will get mapped to a specific metric
For example, when a device connects to the at path /rd/urn:imei:35045779074654654, and sends the following data from the LwM2M Device object with a SEND command (decoded from CBOR):
| |
Then these measurements will be ingested as if send as depicted below in our default JSON format (see HTTP API docs):
| |