Skip to content

Java LwM2M IoT3 bootstrap example#478

Merged
mathieu1fb merged 8 commits intoOrange-OpenSource:masterfrom
mathieu1fb:lwm2m-bootstrap
Dec 2, 2025
Merged

Java LwM2M IoT3 bootstrap example#478
mathieu1fb merged 8 commits intoOrange-OpenSource:masterfrom
mathieu1fb:lwm2m-bootstrap

Conversation

@mathieu1fb
Copy link
Copy Markdown
Collaborator

@mathieu1fb mathieu1fb commented Dec 2, 2025

What's new

New classes have been added to handle IoT3 bootstrapping with Live Objects using LwM2M:

  • IoT3Identity and Lwm2mIoT3Identity (LwM2M instance for server interactions)
  • IoT3ServiceEndpoint and Lwm2mIoT3ServiceEndpoint (LwM2M instance for server interactions)
  • Lwm2mCallback to be notified of LwM2M events (bootstrap, registration, etc.)

The Lwm2mClient has been updated to handle the new callback and IoT3-specific object models.

A new Lwm2mExample class has been added to demonstrate the LwM2M IoT3 bootstrap sequence.

Close #276


What to do

After reviewing code changes:

  1. Clone the its-client project on your IDE.
  2. Ensure that you have Gradle to be able to build the java/iot3 modules (core, mobility and examples).
  3. Find the Lwm2mExample class in the examples module, and set appropriate values for the following objects:
    private static final Lwm2mServer EXAMPLE_LWM2M_SERVER = new Lwm2mServer(
            123456,
            5 * 60,
            "U"
    );
    private static final Lwm2mConfig EXAMPLE_LWM2M_BOOTSTRAP_CONFIG = new Lwm2mConfig.Lwm2mBootstrapConfig(
            "your_endpoint_name",
            "your_url",
            "your_psk_id",
            "your_private_key_in_hex",
            EXAMPLE_LWM2M_SERVER,
            true
    );
  1. Run the Lwm2mExample.

Expected results

  1. You're getting a LwM2M bootstrap success! in the console, followed by:
  2. The IoT3 Identity :
IoT3Identity:
ID: <an_id>
PSK identity: <a_psk_identity>
PSK secret key: <a_psk_secret_******>
  1. Several instances of IoT3 Service Endpoints:
IoT3ServiceEndpoint:
Service name: <service_name>
Payload: <optional>
URI: <service_uri>
Topic root: <optional>
Server public key: <optional>

IoT3ServiceEndpoint:
Service name: <service_name>
Payload: <optional>
URI: <service_uri>
Topic root: <optional>
Server public key: <optional>

...
  1. And finally, a LwM2M registration success!.

… classes

For IoT3Identity:
- Lwm2mIoT3Identity extending Lwm2mInstance to interact with the LwM2M server
- IoT3Identity to securely store the received object

For IoT3ServiceEndpoint:
- Lwm2mIoT3ServiceEndpoint extending Lwm2mInstance to interact with the LwM2M server
- IoT3ServiceEndpoint to securely store the received object

Signed-off-by: Mathieu LEFEBVRE <mathieu1.lefebvre@orange.com>
Leshan needs to know beforehand about our custom objects to be able to handle them.

Signed-off-by: Mathieu LEFEBVRE <mathieu1.lefebvre@orange.com>
@mathieu1fb mathieu1fb added this to the Sprint 16 milestone Dec 2, 2025
@mathieu1fb mathieu1fb requested a review from fredOG-2A1 December 2, 2025 08:57
@mathieu1fb mathieu1fb self-assigned this Dec 2, 2025
@mathieu1fb mathieu1fb added the Java label Dec 2, 2025
…ation, update and deregistration events

Signed-off-by: Mathieu LEFEBVRE <mathieu1.lefebvre@orange.com>
Signed-off-by: Mathieu LEFEBVRE <mathieu1.lefebvre@orange.com>
…int write operations during the bootstrap sequence, as these objects are read-only otherwise

Signed-off-by: Mathieu LEFEBVRE <mathieu1.lefebvre@orange.com>
Signed-off-by: Mathieu LEFEBVRE <mathieu1.lefebvre@orange.com>
Signed-off-by: Mathieu LEFEBVRE <mathieu1.lefebvre@orange.com>
… on client side for now

Ideally, they should be created automatically on the fly according to the number of endpoints defined server-side, but I haven't found how to achieve this yet...

Signed-off-by: Mathieu LEFEBVRE <mathieu1.lefebvre@orange.com>
Copy link
Copy Markdown
Member

@fredOG-2A1 fredOG-2A1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok with the last modification.

@fredOG-2A1
Copy link
Copy Markdown
Member

Running the code leads to expected results:
`
LwM2M bootstrap success!
IoT3Identity:
ID: 192...
PSK identity: zqsd....
PSK secret key: [-13, -89, -7...]

IoT3ServiceEndpoint:
Service name: message
Payload: json
URI: mqtts://cor...
Topic root: default/
Server public key: null

IoT3ServiceEndpoint:
Service name: message
Payload: json
URI: mqtt+wss://cor...
Topic root: default/
Server public key: null

IoT3ServiceEndpoint:
Service name: telemetry
Payload: otlp/json
URI: https://core...
Topic root: null
Server public key: null

IoT3ServiceEndpoint:
Service name: api
Payload: jaeger
URI: https://core...
Topic root: null
Server public key: null

LwM2M registration success!
`

Copy link
Copy Markdown
Member

@fredOG-2A1 fredOG-2A1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving :-)

@mathieu1fb mathieu1fb merged commit baca7fe into Orange-OpenSource:master Dec 2, 2025
113 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LwM2M bootstrap with LiveObject

2 participants