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

Write to resource with multiple values does update instead of replace #507

Closed kmdewaal closed 6 years ago

kmdewaal commented 7 years ago

Given a resource defined with multiple instances, type string.

Problem: It is NOT possible to replace the content of the resource with a new value with less instances. Example: Existing value of the resource is [“one”, “two”, “three”] Then write the new value [“aa”, “bb”] Expected result is [“aa”, “bb”] Actual result is: [“aa”, “bb”, “three”]

Relevant bits of the LWM2M specification: Paragraph 5.4.3 Write on page 35 of OMA-TS-LightweightM2M-V1_0-20170208.pdf states: LwM2M Client and LwM2M Server MUST support the following mechanisms to change multiple Resources or an array of Resource Instances: Replace: replaces the Object Instance or the Resource(s) with the new value provided in the "Write" operation. Partial Update: adds or updates Resources provided in the new value and leaves other existing Resources unchanged.

Paragraph 8.2.5, "Device Management & Service Enablement Interface", page 77, states: 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.

ciarmcom commented 7 years ago

ARM Internal Ref: IOTCLT-1859

aewp2 commented 7 years ago

Hi Klaas In the LWM2M spec: PUT does a replace POST does a partial update So is it correct to assume you are doing a PUT, via a Leshan server?

kmdewaal commented 7 years ago

Hi Amyas,

Yes, correct, we actually do a HTTP PUT from the Commissioning-Tool to the Leshan server and then the Leshan server generates a CoAP PUT to the MBED device. I can provide a Wireshark pcapng file if that is useful.

On Mon, Jul 3, 2017 at 6:54 PM, Amyas Phillips notifications@github.com wrote:

Hi Klaas In the LWM2M spec: PUT does a replace POST does a partial update So is it correct to assume you are doing a PUT, via a Leshan server?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ARMmbed/mbed-client/issues/507#issuecomment-312693419, or mute the thread https://github.com/notifications/unsubscribe-auth/AKAUmOXsYS6dzNTclc-wxzxAbb_8EKhvks5sKRzIgaJpZM4OMYMm .

yogpan01 commented 7 years ago

HI @kmdewaal, Is the issue that PUT should remove the existing resource ? Sorry I didn't quite understand the issue. You mentioned that you write with 2 resource instance value (when there were 3 resource instances) and those are updated but then the third value is untouched because its not updated. Do you mean the third resource instances be deleted in this case ? The spec is a bit ambiguous for me to follow here, can you please update how do you interpret this.

kmdewaal commented 7 years ago

Hi @yogpan01 , I do agree that the spec about multi-instance resources is not very clear. My interpretation is that the new resource value in the PUT should completely replace the old/existing resource value. In my example the old/existing resource value is an array of three strings. When the new resource value in the PUT is an array of two strings, as in my example, the final value of the resource should be the array of two strings, so exactly the same as the new resource value in the PUT.

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.