boogie / mcumgr-web

MCU Manager for browsers
https://boogie.github.io/mcumgr-web
MIT License
31 stars 13 forks source link

Add data.rc undefined to response condition check #3

Closed machadosword closed 8 months ago

machadosword commented 8 months ago

With the addition of the new SMP v2 protocol the legacy SMP(v1) also had it's response data changed. Previously, the response data would allways include the rc field, see https://docs.zephyrproject.org/3.4.0/services/device_mgmt/smp_protocol.html e.g.:

{rc: 0 , off: 73}
{rc: 0 , off: 192}
{rc: 0 , off: 311}

Now, with latest releases, the rc field only appears if non-zero (error condition), see https://docs.zephyrproject.org/3.5.0/services/device_mgmt/smp_protocol.html

“rc” | mcumgr_err_t only appears if non-zero (error condition) when using SMP version 1 or for SMP errors when using SMP version 2.

e.g.:

{off: 73}
{off: 192}
{off: 311}

There's a config added in Zephyr 3.3 (https://docs.zephyrproject.org/latest/releases/release-notes-3.3.html), that allows to disable this behaviour but is defaulted to "n", it can be enabled instead of using this fix:

MCUmgr responses where rc (result code) is 0 (no error) will no longer be present in responses and in cases where there is only an rc result, the resultant response will now be an empty CBOR map. The old behaviour can be restored by enabling CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR.

boogie commented 8 months ago

I had no chance to test your change, but looks straightforward.