@@ -33,13 +33,15 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
33
33
#include "lwm2m_senml_cbor_types.h"
34
34
#include "lwm2m_util.h"
35
35
36
+ #define SENML_MAX_NAME_SIZE sizeof("/65535/65535/")
37
+
36
38
struct cbor_out_fmt_data {
37
39
/* Data */
38
40
struct lwm2m_senml input ;
39
41
40
- /* Storage for basenames and names ~ sizeof("/65535/999 /") */
42
+ /* Storage for basenames and names ~ sizeof("/65535/65535 /") */
41
43
struct {
42
- char names [CONFIG_LWM2M_RW_SENML_CBOR_RECORDS ][sizeof ( "/65535/999/" ) ];
44
+ char names [CONFIG_LWM2M_RW_SENML_CBOR_RECORDS ][SENML_MAX_NAME_SIZE ];
43
45
size_t name_sz ; /* Name buff size */
44
46
uint8_t name_cnt ;
45
47
};
@@ -93,7 +95,7 @@ static void setup_out_fmt_data(struct lwm2m_message *msg)
93
95
94
96
(void )memset (fd , 0 , sizeof (* fd ));
95
97
engine_set_out_user_data (& msg -> out , fd );
96
- fd -> name_sz = sizeof ( "/65535/999/" ) ;
98
+ fd -> name_sz = SENML_MAX_NAME_SIZE ;
97
99
fd -> basetime = 0 ;
98
100
fd -> objlnk_sz = sizeof ("65535:65535" );
99
101
}
@@ -160,7 +162,7 @@ static int put_basename(struct lwm2m_output_context *out, struct lwm2m_obj_path
160
162
record -> _record_bn ._record_bn .len = len ;
161
163
record -> _record_bn_present = 1 ;
162
164
163
- if ((len < sizeof ("0/0" ) - 1 ) || (len >= sizeof ( "65535/999" ) )) {
165
+ if ((len < sizeof ("/ 0/0" ) - 1 ) || (len >= SENML_MAX_NAME_SIZE )) {
164
166
__ASSERT_NO_MSG (false);
165
167
return - EINVAL ;
166
168
}
@@ -307,7 +309,7 @@ static int put_begin_ri(struct lwm2m_output_context *out, struct lwm2m_obj_path
307
309
}
308
310
309
311
/* Forms name from resource id and resource instance id */
310
- int len = snprintk (name , sizeof ( "65535/999" ) ,
312
+ int len = snprintk (name , SENML_MAX_NAME_SIZE ,
311
313
"%" PRIu16 "/%" PRIu16 "" ,
312
314
path -> res_id , path -> res_inst_id );
313
315
@@ -709,7 +711,7 @@ static int do_write_op_item(struct lwm2m_message *msg, struct record *rec)
709
711
uint8_t created = 0U ;
710
712
struct cbor_in_fmt_data * fd ;
711
713
/* Composite op - name with basename */
712
- char name [sizeof ( "65535/999" ) ] = { 0 }; /* Null terminated name */
714
+ char name [SENML_MAX_NAME_SIZE ] = { 0 }; /* Null terminated name */
713
715
int len = 0 ;
714
716
char fqn [MAX_RESOURCE_LEN + 1 ] = {0 };
715
717
0 commit comments