ARMmbed / mbed-client

DEPRECATED: C++ API for mbed-client
https://cloud.mbed.com/docs/current
Apache License 2.0
53 stars 85 forks source link

mbed client does not support LWM2M Create of object instance #510

Closed kmdewaal closed 6 years ago

kmdewaal commented 7 years ago

The mbed client does not support creation of object instances with the LWM2M Create request. Instead, an object instance can be created by sending a LWM2M Write request to a non-existent object instance. This is wrong.

The difference between a LWM2M Create and LWM2M Write is subtle; if there is an object instance in the request then it is a Write and if there is no object instance in the request then it is a Create. With the Create, the object instance that you want to have can be defined in message payload. This is described in the LWM2M specification, OMA-TS-LightweightM2M-V1_0-20170208-A.pdf, page 35, paragraph 5.4.3 Write, and page 37, paragraph 5.4.6 Create.

Background information: Test configuration is:

For a Write, you have to do a HTTP POST to an existing object instance, like: POST http:///api/clients/OpenAIS xx:xx:xx:xx:xx:xx/4006/5

For a Create, you have to do a HTTP POST to the object, like: POST http:///api/clients/OpenAIS xx:xx:xx:xx:xx:xx/4006

For both the Write and the Create the object instance content is stored in the payload. This usually includes the object instance.

The POST messages above are the HTTP messages to the Leshan LWM2M server. The LWM2M server translates the messages to CoAP POST requests. The /5 in the Write request translates to an additional CoAP option, "Uri-Path: 5". This is, at the CoAP (and mbed-client) level, the only difference between a Write and a Create.

Wireshark traces can be made available on request.

ciarmcom commented 7 years ago

ARM Internal Ref: IOTCLT-1864

anttiylitokola commented 7 years ago

Hi,

Thanks for your report. I made some testing around this but for me it looks like Create is working fine. It could be that I'm missing something here now but the POST request in /object level does create a new object instance.

Attached wireshark logs where object instance and resource is created as a part Create. create.zip

It would help if you could attach wireshark traces which shows the issue.

Thanks, Antti

kmdewaal commented 7 years ago

Hi Antti,

Your wireshark trace does show the correct behavior as far as I can see. Unfortunately my wireshark trace, attached below, shows problematic behavior. ws_20170707_1033_lwm2m_web_create_oAGroup_mbed.zip The following packets are interesting: Frame 23 HTTP POST Frame 28 CoAP POST Frame 29 CoAP ACK 4.04 Not Found Frame 34 HTTP 200 OK status "NOT_FOUND" N.B. that this uses the standard CoAP port 5683, not port 5693 as in your example. The Create request in my trace is made with the Leshan LWM2M web interface and the Leshan web server. Can this make a difference? Would it be possible for me to build your mbed client example application to verify the behavior?

Thanks, Klaas

kmdewaal commented 7 years ago

Same example but now with a "poster" application, now with the object instance specified in the POST. This does create a new object instance in the mbed client device. This is the file: ws_20170821_1649_poster_create_oAGroup_mbed_succeed.zip The following packets are interesting: Frame 5 HTTP POST to /4006/2 (n.b. with the object instance specified here) Frame 10 CoAP POST (n.b. with the object instance specified, so this is a CoAP Write) Frame 12 CoAP ACK 2.01 Created Frame 28 HTTP 200 OK status "CREATED"

kmdewaal commented 7 years ago

The client application that I used in my tests is built with the mbed-client and other ARMmbed repositories from 5 april 2017. Is it possible that the object-creation issue is fixed already since then? That could explain the correct behavior reported by Antti and the wrong behavior reported by me. Please confirm!

teetak01 commented 6 years ago

Closing the issue as inactive and due to the repository being deprecated.

Please take a look at our current offering at https://cloud.mbed.com/docs/current. The actively maintained version of this component can be found in http://github.com/armmbed/mbed-cloud-client.

Please open a new issue if this is still valid. We strongly encourage you to migrate to the latest product. New issues in this repository will most likely remain unfixed.