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);
float temperature = temp_read();
#ifdef ONE_BAORD
double temperature = 0;
get_temp(&temperature);
#elif defined (BOARD_X) || defined(BOARD_Y)
float temperature = 0.0;
get_temp(&temperature);
#endif
int16_t temperature_int = (int16_t)temperature;
LOG_INF("temp %d, uptime %d", temperature_int, uptime_sec);
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);
i see in the print of LOG_INF that the values are the same, i have no idea why temp changes with uptime rise and remain equal .. any ideas ???
and off course 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