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

Negative values handling for Write Attribute #1451

Closed
PFnord opened this issue May 31, 2023 · 10 comments · Fixed by #1535
Closed

Negative values handling for Write Attribute #1451

PFnord opened this issue May 31, 2023 · 10 comments · Fixed by #1535
Labels
question Any question about leshan

Comments

@PFnord
Copy link

PFnord commented May 31, 2023

Question

Hello everyone,

I am trying to have a HTTP PUT method that will handle negative values for Attributes. Does leshan not handle negative values for them?
I have checked the code for DoubleAttributeModel and LongAttributeModel here but it seems to be checking for a DIGIT as the first char:

int start = parser.getPosition();
parser.consumeDIGIT();

This seems to throw an exception as the "-" sign (or % in the case of %2D) is not handled. So I have not found a way to use either curl or python requests library to write a negative attribute to my resource without altering the java code. Am I missing something?

Thanks in advance

@PFnord PFnord added the question Any question about leshan label May 31, 2023
@sbernard31
Copy link
Contributor

I'm not sure to understand.
I guess you try to send WriteAttributeRequest using REST API of leshan-server-demo ?

If yes, when I look at LWM2M-v1.1.1@core§Table: 5.1.2.-2 class Attributes, I can not see attribute which supports negative value. (see CoRE Link param column)

Did I miss something ?

@PFnord
Copy link
Author

PFnord commented Jun 1, 2023

Yes, I am mostly using REST API.

I agree, the specs seems to specify 1*DIGIT["." 1*DIGIT] for greater than for example, but being a float type I would have assumed a possibility of attributes being negative.

Here's where this can be of use. For Radio signal strength, the value is usually represented as negative, so using the greater than or less than should be, in general, a negative threshold. Maybe I'm looking at this the wrong way but it does seem to be that the specs are quite vague on this.

@sbernard31
Copy link
Contributor

For Radio signal strength, the value is usually represented as negative, so using the greater than or less than should be, in general, a negative threshold.

🤔 you maybe find a specification issue ? At least, this seems NOT fixed in LwM2m-v1.2.1 ...

Let's open an issue at OMA to try to get an answer : OpenMobileAlliance/OMA_LwM2M_for_Developers#563

Please do not hesitate to add a comment to OMA issue above with your real use case ☝️.

@PFnord
Copy link
Author

PFnord commented Jun 2, 2023

Thanks for that, I'll keep an eye on the answer!
I know other implementation of LwM2M handles the "-" sign for attributes so this could just be a small inconsistency/oversight in the documentation. 😄

@sbernard31
Copy link
Contributor

I hope we will get an answer 🤞
By the way, thx for reporting this 🙏

@sbernard31
Copy link
Contributor

We can some news from OMA :

So I think I will adapt the code and this should be available for next milestone release 2.0.0-M14.

@sbernard31
Copy link
Contributor

I created a PR about that : #1535

@sbernard31
Copy link
Contributor

This is now integrated in master and should be available in next release 2.0.0-M14.

For pmin, pmax, epmin and epmax let's wait for OMA answer : OpenMobileAlliance/OMA_LwM2M_for_Developers#563 (comment)

@PFnord
Copy link
Author

PFnord commented Nov 9, 2023

That's a very nice change, thanks, I will try and test that locally!

@sbernard31
Copy link
Contributor

Some more question about attribute type : #1583

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

Successfully merging a pull request may close this issue.

2 participants