hello Nordic
i am working with ncs v2.5.0 with nrf52840 and nrf52832
i use cbor for some command i build over smp (user groups >64)..
i have this code part
{ zcbor_state_t *zse = ctxt->writer->zs; bool ok = true; uint32_t uptime_sec = (uint32_t)(k_uptime_get() / 1000); double temperature = temp_read(); int16_t temperature_int = (int16_t)temperature; ok = augu_status_encode_battery_mv(zse) && zcbor_tstr_put_lit(zse, FIELD_UPTIME_SEC) && zcbor_uint32_encode(zse, &uptime_sec) && zcbor_tstr_put_lit(zse, FIELD_TEMPERATURE) && zcbor_int_encode(zse, &temperature_int, sizeof(int16_t)) && ... return (ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE);
and when i decode the cbor i get, using https://cbor.me/, i get that the temperature value is the same as the uptime value .. i am not sure why (i know casting doublt to int16 is not best practice but worst case i would expect to get some other false value not the exact same ) any ideas ?
and also how to fix it ... does using "put" instead of "encode" can help, this put and encode is not very clear or maybe use zcor_unint32_encode will solve it .. i can try but i want to understand what is happening
hope to read you soon
best regards
Ziv