lwm2m_senml: Regenerate cbor code using zcbor

Also do clang-format and apply patch.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
This commit is contained in:
Øyvind Rønningstad 2022-10-12 15:52:24 +02:00 committed by Carles Cufí
parent 7b05569d49
commit 8b295bc58c
5 changed files with 87 additions and 67 deletions

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Generated using zcbor version 0.5.1
* Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor
* Generated with a --default-max-qty of 99
*/
@ -18,7 +18,9 @@
#include "lwm2m_senml_cbor_decode.h"
static bool decode_repeated_record_bn(zcbor_state_t *state, struct record_bn *result);
static bool decode_repeated_record_bt(zcbor_state_t *state, struct record_bt *result);
static bool decode_repeated_record_n(zcbor_state_t *state, struct record_n *result);
static bool decode_repeated_record_t(zcbor_state_t *state, struct record_t *result);
static bool decode_repeated_record_union(zcbor_state_t *state, struct record_union_ *result);
static bool decode_value(zcbor_state_t *state, struct value_ *result);
static bool decode_key_value_pair(zcbor_state_t *state, struct key_value_pair *result);
@ -34,9 +36,24 @@ static bool decode_repeated_record_bn(zcbor_state_t *state, struct record_bn *re
bool tmp_result = ((((zcbor_int32_expect(state, (-2)))) &&
(zcbor_tstr_decode(state, (&(*result)._record_bn)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
return tmp_result;
}
static bool decode_repeated_record_bt(zcbor_state_t *state, struct record_bt *result)
{
zcbor_print("%s\r\n", __func__);
bool tmp_result = ((((zcbor_int32_expect(state, (-3)))) &&
(zcbor_int64_decode(state, (&(*result)._record_bt))) &&
((((*result)._record_bt >= INT64_MIN) &&
((*result)._record_bt <= INT64_MAX)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -48,9 +65,24 @@ static bool decode_repeated_record_n(zcbor_state_t *state, struct record_n *resu
bool tmp_result = ((((zcbor_uint32_expect(state, (0)))) &&
(zcbor_tstr_decode(state, (&(*result)._record_n)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
return tmp_result;
}
static bool decode_repeated_record_t(zcbor_state_t *state, struct record_t *result)
{
zcbor_print("%s\r\n", __func__);
bool tmp_result = ((((zcbor_uint32_expect(state, (6)))) &&
(zcbor_int64_decode(state, (&(*result)._record_t))) &&
((((*result)._record_t >= INT64_MIN) &&
((*result)._record_t <= INT64_MAX)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -66,24 +98,23 @@ static bool decode_repeated_record_union(zcbor_state_t *state, struct record_uni
((((*result)._union_vi >= INT64_MIN) &&
((*result)._union_vi <= INT64_MAX)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) &&
(((*result)._record_union_choice = _union_vi) || 1)) ||
(((*result)._record_union_choice = _union_vi), true)) ||
((((zcbor_uint32_expect_union(state, (2)))) &&
(zcbor_float_decode(state, (&(*result)._union_vf)))) &&
(((*result)._record_union_choice = _union_vf) || 1)) ||
(((*result)._record_union_choice = _union_vf), true)) ||
((((zcbor_uint32_expect_union(state, (3)))) &&
(zcbor_tstr_decode(state, (&(*result)._union_vs)))) &&
(((*result)._record_union_choice = _union_vs) || 1)) ||
(((*result)._record_union_choice = _union_vs), true)) ||
((((zcbor_uint32_expect_union(state, (4)))) &&
(zcbor_bool_decode(state, (&(*result)._union_vb)))) &&
(((*result)._record_union_choice = _union_vb) || 1)) ||
(((*result)._record_union_choice = _union_vb), true)) ||
((((zcbor_uint32_expect_union(state, (8)))) &&
(zcbor_bstr_decode(state, (&(*result)._union_vd)))) &&
(((*result)._record_union_choice = _union_vd) || 1))),
(((*result)._record_union_choice = _union_vd), true))),
zcbor_union_end_code(state), int_res))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -96,23 +127,22 @@ static bool decode_value(zcbor_state_t *state, struct value_ *result)
bool tmp_result =
(((zcbor_union_start_code(state) &&
(int_res = ((((zcbor_tstr_decode(state, (&(*result)._value_tstr)))) &&
(((*result)._value_choice = _value_tstr) || 1)) ||
(((*result)._value_choice = _value_tstr), true)) ||
(((zcbor_bstr_decode(state, (&(*result)._value_bstr)))) &&
(((*result)._value_choice = _value_bstr) || 1)) ||
(((*result)._value_choice = _value_bstr), true)) ||
(((zcbor_int64_decode(state, (&(*result)._value_int))) &&
((((*result)._value_int >= INT64_MIN) &&
((*result)._value_int <= INT64_MAX)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) &&
(((*result)._value_choice = _value_int) || 1)) ||
(((*result)._value_choice = _value_int), true)) ||
(((zcbor_float_decode(state, (&(*result)._value_float)))) &&
(((*result)._value_choice = _value_float) || 1)) ||
(((*result)._value_choice = _value_float), true)) ||
(((zcbor_bool_decode(state, (&(*result)._value_bool)))) &&
(((*result)._value_choice = _value_bool) || 1))),
(((*result)._value_choice = _value_bool), true))),
zcbor_union_end_code(state), int_res))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -124,9 +154,8 @@ static bool decode_key_value_pair(zcbor_state_t *state, struct key_value_pair *r
bool tmp_result = ((((zcbor_int32_decode(state, (&(*result)._key_value_pair_key)))) &&
(decode_value(state, (&(*result)._key_value_pair)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -138,9 +167,8 @@ static bool decode_repeated_record__key_value_pair(zcbor_state_t *state,
bool tmp_result = (((decode_key_value_pair(state, (&(*result)._record__key_value_pair)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -154,13 +182,19 @@ static bool decode_record(zcbor_state_t *state, struct record *result)
((zcbor_present_decode(&((*result)._record_bn_present),
(zcbor_decoder_t *)decode_repeated_record_bn, state,
(&(*result)._record_bn)) &&
zcbor_present_decode(&((*result)._record_bt_present),
(zcbor_decoder_t *)decode_repeated_record_bt, state,
(&(*result)._record_bt)) &&
zcbor_present_decode(&((*result)._record_n_present),
(zcbor_decoder_t *)decode_repeated_record_n, state,
(&(*result)._record_n)) &&
zcbor_present_decode(&((*result)._record_t_present),
(zcbor_decoder_t *)decode_repeated_record_t, state,
(&(*result)._record_t)) &&
zcbor_present_decode(&((*result)._record_union_present),
(zcbor_decoder_t *)decode_repeated_record_union, state,
(&(*result)._record_union)) &&
zcbor_multi_decode(0, ARRAY_SIZE(result->_record__key_value_pair),
zcbor_multi_decode(0, ZCBOR_ARRAY_SIZE(result->_record__key_value_pair),
&(*result)._record__key_value_pair_count,
(zcbor_decoder_t *)decode_repeated_record__key_value_pair,
state, (&(*result)._record__key_value_pair),
@ -168,9 +202,8 @@ static bool decode_record(zcbor_state_t *state, struct record *result)
(zcbor_list_map_end_force_decode(state), false)) &&
zcbor_map_end_decode(state))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -181,16 +214,15 @@ static bool decode_lwm2m_senml(zcbor_state_t *state, struct lwm2m_senml *result)
bool tmp_result = ((
(zcbor_list_start_decode(state) &&
((zcbor_multi_decode(1, ARRAY_SIZE(result->_lwm2m_senml__record),
((zcbor_multi_decode(1, ZCBOR_ARRAY_SIZE(result->_lwm2m_senml__record),
&(*result)._lwm2m_senml__record_count,
(zcbor_decoder_t *)decode_record, state,
(&(*result)._lwm2m_senml__record), sizeof(struct record))) ||
(zcbor_list_map_end_force_decode(state), false)) &&
zcbor_list_end_decode(state))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Generated using zcbor version 0.5.1
* Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor
* Generated with a --default-max-qty of 99
*/

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Generated using zcbor version 0.5.1
* Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor
* Generated with a --default-max-qty of 99
*/
@ -13,7 +13,6 @@
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include "zcbor_encode.h"
#include "lwm2m_senml_cbor_encode.h"
#include "lwm2m_senml_cbor_types.h"
@ -37,9 +36,8 @@ static bool encode_repeated_record_bn(zcbor_state_t *state, const struct record_
bool tmp_result = ((((zcbor_int32_put(state, (-2)))) &&
(zcbor_tstr_encode(state, (&(*input)._record_bn)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -54,9 +52,8 @@ static bool encode_repeated_record_bt(zcbor_state_t *state, const struct record_
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)) &&
(zcbor_int64_encode(state, (&(*input)._record_bt)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -68,9 +65,8 @@ static bool encode_repeated_record_n(zcbor_state_t *state, const struct record_n
bool tmp_result = ((((zcbor_uint32_put(state, (0)))) &&
(zcbor_tstr_encode(state, (&(*input)._record_n)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -79,15 +75,14 @@ static bool encode_repeated_record_t(zcbor_state_t *state, const struct record_t
{
zcbor_print("%s\r\n", __func__);
bool tmp_result =
((((zcbor_uint32_put(state, (6)))) &&
((((*input)._record_t >= INT64_MIN) && ((*input)._record_t <= INT64_MAX)) ||
bool tmp_result = ((((zcbor_uint32_put(state, (6)))) &&
((((*input)._record_t >= INT64_MIN) &&
((*input)._record_t <= INT64_MAX)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)) &&
(zcbor_int64_encode(state, (&(*input)._record_t)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -122,9 +117,8 @@ static bool encode_repeated_record_union(zcbor_state_t *state, const struct reco
(&(*input)._union_vd))))
: false)))))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -155,9 +149,8 @@ static bool encode_value(zcbor_state_t *state, const struct value_ *input)
(&(*input)._value_bool))))
: false)))))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -169,9 +162,8 @@ static bool encode_key_value_pair(zcbor_state_t *state, const struct key_value_p
bool tmp_result = ((((zcbor_int32_encode(state, (&(*input)._key_value_pair_key)))) &&
(encode_value(state, (&(*input)._key_value_pair)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -183,19 +175,17 @@ static bool encode_repeated_record__key_value_pair(zcbor_state_t *state,
bool tmp_result = (((encode_key_value_pair(state, (&(*input)._record__key_value_pair)))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
static bool encode_record(
zcbor_state_t *state, const struct record *input)
static bool encode_record(zcbor_state_t *state, const struct record *input)
{
zcbor_print("%s\r\n", __func__);
int max_keys = ARRAY_SIZE(input->_record__key_value_pair);
int max_keys = ZCBOR_ARRAY_SIZE(input->_record__key_value_pair);
bool tmp_result = (((zcbor_map_start_encode(state, max_keys + 5) &&
((zcbor_present_encode(&((*input)._record_bn_present),
@ -221,9 +211,8 @@ static bool encode_record(
(zcbor_list_map_end_force_encode(state), false)) &&
zcbor_map_end_encode(state, max_keys + 5))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}
@ -231,7 +220,7 @@ static bool encode_record(
static bool encode_lwm2m_senml(zcbor_state_t *state, const struct lwm2m_senml *input)
{
zcbor_print("%s\r\n", __func__);
size_t max_records = ARRAY_SIZE(input->_lwm2m_senml__record);
size_t max_records = ZCBOR_ARRAY_SIZE(input->_lwm2m_senml__record);
bool tmp_result = (((zcbor_list_start_encode(state, max_records) &&
((zcbor_multi_encode_minmax(
@ -241,9 +230,8 @@ static bool encode_lwm2m_senml(zcbor_state_t *state, const struct lwm2m_senml *i
(zcbor_list_map_end_force_encode(state), false)) &&
zcbor_list_end_encode(state, max_records))));
if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}
return tmp_result;
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Generated using zcbor version 0.5.1
* Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor
* Generated with a --default-max-qty of 99
*/

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Generated using zcbor version 0.5.1
* Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor
* Generated with a --default-max-qty of 99
*/