1+ /*
2+ * Copyright (c) 2022 Nordic Semiconductor ASA
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
16/*
27 * Generated using zcbor version 0.3.99
38 * https://github.com/zephyrproject-rtos/zcbor
1015#include <string.h>
1116#include "zcbor_encode.h"
1217#include "lwm2m_senml_cbor_encode.h"
13-
14- #if DEFAULT_MAX_QTY != 99
15- #error "The type file was generated with a different default_max_qty than this file"
16- #endif
18+ #include "lwm2m_senml_cbor_types.h"
1719
1820static bool encode_repeated_record_bn (zcbor_state_t * state , const struct record_bn * input )
1921{
@@ -139,7 +141,9 @@ static bool encode_record(zcbor_state_t *state, const struct record *input)
139141{
140142 zcbor_print ("%s\r\n" , __func__ );
141143
142- bool tmp_result = (((zcbor_map_start_encode (state , 6 ) &&
144+ int max_keys = ARRAY_SIZE (input -> _record__key_value_pair );
145+
146+ bool tmp_result = (((zcbor_map_start_encode (state , max_keys ) &&
143147 ((zcbor_present_encode (& ((* input )._record_bn_present ),
144148 (zcbor_encoder_t * )encode_repeated_record_bn ,
145149 state , (& (* input )._record_bn )) &&
@@ -150,12 +154,13 @@ static bool encode_record(zcbor_state_t *state, const struct record *input)
150154 (zcbor_encoder_t * )encode_repeated_record_union ,
151155 state , (& (* input )._record_union )) &&
152156 zcbor_multi_encode_minmax (
153- 0 , 3 , & (* input )._record__key_value_pair_count ,
157+ 0 , max_keys ,
158+ & (* input )._record__key_value_pair_count ,
154159 (zcbor_encoder_t * )encode_repeated_record__key_value_pair ,
155160 state , (& (* input )._record__key_value_pair ),
156161 sizeof (struct record__key_value_pair ))) ||
157162 (zcbor_list_map_end_force_encode (state ), false)) &&
158- zcbor_map_end_encode (state , 6 ))));
163+ zcbor_map_end_encode (state , max_keys ))));
159164
160165 if (!tmp_result )
161166 zcbor_trace ();
@@ -166,15 +171,16 @@ static bool encode_record(zcbor_state_t *state, const struct record *input)
166171static bool encode_lwm2m_senml (zcbor_state_t * state , const struct lwm2m_senml * input )
167172{
168173 zcbor_print ("%s\r\n" , __func__ );
174+ size_t max_records = ARRAY_SIZE (input -> _lwm2m_senml__record );
169175
170176 bool tmp_result =
171- (((zcbor_list_start_encode (state , 99 ) &&
172- ((zcbor_multi_encode_minmax (1 , 99 , & (* input )._lwm2m_senml__record_count ,
177+ (((zcbor_list_start_encode (state , max_records ) &&
178+ ((zcbor_multi_encode_minmax (1 , max_records , & (* input )._lwm2m_senml__record_count ,
173179 (zcbor_encoder_t * )encode_record , state ,
174180 (& (* input )._lwm2m_senml__record ),
175181 sizeof (struct record ))) ||
176182 (zcbor_list_map_end_force_encode (state ), false)) &&
177- zcbor_list_end_encode (state , 99 ))));
183+ zcbor_list_end_encode (state , max_records ))));
178184
179185 if (!tmp_result )
180186 zcbor_trace ();
@@ -197,6 +203,7 @@ uint_fast8_t cbor_encode_lwm2m_senml(uint8_t *payload, size_t payload_len,
197203
198204 if (!ret ) {
199205 uint_fast8_t ret = zcbor_pop_error (states );
206+
200207 return (ret == ZCBOR_SUCCESS ) ? ZCBOR_ERR_UNKNOWN : ret ;
201208 }
202209 return ZCBOR_SUCCESS ;
0 commit comments