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 WRITE with /objectId/instanceId is implemented according to the spec 1.0.2? #1114

Closed
Frendzel opened this issue Oct 18, 2021 · 7 comments
Labels
question Any question about leshan

Comments

@Frendzel
Copy link

Hi guys,
according to the spec: OMA-TS-LightweightM2M-V1_0_2-20180209-A

for write operation we may have 2 coap methods:

  • PUT
    /{Object ID}/{Object Instance ID}/{Resource ID}
    and
  • POST
    /{Object ID}/{Object Instance ID}

but terminology is a bit unclear as in the spec in chapter 8.2.5 it is also defined that:

"An Object Instance or Resource is written to by sending either a CoAP PUT request to the corresponding path. The request includes the value to be written in the corresponding Plain Text, Opaque,TLV or JSON format according to the Content-Format option which MUST be specified [CoAP]. In addition, an Object Instance can be written by sending a CoAP POST request; in that case the specified Content-Format MUST be the LwM2M TLV or LwM2M JSON. A CoAP PUT is used for the Replace and CoAP POST is used for Partial Update mechanism of the “Write” operation as described in 5.4.3. "

So our understanding and our customers is like this that both below cases can go with PUT or POST depending on wanted behaviour

  • WRITE /objectId/instanceId - as a COAP PUT (replace case)
  • WRITE /objectId/instanceId - as a COAP POST (update case)
    and it all depends on the fact if this is a replacement or an update.

So my question is how it was implemented in Leshan under the hood?

@Frendzel Frendzel changed the title How WRITE with /objectId/instanceId is implemented according to the spec? How WRITE with /objectId/instanceId is implemented according to the spec 1.0.2? Oct 18, 2021
@sbernard31
Copy link
Contributor

So our understanding and our customers is like this that both below cases can go with PUT or POST depending on wanted behaviour

  • WRITE /objectId/instanceId - as a COAP PUT (replace case)
  • WRITE /objectId/instanceId - as a COAP POST (update case)
    and it all depends on the fact if this is a replacement or an update.

So my question is how it was implemented in Leshan under the hood?

I understand like you and I hope this is what it is implemented in Leshan.
But I'm not sure to get the question 😬.
Maybe you want I point you to the code which implements this ?
Or this is a question about the API to do that ?

@sbernard31 sbernard31 added the question Any question about leshan label Oct 18, 2021
@Frendzel
Copy link
Author

Yes, if you can point me there, please! The question is how this is implemented and if Leshan is using only POST for WRITE methods with objectId and instanceId or instead it can be switched between POST and PUT depending on type (replace or update)?

@sbernard31
Copy link
Contributor

The API allow to choose the Mode when you create a WriteRequest.

E.g.: https://github.com/eclipse/leshan/blob/0232b4b79bcc71d7efe78a6bb2d79923b9798018/leshan-core/src/main/java/org/eclipse/leshan/core/request/WriteRequest.java#L63L77

The code at server side is pretty simple :
https://github.com/eclipse/leshan/blob/master/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/request/CoapRequestBuilder.java#L110L118

I guess if you ask this, you probably face an issue about this ? or ?
If yes, do not hesitate to share as I could maybe better understand it.

@Frendzel
Copy link
Author

Yes, thank you so much! The issue which we had was like this that we were wondering what is a behavior of Leshan library in such a scenario as we were pointed to a table in the spec where in this specific scenario we should expect always a POST method. But looks like you did it well guys, as it was designed by spec. Everything is fine for us. Thank you once again for your excellent support and such a quick responses!

@sbernard31
Copy link
Contributor

My pleasure.

If this is not already done and if you think it make sense, maybe you could consider to add your company and/or customer as Leshan Adopters ? #830

@sbernard31
Copy link
Contributor

I guess I can close the issue ?

@sbernard31
Copy link
Contributor

I close this one but feel free to reopen if needed 😉

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

No branches or pull requests

2 participants