thingsboard: LwM2M send operation with multiple timestamped values fails

Describe the bug Sending multiple timestamped values for the same resource results in only the latest one being stored (and discarding the timestamp for this single value). In general, not only for send operations, but for read/write/notify as well, SenML values with timestamps should be honored.

This is related to #10135 where a similar request was made. I assumed the integration of Leshan 2.0.0-M14 had been done with this in mind, but it looks like there are still some improvements to be made.

Your Server Environment

  • own setup
    • Deployment: monolith
    • Deployment type: dev build
    • ThingsBoard Version: on master 3d7128a1b6
    • Community Edition
    • Ubuntu 22.04

Your Device

  • custom device running Zephyr and LwM2M client

To Reproduce Steps to reproduce the behavior:

  1. Run the ThingsBoard server with a device provisioned for LwM2M communication
  2. Trigger a Send operation from the client with multiple values for the same resource as a payload [{"bn":"/3303/1/","bt":1717886813,"n":"5700","v":20.0},{"n":"5700","v":21.0,"t":10},{"n":"5700","v":22.0,"t":20},{"n":"5700","v":23.0,"t":30},{"n":"5700","v":24.0,"t":40},{"n":"5700","v":25.0,"t":50},{"n":"5700","v":26.0,"t":60},{"n":"5700","v":27.0,"t":70},{"n":"5700","v":28.0,"t":80},{"n":"5700","v":29.0,"t":90}]

Expected behavior 10 values for the resource /3303/1/5700 should be stored with timestamps 1717886813, 1717886823, …, 1717886903

Additional context

    @Override
    public void onUpdateValueWithSendRequest(Registration registration, SendRequest sendRequest) {
        for(var entry : sendRequest.getTimestampedNodes().getNodes().entrySet()) {
            // At this point the 10 timestamped values have been effectively reduced
            // to a single one by calling getNodes()
            ...
        }
    }

I’d be happy to test anything you need. Thanks for the great work, ThingsBoard has been working flawlessly for me so far!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

Hi @nickAS21, thanks for the changes. It works for my simple use case. I haven’t had the chance to perform more extensive tests, but the data is correctly timestamped now. Since most of the heavy lifting of parsing the coap packet and generating the right timestamp is done by Leshan, I think you can go ahead and merge.

Thanks for implementing this!

This was for us the main reason to upgrade to 3.7. It is very unfortunate it doesn’t work as we’d expected.

In our case the devices are battery-powered ones and they use NB-IoT/LTE-M to send their collected data. This is for us a need-to-have to be able to get a long battery life.