net: lib: regenerate cbor code using zcbor

with the updated cddl for object links.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
This commit is contained in:
Juha Heiskanen 2023-01-03 16:05:51 +02:00 committed by Carles Cufí
parent 547c3063b9
commit 637c9bbf95
5 changed files with 144 additions and 125 deletions

View file

@ -1,22 +1,20 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/* /*
* Generated using zcbor version 0.6.0 * Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor * https://github.com/NordicSemiconductor/zcbor
* Generated with a --default-max-qty of 99 * Generated with a --default-max-qty of 99
*/ */
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include "zcbor_decode.h" #include "zcbor_decode.h"
#include "lwm2m_senml_cbor_decode.h" #include "lwm2m_senml_cbor_decode.h"
#if DEFAULT_MAX_QTY != 99
#error "The type file was generated with a different default_max_qty than this file"
#endif
static bool decode_repeated_record_bn(zcbor_state_t *state, struct record_bn *result); 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_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_n(zcbor_state_t *state, struct record_n *result);
@ -36,8 +34,9 @@ static bool decode_repeated_record_bn(zcbor_state_t *state, struct record_bn *re
bool tmp_result = ((((zcbor_int32_expect(state, (-2)))) && bool tmp_result = ((((zcbor_int32_expect(state, (-2)))) &&
(zcbor_tstr_decode(state, (&(*result)._record_bn))))); (zcbor_tstr_decode(state, (&(*result)._record_bn)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -48,12 +47,13 @@ static bool decode_repeated_record_bt(zcbor_state_t *state, struct record_bt *re
bool tmp_result = ((((zcbor_int32_expect(state, (-3)))) && bool tmp_result = ((((zcbor_int32_expect(state, (-3)))) &&
(zcbor_int64_decode(state, (&(*result)._record_bt))) && (zcbor_int64_decode(state, (&(*result)._record_bt))) &&
((((*result)._record_bt >= INT64_MIN) && ((((*result)._record_bt >= -9223372036854775807LL) &&
((*result)._record_bt <= INT64_MAX)) || ((*result)._record_bt <= 9223372036854775807LL)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)))); (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -65,8 +65,9 @@ static bool decode_repeated_record_n(zcbor_state_t *state, struct record_n *resu
bool tmp_result = ((((zcbor_uint32_expect(state, (0)))) && bool tmp_result = ((((zcbor_uint32_expect(state, (0)))) &&
(zcbor_tstr_decode(state, (&(*result)._record_n))))); (zcbor_tstr_decode(state, (&(*result)._record_n)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -77,12 +78,13 @@ static bool decode_repeated_record_t(zcbor_state_t *state, struct record_t *resu
bool tmp_result = ((((zcbor_uint32_expect(state, (6)))) && bool tmp_result = ((((zcbor_uint32_expect(state, (6)))) &&
(zcbor_int64_decode(state, (&(*result)._record_t))) && (zcbor_int64_decode(state, (&(*result)._record_t))) &&
((((*result)._record_t >= INT64_MIN) && ((((*result)._record_t >= -9223372036854775807LL) &&
((*result)._record_t <= INT64_MAX)) || ((*result)._record_t <= 9223372036854775807LL)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)))); (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -90,31 +92,40 @@ static bool decode_repeated_record_t(zcbor_state_t *state, struct record_t *resu
static bool decode_repeated_record_union(zcbor_state_t *state, struct record_union_ *result) static bool decode_repeated_record_union(zcbor_state_t *state, struct record_union_ *result)
{ {
zcbor_print("%s\r\n", __func__); zcbor_print("%s\r\n", __func__);
struct zcbor_string tmp_str;
bool int_res; bool int_res;
bool tmp_result = (((zcbor_union_start_code(state) && bool tmp_result =
(int_res = (((((zcbor_uint32_expect_union(state, (2)))) && (((zcbor_union_start_code(state) &&
(zcbor_int64_decode(state, (&(*result)._union_vi))) && (int_res = (((((zcbor_uint32_expect_union(state, (2)))) &&
((((*result)._union_vi >= INT64_MIN) && (zcbor_int64_decode(state, (&(*result)._union_vi))) &&
((*result)._union_vi <= INT64_MAX)) || ((((*result)._union_vi >= -9223372036854775807LL) &&
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) && ((*result)._union_vi <= 9223372036854775807LL)) ||
(((*result)._record_union_choice = _union_vi), true)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) &&
((((zcbor_uint32_expect_union(state, (2)))) && (((*result)._record_union_choice = _union_vi), true)) ||
(zcbor_float_decode(state, (&(*result)._union_vf)))) && ((((zcbor_uint32_expect_union(state, (2)))) &&
(((*result)._record_union_choice = _union_vf), true)) || (zcbor_float_decode(state, (&(*result)._union_vf)))) &&
((((zcbor_uint32_expect_union(state, (3)))) && (((*result)._record_union_choice = _union_vf), true)) ||
(zcbor_tstr_decode(state, (&(*result)._union_vs)))) && ((((zcbor_uint32_expect_union(state, (3)))) &&
(((*result)._record_union_choice = _union_vs), true)) || (zcbor_tstr_decode(state, (&(*result)._union_vs)))) &&
((((zcbor_uint32_expect_union(state, (4)))) && (((*result)._record_union_choice = _union_vs), true)) ||
(zcbor_bool_decode(state, (&(*result)._union_vb)))) && ((((zcbor_uint32_expect_union(state, (4)))) &&
(((*result)._record_union_choice = _union_vb), true)) || (zcbor_bool_decode(state, (&(*result)._union_vb)))) &&
((((zcbor_uint32_expect_union(state, (8)))) && (((*result)._record_union_choice = _union_vb), true)) ||
(zcbor_bstr_decode(state, (&(*result)._union_vd)))) && ((((zcbor_uint32_expect_union(state, (8)))) &&
(((*result)._record_union_choice = _union_vd), true))), (zcbor_bstr_decode(state, (&(*result)._union_vd)))) &&
zcbor_union_end_code(state), int_res)))); (((*result)._record_union_choice = _union_vd), true)) ||
(zcbor_union_elem_code(state) &&
((((zcbor_tstr_expect(
state, ((tmp_str.value = (uint8_t *)"vlo",
tmp_str.len = sizeof("vlo") - 1, &tmp_str))))) &&
(zcbor_tstr_decode(state, (&(*result)._union_vlo)))) &&
(((*result)._record_union_choice = _union_vlo), true)))),
zcbor_union_end_code(state), int_res))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -131,8 +142,8 @@ static bool decode_value(zcbor_state_t *state, struct value_ *result)
(((zcbor_bstr_decode(state, (&(*result)._value_bstr)))) && (((zcbor_bstr_decode(state, (&(*result)._value_bstr)))) &&
(((*result)._value_choice = _value_bstr), true)) || (((*result)._value_choice = _value_bstr), true)) ||
(((zcbor_int64_decode(state, (&(*result)._value_int))) && (((zcbor_int64_decode(state, (&(*result)._value_int))) &&
((((*result)._value_int >= INT64_MIN) && ((((*result)._value_int >= -9223372036854775807LL) &&
((*result)._value_int <= INT64_MAX)) || ((*result)._value_int <= 9223372036854775807LL)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) && (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) &&
(((*result)._value_choice = _value_int), true)) || (((*result)._value_choice = _value_int), true)) ||
(((zcbor_float_decode(state, (&(*result)._value_float)))) && (((zcbor_float_decode(state, (&(*result)._value_float)))) &&
@ -141,8 +152,9 @@ static bool decode_value(zcbor_state_t *state, struct value_ *result)
(((*result)._value_choice = _value_bool), true))), (((*result)._value_choice = _value_bool), true))),
zcbor_union_end_code(state), int_res)))); zcbor_union_end_code(state), int_res))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -154,8 +166,9 @@ 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)))) && bool tmp_result = ((((zcbor_int32_decode(state, (&(*result)._key_value_pair_key)))) &&
(decode_value(state, (&(*result)._key_value_pair))))); (decode_value(state, (&(*result)._key_value_pair)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -167,8 +180,9 @@ 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))))); bool tmp_result = (((decode_key_value_pair(state, (&(*result)._record__key_value_pair)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -194,16 +208,16 @@ static bool decode_record(zcbor_state_t *state, struct record *result)
zcbor_present_decode(&((*result)._record_union_present), zcbor_present_decode(&((*result)._record_union_present),
(zcbor_decoder_t *)decode_repeated_record_union, state, (zcbor_decoder_t *)decode_repeated_record_union, state,
(&(*result)._record_union)) && (&(*result)._record_union)) &&
zcbor_multi_decode(0, ZCBOR_ARRAY_SIZE(result->_record__key_value_pair), zcbor_multi_decode(0, 5, &(*result)._record__key_value_pair_count,
&(*result)._record__key_value_pair_count,
(zcbor_decoder_t *)decode_repeated_record__key_value_pair, (zcbor_decoder_t *)decode_repeated_record__key_value_pair,
state, (&(*result)._record__key_value_pair), state, (&(*result)._record__key_value_pair),
sizeof(struct record__key_value_pair))) || sizeof(struct record__key_value_pair))) ||
(zcbor_list_map_end_force_decode(state), false)) && (zcbor_list_map_end_force_decode(state), false)) &&
zcbor_map_end_decode(state)))); zcbor_map_end_decode(state))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -214,15 +228,15 @@ static bool decode_lwm2m_senml(zcbor_state_t *state, struct lwm2m_senml *result)
bool tmp_result = (( bool tmp_result = ((
(zcbor_list_start_decode(state) && (zcbor_list_start_decode(state) &&
((zcbor_multi_decode(1, ZCBOR_ARRAY_SIZE(result->_lwm2m_senml__record), ((zcbor_multi_decode(1, 99, &(*result)._lwm2m_senml__record_count,
&(*result)._lwm2m_senml__record_count,
(zcbor_decoder_t *)decode_record, state, (zcbor_decoder_t *)decode_record, state,
(&(*result)._lwm2m_senml__record), sizeof(struct record))) || (&(*result)._lwm2m_senml__record), sizeof(struct record))) ||
(zcbor_list_map_end_force_decode(state), false)) && (zcbor_list_map_end_force_decode(state), false)) &&
zcbor_list_end_decode(state)))); zcbor_list_end_decode(state))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }

View file

@ -1,24 +1,23 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/* /*
* Generated using zcbor version 0.6.0 * Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor * https://github.com/NordicSemiconductor/zcbor
* Generated with a --default-max-qty of 99 * Generated with a --default-max-qty of 99
*/ */
#ifndef LWM2M_SENML_CBOR_DECODE_H__ #ifndef LWM2M_SENML_CBOR_DECODE_H__
#define LWM2M_SENML_CBOR_DECODE_H__ #define LWM2M_SENML_CBOR_DECODE_H__
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include "zcbor_decode.h" #include "zcbor_decode.h"
#include "lwm2m_senml_cbor_types.h" #include "lwm2m_senml_cbor_types.h"
#if DEFAULT_MAX_QTY != 99
#error "The type file was generated with a different default_max_qty than this file"
#endif
int cbor_decode_lwm2m_senml(const uint8_t *payload, size_t payload_len, struct lwm2m_senml *result, int cbor_decode_lwm2m_senml(const uint8_t *payload, size_t payload_len, struct lwm2m_senml *result,
size_t *payload_len_out); size_t *payload_len_out);

View file

@ -1,21 +1,19 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/* /*
* Generated using zcbor version 0.6.0 * Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor * https://github.com/NordicSemiconductor/zcbor
* Generated with a --default-max-qty of 99 * Generated with a --default-max-qty of 99
*/ */
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include "zcbor_encode.h" #include "zcbor_encode.h"
#include "lwm2m_senml_cbor_encode.h" #include "lwm2m_senml_cbor_encode.h"
#include "lwm2m_senml_cbor_types.h"
#if DEFAULT_MAX_QTY != 99
#error "The type file was generated with a different default_max_qty than this file"
#endif
static bool encode_repeated_record_bn(zcbor_state_t *state, const struct record_bn *input); static bool encode_repeated_record_bn(zcbor_state_t *state, const struct record_bn *input);
static bool encode_repeated_record_bt(zcbor_state_t *state, const struct record_bt *input); static bool encode_repeated_record_bt(zcbor_state_t *state, const struct record_bt *input);
@ -36,8 +34,9 @@ static bool encode_repeated_record_bn(zcbor_state_t *state, const struct record_
bool tmp_result = ((((zcbor_int32_put(state, (-2)))) && bool tmp_result = ((((zcbor_int32_put(state, (-2)))) &&
(zcbor_tstr_encode(state, (&(*input)._record_bn))))); (zcbor_tstr_encode(state, (&(*input)._record_bn)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -47,13 +46,14 @@ static bool encode_repeated_record_bt(zcbor_state_t *state, const struct record_
zcbor_print("%s\r\n", __func__); zcbor_print("%s\r\n", __func__);
bool tmp_result = ((((zcbor_int32_put(state, (-3)))) && bool tmp_result = ((((zcbor_int32_put(state, (-3)))) &&
((((*input)._record_bt >= INT64_MIN) && ((((*input)._record_bt >= -9223372036854775807LL) &&
((*input)._record_bt <= INT64_MAX)) || ((*input)._record_bt <= 9223372036854775807LL)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)) && (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)) &&
(zcbor_int64_encode(state, (&(*input)._record_bt))))); (zcbor_int64_encode(state, (&(*input)._record_bt)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -65,8 +65,9 @@ static bool encode_repeated_record_n(zcbor_state_t *state, const struct record_n
bool tmp_result = ((((zcbor_uint32_put(state, (0)))) && bool tmp_result = ((((zcbor_uint32_put(state, (0)))) &&
(zcbor_tstr_encode(state, (&(*input)._record_n))))); (zcbor_tstr_encode(state, (&(*input)._record_n)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -76,13 +77,14 @@ static bool encode_repeated_record_t(zcbor_state_t *state, const struct record_t
zcbor_print("%s\r\n", __func__); zcbor_print("%s\r\n", __func__);
bool tmp_result = ((((zcbor_uint32_put(state, (6)))) && bool tmp_result = ((((zcbor_uint32_put(state, (6)))) &&
((((*input)._record_t >= INT64_MIN) && ((((*input)._record_t >= -9223372036854775807LL) &&
((*input)._record_t <= INT64_MAX)) || ((*input)._record_t <= 9223372036854775807LL)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)) && (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)) &&
(zcbor_int64_encode(state, (&(*input)._record_t))))); (zcbor_int64_encode(state, (&(*input)._record_t)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -90,12 +92,13 @@ static bool encode_repeated_record_t(zcbor_state_t *state, const struct record_t
static bool encode_repeated_record_union(zcbor_state_t *state, const struct record_union_ *input) static bool encode_repeated_record_union(zcbor_state_t *state, const struct record_union_ *input)
{ {
zcbor_print("%s\r\n", __func__); zcbor_print("%s\r\n", __func__);
struct zcbor_string tmp_str;
bool tmp_result = ((( bool tmp_result = (((
((*input)._record_union_choice == _union_vi) ((*input)._record_union_choice == _union_vi)
? (((zcbor_uint32_put(state, (2)))) && ? (((zcbor_uint32_put(state, (2)))) &&
((((*input)._union_vi >= INT64_MIN) && ((((*input)._union_vi >= -9223372036854775807LL) &&
((*input)._union_vi <= INT64_MAX)) || ((*input)._union_vi <= 9223372036854775807LL)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)) && (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)) &&
(zcbor_int64_encode(state, (&(*input)._union_vi)))) (zcbor_int64_encode(state, (&(*input)._union_vi))))
: (((*input)._record_union_choice == _union_vf) : (((*input)._record_union_choice == _union_vf)
@ -113,12 +116,26 @@ static bool encode_repeated_record_union(zcbor_state_t *state, const struct reco
? (((zcbor_uint32_put(state, ? (((zcbor_uint32_put(state,
(8)))) && (8)))) &&
(zcbor_bstr_encode( (zcbor_bstr_encode(
state, state,
(&(*input)._union_vd)))) (&(*input)._union_vd))))
: false))))))); : (((*input)._record_union_choice ==
_union_vlo)
? (((zcbor_tstr_encode(
state,
((tmp_str.value =
(uint8_t *)"vlo",
tmp_str.len =
sizeof("vlo") -
1,
&tmp_str))))) &&
(zcbor_tstr_encode(
state,
(&(*input)._union_vlo))))
: false))))))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -133,8 +150,10 @@ static bool encode_value(zcbor_state_t *state, const struct value_ *input)
: (((*input)._value_choice == _value_bstr) : (((*input)._value_choice == _value_bstr)
? ((zcbor_bstr_encode(state, (&(*input)._value_bstr)))) ? ((zcbor_bstr_encode(state, (&(*input)._value_bstr))))
: (((*input)._value_choice == _value_int) : (((*input)._value_choice == _value_int)
? (((((*input)._value_int >= INT64_MIN) && ? (((((*input)._value_int >=
((*input)._value_int <= INT64_MAX)) || -9223372036854775807LL) &&
((*input)._value_int <=
9223372036854775807LL)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE),
false)) && false)) &&
(zcbor_int64_encode(state, (zcbor_int64_encode(state,
@ -145,12 +164,13 @@ static bool encode_value(zcbor_state_t *state, const struct value_ *input)
(&(*input)._value_float)))) (&(*input)._value_float))))
: (((*input)._value_choice == _value_bool) : (((*input)._value_choice == _value_bool)
? ((zcbor_bool_encode( ? ((zcbor_bool_encode(
state, state,
(&(*input)._value_bool)))) (&(*input)._value_bool))))
: false))))))); : false)))))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -162,8 +182,9 @@ 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)))) && bool tmp_result = ((((zcbor_int32_encode(state, (&(*input)._key_value_pair_key)))) &&
(encode_value(state, (&(*input)._key_value_pair))))); (encode_value(state, (&(*input)._key_value_pair)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -175,8 +196,9 @@ 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))))); bool tmp_result = (((encode_key_value_pair(state, (&(*input)._record__key_value_pair)))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -185,9 +207,7 @@ static bool encode_record(zcbor_state_t *state, const struct record *input)
{ {
zcbor_print("%s\r\n", __func__); zcbor_print("%s\r\n", __func__);
int max_keys = ZCBOR_ARRAY_SIZE(input->_record__key_value_pair); bool tmp_result = (((zcbor_map_start_encode(state, 10) &&
bool tmp_result = (((zcbor_map_start_encode(state, max_keys + 5) &&
((zcbor_present_encode(&((*input)._record_bn_present), ((zcbor_present_encode(&((*input)._record_bn_present),
(zcbor_encoder_t *)encode_repeated_record_bn, (zcbor_encoder_t *)encode_repeated_record_bn,
state, (&(*input)._record_bn)) && state, (&(*input)._record_bn)) &&
@ -204,15 +224,16 @@ static bool encode_record(zcbor_state_t *state, const struct record *input)
(zcbor_encoder_t *)encode_repeated_record_union, (zcbor_encoder_t *)encode_repeated_record_union,
state, (&(*input)._record_union)) && state, (&(*input)._record_union)) &&
zcbor_multi_encode_minmax( zcbor_multi_encode_minmax(
0, max_keys, &(*input)._record__key_value_pair_count, 0, 5, &(*input)._record__key_value_pair_count,
(zcbor_encoder_t *)encode_repeated_record__key_value_pair, (zcbor_encoder_t *)encode_repeated_record__key_value_pair,
state, (&(*input)._record__key_value_pair), state, (&(*input)._record__key_value_pair),
sizeof(struct record__key_value_pair))) || sizeof(struct record__key_value_pair))) ||
(zcbor_list_map_end_force_encode(state), false)) && (zcbor_list_map_end_force_encode(state), false)) &&
zcbor_map_end_encode(state, max_keys + 5)))); zcbor_map_end_encode(state, 10))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }
@ -220,18 +241,18 @@ static bool encode_record(zcbor_state_t *state, const struct record *input)
static bool encode_lwm2m_senml(zcbor_state_t *state, const struct lwm2m_senml *input) static bool encode_lwm2m_senml(zcbor_state_t *state, const struct lwm2m_senml *input)
{ {
zcbor_print("%s\r\n", __func__); zcbor_print("%s\r\n", __func__);
size_t max_records = ZCBOR_ARRAY_SIZE(input->_lwm2m_senml__record);
bool tmp_result = (((zcbor_list_start_encode(state, max_records) && bool tmp_result = (((zcbor_list_start_encode(state, 99) &&
((zcbor_multi_encode_minmax( ((zcbor_multi_encode_minmax(
1, max_records, &(*input)._lwm2m_senml__record_count, 1, 99, &(*input)._lwm2m_senml__record_count,
(zcbor_encoder_t *)encode_record, state, (zcbor_encoder_t *)encode_record, state,
(&(*input)._lwm2m_senml__record), sizeof(struct record))) || (&(*input)._lwm2m_senml__record), sizeof(struct record))) ||
(zcbor_list_map_end_force_encode(state), false)) && (zcbor_list_map_end_force_encode(state), false)) &&
zcbor_list_end_encode(state, max_records)))); zcbor_list_end_encode(state, 99))));
if (!tmp_result) if (!tmp_result) {
zcbor_trace(); zcbor_trace();
}
return tmp_result; return tmp_result;
} }

View file

@ -1,24 +1,23 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/* /*
* Generated using zcbor version 0.6.0 * Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor * https://github.com/NordicSemiconductor/zcbor
* Generated with a --default-max-qty of 99 * Generated with a --default-max-qty of 99
*/ */
#ifndef LWM2M_SENML_CBOR_ENCODE_H__ #ifndef LWM2M_SENML_CBOR_ENCODE_H__
#define LWM2M_SENML_CBOR_ENCODE_H__ #define LWM2M_SENML_CBOR_ENCODE_H__
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include "zcbor_encode.h" #include "zcbor_encode.h"
#include "lwm2m_senml_cbor_types.h" #include "lwm2m_senml_cbor_types.h"
#if DEFAULT_MAX_QTY != 99
#error "The type file was generated with a different default_max_qty than this file"
#endif
int cbor_encode_lwm2m_senml(uint8_t *payload, size_t payload_len, const struct lwm2m_senml *input, int cbor_encode_lwm2m_senml(uint8_t *payload, size_t payload_len, const struct lwm2m_senml *input,
size_t *payload_len_out); size_t *payload_len_out);

View file

@ -1,35 +1,17 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/* /*
* Generated using zcbor version 0.6.0 * Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor * https://github.com/NordicSemiconductor/zcbor
* Generated with a --default-max-qty of 99 * Generated with a --default-max-qty of 99
*/ */
#ifndef LWM2M_SENML_CBOR_TYPES_H__ #ifndef LWM2M_SENML_CBOR_TYPES_H__
#define LWM2M_SENML_CBOR_TYPES_H__ #define LWM2M_SENML_CBOR_TYPES_H__
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include "zcbor_common.h" #include "zcbor_encode.h"
enum lwm2m_senml_cbor_key {
lwm2m_senml_cbor_key_bn = -2,
lwm2m_senml_cbor_key_bt = -3,
lwm2m_senml_cbor_key_n = 0,
lwm2m_senml_cbor_key_t = 6,
lwm2m_senml_cbor_key_vi = 2,
lwm2m_senml_cbor_key_vf = 2,
lwm2m_senml_cbor_key_vs = 3,
lwm2m_senml_cbor_key_vb = 4,
lwm2m_senml_cbor_key_vd = 8,
};
/** Which value for --default-max-qty this file was created with. /** Which value for --default-max-qty this file was created with.
* *
@ -38,7 +20,7 @@ enum lwm2m_senml_cbor_key {
* *
* See `zcbor --help` for more information about --default-max-qty * See `zcbor --help` for more information about --default-max-qty
*/ */
#define DEFAULT_MAX_QTY CONFIG_LWM2M_RW_SENML_CBOR_RECORDS #define DEFAULT_MAX_QTY 99
struct record_bn { struct record_bn {
struct zcbor_string _record_bn; struct zcbor_string _record_bn;
@ -73,6 +55,9 @@ struct record_union_ {
struct { struct {
struct zcbor_string _union_vd; struct zcbor_string _union_vd;
}; };
struct {
struct zcbor_string _union_vlo;
};
}; };
enum { enum {
_union_vi, _union_vi,
@ -80,6 +65,7 @@ struct record_union_ {
_union_vs, _union_vs,
_union_vb, _union_vb,
_union_vd, _union_vd,
_union_vlo,
} _record_union_choice; } _record_union_choice;
}; };
@ -125,7 +111,7 @@ struct record {
}; };
struct lwm2m_senml { struct lwm2m_senml {
struct record _lwm2m_senml__record[DEFAULT_MAX_QTY]; struct record _lwm2m_senml__record[99];
uint_fast32_t _lwm2m_senml__record_count; uint_fast32_t _lwm2m_senml__record_count;
}; };