Skip to content
Stand with Ukraine flag

OTA Updates

LwM2M supports over-the-air (OTA) firmware and software updates using standardized objects. Before proceeding, read the OTA Updates guide to understand how to upload and manage packages in ThingsBoard.

LwM2M Object 5 (Firmware Update) handles firmware delivery and installation.

Configure these resource observations in the device profile to track update progress:

ResourceKeyDescription
/3/0/3firmwareVersionCurrent firmware version
/5/0/3stateFirmware update state
/5/0/5updateResultResult of the last update attempt
/5/0/7pkgVersionTarget firmware package version

Select the strategy in Device profile → Transport configuration → Other settings:

StrategyHow it works
Push via Object 5 / Resource 0 (Package)ThingsBoard pushes the binary directly to the device via block-wise CoAP transfer
Pull via Object 5 / Resource 1 (Package URI)ThingsBoard generates a CoAP URL; the device downloads the firmware from that URL
Push via Object 19 / Resource 0 (Data)Alternative binary push using Object 19

After the package is delivered, trigger installation using the Execute RPC:

{"method": "Execute", "params": {"id": "/5/0/2"}}

LwM2M Object 9 (Software Management) handles software delivery, installation, and activation as two separate phases.

ResourceKeyDescription
/3/0/19softwareVersionCurrent software version
/9/0/0pkgNameSoftware package name
/9/0/1pkgVersionSoftware package version
/9/0/7updateStateSoftware update state
/9/0/9updateResultResult of the last software update
StepStateResultDescription
1INITIAL (0)INITIAL (0)Before any download
2DOWNLOAD_STARTED (1)DOWNLOADING (1)Download in progress
3DOWNLOADED (2)DOWNLOADING (1)Package downloaded and verified
4DELIVERED (3)SUCCESSFULLY_DOWNLOADED_VERIFIED (3)Ready to install
5INSTALLED (4)SOFTWARE_SUCCESSFULLY_INSTALLED (2)Installation complete
6INITIAL (0)INITIAL (0)Returned to initial after uninstall
StrategyHow it works
Push via Object 9 / Resource 2 (Package)Binary pushed directly to the device
Pull via Object 9 / Resource 3 (Package URI)ThingsBoard generates a CoAP URL; device downloads the software package

ThingsBoard optionally uses Object 19 to deliver OTA metadata before the actual package transfer. Enable it in Device profile → Transport configuration → Other settings → Use Object 19 for OTA file metadata.

When enabled:

  • ThingsBoard checks whether Object 19 is supported at device registration.
  • Creates an Object 19 instance (InstanceId 65534 for firmware, 65535 for software).
  • Writes a Base64-encoded JSON metadata payload to that instance.

Metadata structure:

{
"Checksum": "SHA256 hash of the file",
"Title": "OTA package name",
"Version": "Target version string",
"File Name": "Filename for device storage",
"File Size": "Size in bytes"
}

The ThingsBoard LwM2M Demo Client simulates Object 5, Object 9, and Object 19 for OTA testing.

  1. Clone and build:

    Terminal window
    git clone https://github.com/thingsboard/thingsboard.lwm2m.demo.client
    mvn clean install
  2. Run with OTA support enabled (-tota flag):

    Terminal window
    java -jar thingsboard-lwm2m-demo-client-{version}.jar -u coap://$THINGSBOARD_HOST:5685 -n MyClientNoSec -tota

The demo client logs all state transitions — use it to validate the firmware update strategy and Object 19 metadata delivery configured in the device profile.