LwM2M API
ThingsBoard Edge supports the OMA LwM2M 1.0 and 1.1 specifications. Edge acts as the LwM2M server — devices register with Edge over the local network, and Edge relays telemetry and alarms to the ThingsBoard server over gRPC.
Default ports:
| Role | Plain | Secured |
|---|---|---|
| LwM2M server | 5685 UDP (NoSec) | 5686 UDP (DTLS) |
| LwM2M bootstrap server | 5687 UDP (NoSec) | 5688 UDP (DTLS) |
Device profile
Section titled “Device profile”LwM2M devices require a device profile configured with:
- Transport type: LwM2M
- LwM2M server URI: pointing to the Edge node (e.g.,
coap://192.168.1.10:5685) - Security mode: NoSec, PSK, RPK, or X.509
To configure a LwM2M device profile: go to Profiles → Device profiles → Add device profile, select LwM2M as the transport type.
Credentials
Section titled “Credentials”LwM2M supports four security modes. Configure the matching credentials on both the device and the device profile in Edge:
| Mode | Description |
|---|---|
| NoSec | No security — for development and trusted networks only |
| PSK | Pre-shared key — identity and key defined per device |
| RPK | Raw public key — asymmetric, no certificate authority required |
| X.509 | Certificate-based — requires a CA chain |
To set credentials: go to Entities → Devices, open the device, click Manage credentials, select the LwM2M security mode.
Object and resource mapping
Section titled “Object and resource mapping”LwM2M resources are mapped to ThingsBoard attributes and telemetry in the device profile. Each object/resource ID maps to a ThingsBoard key.
For example, Object 3306 (Presence), Resource 5500 maps to a boolean telemetry key digital_input_state.
Edge stores and processes these values locally and syncs them to the server when the gRPC connection is available.
OTA updates
Section titled “OTA updates”Edge supports OTA firmware and software updates for LwM2M devices using:
- Object 5 (
/5) — Firmware Update - Object 9 (
/9) — Software Management
Assign an OTA package to the device via Entities → Devices → OTA updates on the Edge node. Edge pushes the firmware to the device using the LwM2M PUSH or PULL delivery method defined in the device profile.
RPC commands
Section titled “RPC commands”Send commands to LwM2M devices via the ThingsBoard RPC API. Supported operations:
| RPC method | LwM2M operation |
|---|---|
Read | Read object or resource value |
Write | Write a resource value |
Execute | Execute a resource (e.g., reboot) |
Observe | Start observing a resource |
Cancel Observe | Stop observing a resource |
Discover | List available resources on the device |