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

SenML-CBOR Time reprentation description error ? #537

Open
sbernard31 opened this issue Dec 21, 2021 · 8 comments
Open

SenML-CBOR Time reprentation description error ? #537

sbernard31 opened this issue Dec 21, 2021 · 8 comments
Assignees

Comments

@sbernard31
Copy link

sbernard31 commented Dec 21, 2021

When reading the LWM2M specification about SenML-CBOR representation of TIME datatype, I see :

Data Type Text Format TLV Format JSON SenML Format CBOR SenML Format
Time Represented as an ASCII integer. For example, 1476186613 seconds since Jan 01 1970, which represents Tuesday, 11-Oct-16 11:50:13 UTC, are represented as the ASCII string "1476186613", which has 10 characters/bytes. Same representation as Integer. Represented as a number. 👉 Represented as date/time strings, as defined in Section 2.4.1 of [RFC7049].

(from : LWM2M-v1.1.1@core§C.2-Data Type Mapping)

Data Type Text Format TLV Format SenML JSON Format CBOR, LwM2M CBOR, and SenML CBOR Formats
Time Represented as an ASCII integer. For example, 1476186613 seconds since Jan 01 1970, which represents Tuesday, 11-Oct-16 11:50:13 UTC, are represented as the ASCII string "1476186613", which has 10 characters/bytes. Same representation as Integer. Represented as a number. 👉 Represented as an unsigned integer or a date/time string, as defined in Section 2.4.1 of [RFC7049].

(from : LWM2M-v1.2@core§C.2-Data Type Mapping)

I saw some contradiction with CBOR and SenML RFC but maybe I just missed the point.


About CBOR RFC7049, the specification says about Date and Time:

Tag value 1 is for numerical representation of seconds relative to
1970-01-01T00:00Z in UTC time. (For the non-negative values that the
Portable Operating System Interface (POSIX) defines, the number of
seconds is counted in the same way as for POSIX "seconds since the
epoch" [TIME_T].) The tagged item can be a positive or negative
integer
(major types 0 and 1), or a floating-point number (major type
7 with additional information 25, 26, or 27). Note that the number
can be negative (time before 1970-01-01T00:00Z) and, if a floating-
point number, indicate fractional seconds.

So it allows Floating point number and negative one, so is there any reason to limit it to unsigned integer ?


About SenML-CBOR RFC8428, there is no value of type date/time, see

And LWM2M specification says that TIME value should be encoded using v which should be a number, see LWM2M-v1.2@core§SenML-JSON-format-and-description

That sounds contradictory with "Represented as date/time strings, as defined in Section 2.4.1 of [RFC7049]." from C.2-Data Type Mapping of LWM2M specification.

@mkgillmore
Copy link

@sbernard31 Is this an issue that has been clarified in the IETF?

@sbernard31
Copy link
Author

@mkgillmore I'm not sure to see which IETF clarification is needed.

At least from my point of view, the 2 RFC (RFC7049 and RFC8428) are clear.

I think "issue" comes with LWM2M specification.

For CBOR,

LWM2M add some limitation for date compare to RFC. (maybe it's OK but I just ask why ? to be sure this is not an unintentional issue?)

RFCt allows Floating point number and negative one, so is there any reason to limit it to unsigned integer in LWM2M ?

For SenML-CBOR

LWM2M seems to add some contradiction with the RFC.
RFC says that v value should be encoded as number.
LWM2M says v should be encoded_"as a JSON float if the Resource data type is Integer, Float, or Time"_ but also says Time should be "Represented as date/time strings, as defined in Section 2.4.1 of [RFC7049]".

I think for SenML-CBOR, this should rather be "integers, floating-point numbers, or decimal fractions (CBOR Tag 4) as defined in in Section 6 of RFC8428"

?

@eliasweingaertner
Copy link

eliasweingaertner commented Sep 27, 2024

Well spotted @sbernard31

I also think that the spec is too vague here. The description for TEXT actually makes it clear that LWM2M 1.2 doesn't allow TIME values before Jan 01 1970. The unsigned integer type for the CBOR formats is inline with this restriction, while TLV and SenML JSON allow negative numbers and hence bypass the restriction.

At DMSO, we actually need to decide if we want to enforce TIME always to be newer than Jan 01 1970. In this case, we'd need to put a restriction into the spec for TLV and SENML_JSON. In the contrary case of allowing prior dates, we'd need to turn SENML_JSON to Integer (less range...) and need to discuss what to do with TEXT (for example allow a - prefix)

@sbernard31
Copy link
Author

sbernard31 commented Sep 27, 2024

@eliasweingaertner, you raise the point about consistency between all format regarding "allowing TIME values before Jan 01 1970", this is a good point that I missed.

And that point ☝️ should be addressed to correctly answer to my CBOR question, but my question was more why LWM2M limit to string where RFC support String and different kind of number.

For SenML question, this is not too much related. My point was more that "LWM2M say to encode time with string" where "RFC say to use number". (so here LWM2M goes againts RFC)

To be crystal clear, I think the most important point about SenML is that :
"Represented as an unsigned integer or a date/time string, as defined in Section 2.4.1 of [RFC7049]."
should be replaced by :
"Represented as integers, floating-point numbers, or decimal fractions (CBOR Tag 4) as defined in in Section 6 of RFC8428"

@mkgillmore mkgillmore added the v1.3 label Oct 1, 2024
@mkgillmore
Copy link

Group agrees to remove "unsigned" to the description

@sbernard31
Copy link
Author

@mkgillmore, thanks for letting me know that, I really appreciate it. 🙏

I guess your are talking about SenML description, right ?

IF I'm right AND as I understand the specification THEN keeping "a date/time string" is :

@eliasweingaertner
Copy link

In my opinion, for all CBOR formats we should for each data type simply say that they use the corresponding CBOR data type in RFC7049, as specified in the Table 3, just above paragraph 2.4.1

@sbernard31
Copy link
Author

@eliasweingaertner I agree for CBOR. For LWM2M CBOR I didn't know that format so maybe(probably?) this makes sense too.

For SenML-CBOR, I think this is not a good idea because RFC8428 should be followed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants