Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How Timstamp should be handled in LWM2M/Leshan ? #1623

Open
sbernard31 opened this issue Jun 12, 2024 · 0 comments
Open

How Timstamp should be handled in LWM2M/Leshan ? #1623

sbernard31 opened this issue Jun 12, 2024 · 0 comments
Labels
discussion Discussion about anything spec ambiguity Issue because of specification/RFC ambiguity

Comments

@sbernard31
Copy link
Contributor

sbernard31 commented Jun 12, 2024

I try to summarize all information about timestamped in LWM2M and Leshan.

2 different Timestamp use cases :

Reading LWM2M specification, I see 2 kind of very different timestamp usage :

  1. to express the timestamp of when a sensor measurement was performed
  2. to express historical data in notifications when "Notification Storing When Disabled or Offline"

Sensor Measurement Timestamp

Sensor measurement use case is pretty clear. Often a LWM2M resource value of a LWM2M Object is measurement of a physical sensor. This value is measured at some time and this time is what we called sensor measurement timestamp

So if later you read a LWM2M node containing this kind of resource you could now exactly the date/time when this sensor value was measured.

Historical Data Timestamp

This use case is less obvious, LWM2M client could use "Notification Storing When Disabled or Offline".
So when client is offline and should have sent a Notification (from Observe request), it will store the whole notification value and timestamped it.

E.g. :

  1. Server observes object location (/6/0)
  2. Client send the whole instance 0 of object /6 which means with all resources without timestamp.
  3. Client goes offline
  4. An event should generate a notification, but client is offline so it store object the whole instance value and timestamp it (the whole instance must be present with all resources and all resources timestamped at same time, the time where the notification should have been sent).
  5. More event when offline, means more timestamped instance.
    6.Client goes online and send an update request then the notification with historical values. (each instance with all value and each with a different timestamp)

How they looks like in LWM2M ?

In LWM2M v1.0.x

In LWM2M v1.0.x this is pretty clear.

Sensor Measurement Timestamp is done by adding a timestamp resource to an object for sensor resource.
E.g. For object Location(id:6), a resource "Timestamp" (id:5) was added which means "The timestamp of when the location measurement was performed."

Lot of objects have this kind of timestamp resource (3302, 3318,3422,3312,3430,3450,3428,3332,3416,3320,3435 and so much more)

Historical Data Timestamp only 1 format allow to express historical data : JSON (which is based on a draft of SenML :draft-jennings-senml-10) and the LwM2M-v1.0.2 is clear at 6.4.4 JSON* :

The time fields MUST only be used when sending notifications.
...
Historical version of notifications are typically generated when “Notification Storing When Disabled or Offline” resource of
LwM2M Server Object is set to true (see Appendix D.2) and when the Device comes on line after having been disabled for a
period of time

What about Leshan API/behavior ? It just follow that specification and it just works as expected. Sensor measurement can be read in a LwM2mSingleResource. Historical Data can be get via a List<TimestampedLwM2mNode> in notification only and if both concept are used at same time there is no problem.

In LWM2M v1.1.x

In LWM2M v1.1.x this is less clear because new SenML content format chapter bring confusion ...

LWM2M-v1.1.1@core§7.4.5. SenML JSON says :

The SenML JSON format also includes optional time fields, which allows for multiple versions of representations to be sent in the same payload or indicating the time when the representation was created (e.g., measurement made).

Some begin to think that "time fields" could be used for Sensor measurement timestamp in LWM2M. But this is inconsistent with LWM2M-v1.0.x ideas. I would rather bet this is a mistake in this chapter which try to explain SenML RFC. Especially when you know that SenML format is just an update of previous JSON format to upgrade from draft-jennings-senml-10 to released rfc8428. From my point of view this is regrettable copy/past from RFC8428 - SenML : "... the time the measurement was made ..."
By the way later it is said about "time fields" : "Required only for historical representations." (same sentence in LWM2M v1.0.2 in JSON chapter.)

Some argue that timestamp exists in SenML, LWM2M uses SenML so you can use timestamp in LWM2M.
This argument sounds not so good because :

  1. LWM2M have concepts. LWM2M is based on several existing RFC. LWM2M concepts should be translated in RFC concepts. Be based on a RFC does not means you will reuse all feature of that RFC. There is lot of example in LWM2M specification which illustrate that.
  2. Even if it was a good argument. OK LWM2M uses SenML so you can use timestamp in SenML but no just anyway. For sure for Historical Data Timestamp but FMPOV not for Sensor Measurement Timestamp for reason explained above.

Is there a problem to use "time fields" for "Sensor measurement timestamp"

I see at least 2.

  1. How does it works when you are using Sensor measurement timestamp and Historical Data Timestamp at same time ?
  2. Specification doesn't specify how to understand/use "time fields" and so this could lead to interoperability issue...

I seriously think the clear separation of LWM2M v1.0.x was good enough :

  • You need Historical Data Timestamp, use "time fields" !
  • You need Sensor measurement timestamp, create a dedicated resource in your model !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion about anything spec ambiguity Issue because of specification/RFC ambiguity
Projects
None yet
Development

No branches or pull requests

1 participant