Topics ยท Connect a device

LwM2M: connect a device

The server is a complete LwM2M server (OMA LwM2M 1.0 and 1.1). Register your LwM2M client with it, then read, write, execute and observe its objects on the LwM2M pages, and update its firmware over the air. Without encryption (NoSec) or with DTLS 1.2 and a pre-shared key (PSK).

Server URIcoap://164.30.75.205:15683 (NoSec) or coaps://164.30.75.205:15684 (PSK)
Bootstrap URIcoap://164.30.75.205:5783 (NoSec) or coaps://164.30.75.205:5784 (PSK), optional, see Bootstrap
Security modeNoSec, or PSK with a key from the Keys page whose identity is the endpoint name
Endpoint nameAny unique name, e.g. the IMEI: urn:imei:351234567890123
BindingU (UDP), or UQ / queue mode for devices that sleep
Content formatsTLV, SenML JSON, SenML CBOR, LwM2M JSON, plain text, opaque, see Working with devices

Setup

  1. For DTLS: create a key on the Keys page with the endpoint name of your device as identity (e.g. urn:imei:351234567890123) and store identity and key in the device. An endpoint that has a key must use DTLS.
  2. Set the server URI in the LwM2M Security and Server objects of your client (or its configuration), with the security mode that fits. Or let the device bootstrap: then it only needs the bootstrap URI.
  3. Start the client. After its Register message, it appears in the device list on the LwM2M page.
  4. Open the device to read, write and observe its resources.

Right after a device registers, the server reads all objects it announced, so the device page shows its values straight away. Every message of a device and every request from the LwM2M pages appears in the live traffic.

Registration and lifetime

The lifetime (resource /1/0/1, in seconds) says how long the registration stays valid. Before it runs out, the device sends a Registration Update; without one, the server removes the registration and the device shows as expired. A long lifetime saves energy and data, a short one shows sooner that a device is gone. After a device deregistered or expired, its page keeps the last known values.