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:

PropertyValue
LwM2M server URLcoaps://coap.blockbax.com
Port number5684 (default CoAP port)
User identityThe 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 keyThe 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.

OperationDescription
READA 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.
WRITEA 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.
EXECUTEAn 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.
SENDA 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:

  1. The subject external ID will be the endpoint that the client connects to
  2. 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):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
[
  {
    "0": "0/3", // firmware version
    "3": "1.0.3",
    "-2": "/3/" // device object (base name)
  },
  {
    "0": "0/9", // battery level
    "2": 74
  }
]

Then these measurements will be ingested as if send as depicted below in our default JSON format (see HTTP API docs):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
{
  "series": [
    {
      "ingestionId": "urn:imei:35045779074654654$/3/0/3",
      "measurements": [
        {
          "text": "1.0.3"
        }
      ]
    },
    {
      "ingestionId": "urn:imei:35045779074654654$/3/0/9",
      "measurements": [
        {
          "number": 74
        }
      ]
    }
  ]
}