net: lwm2m: Properly initialize buffers for resource instance
When resource instances are initialized, we must calculate beginning of the data buffer using the index and maximum data length. Otherwise buffers would overlap with previous. Fixes #64011 Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commit is contained in:
parent
36d6a7257b
commit
015b1103fb
3 changed files with 38 additions and 1 deletions
|
@ -13,3 +13,4 @@ CONFIG_LWM2M_IPSO_TEMP_SENSOR_VERSION_1_1=y
|
|||
CONFIG_LWM2M_IPSO_TEMP_SENSOR_INSTANCE_COUNT=4
|
||||
CONFIG_LWM2M_CONN_MON_OBJ_SUPPORT=y
|
||||
CONFIG_LWM2M_CONNMON_OBJECT_VERSION_1_2=y
|
||||
CONFIG_LWM2M_PORTFOLIO_OBJ_SUPPORT=y
|
||||
|
|
|
@ -285,6 +285,42 @@ ZTEST(lwm2m_registry, test_resource_instance_creation_and_deletion)
|
|||
zassert_equal(ret, 0);
|
||||
}
|
||||
|
||||
ZTEST(lwm2m_registry, test_resource_instance_strings)
|
||||
{
|
||||
int ret;
|
||||
char buf[256] = {0};
|
||||
static const char string_a[] = "Hello";
|
||||
static const char string_b[] = "World";
|
||||
struct lwm2m_obj_path path_a = LWM2M_OBJ(16, 0, 0, 0);
|
||||
struct lwm2m_obj_path path_b = LWM2M_OBJ(16, 0, 0, 1);
|
||||
|
||||
ret = lwm2m_create_object_inst(&LWM2M_OBJ(16, 0));
|
||||
zassert_equal(ret, 0);
|
||||
|
||||
ret = lwm2m_create_res_inst(&path_a);
|
||||
zassert_equal(ret, 0);
|
||||
|
||||
ret = lwm2m_create_res_inst(&path_b);
|
||||
zassert_equal(ret, 0);
|
||||
|
||||
ret = lwm2m_set_string(&path_a, string_a);
|
||||
zassert_equal(ret, 0);
|
||||
|
||||
ret = lwm2m_set_string(&path_b, string_b);
|
||||
zassert_equal(ret, 0);
|
||||
|
||||
ret = lwm2m_get_string(&path_a, buf, sizeof(buf));
|
||||
zassert_equal(ret, 0);
|
||||
zassert_equal(0, memcmp(buf, string_a, sizeof(string_a)));
|
||||
|
||||
ret = lwm2m_get_string(&path_b, buf, sizeof(buf));
|
||||
zassert_equal(ret, 0);
|
||||
zassert_equal(0, memcmp(buf, string_b, sizeof(string_b)));
|
||||
|
||||
ret = lwm2m_delete_object_inst(&LWM2M_OBJ(16, 0));
|
||||
zassert_equal(ret, 0);
|
||||
}
|
||||
|
||||
ZTEST(lwm2m_registry, test_callbacks)
|
||||
{
|
||||
int ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue