Skip to content

Commit

Permalink
net: lib: lwm2m_client_utils: RSRP is now 16 bit
Browse files Browse the repository at this point in the history
Upstream Zephyr changes RSRP resource from 8bit to
16 bit signed value.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
  • Loading branch information
SeppoTakalo authored and rlubos committed Aug 3, 2023
1 parent 961ddc5 commit c0aeffb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_connmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static void modem_signal_update(struct k_work *work)
return;
}

lwm2m_set_s8(&LWM2M_OBJ(4, 0, 2), modem_rsrp);
lwm2m_set_s16(&LWM2M_OBJ(4, 0, 2), modem_rsrp);
timestamp_prev = k_uptime_get_32();
}

Expand Down
10 changes: 5 additions & 5 deletions tests/subsys/net/lib/lwm2m_client_utils/src/connmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static rsrp_cb_t modem_info_rsrp_cb;

static uint8_t connmon_mode;

static int8_t modem_rsrp_resource;
static int16_t modem_rsrp_resource;

static enum lte_lc_lte_mode lte_mode;

Expand Down Expand Up @@ -61,10 +61,10 @@ static int set_string_custom_fake(const struct lwm2m_obj_path *path, const char
return 0;
}

static int set_s8_custom_fake(const struct lwm2m_obj_path *path, int8_t value)
static int set_s16_custom_fake(const struct lwm2m_obj_path *path, int16_t value)
{
if (path->obj_id == 4 && path->obj_inst_id == 0 && path->res_id == 2) {
zassert_equal((int8_t)RSRP_IDX_TO_DBM(modem_rsrp_resource), value);
zassert_equal((int16_t)RSRP_IDX_TO_DBM(modem_rsrp_resource), value);
} else {
zassert(0, "Invalid path");
return -EINVAL;
Expand Down Expand Up @@ -162,7 +162,7 @@ ZTEST(lwm2m_client_utils_connmon, test_connected)
modem_rsrp_resource = 50;
lte_lc_register_handler_fake.custom_fake = copy_event_handler;
lwm2m_set_string_fake.custom_fake = set_string_custom_fake;
lwm2m_set_s8_fake.custom_fake = set_s8_custom_fake;
lwm2m_set_s16_fake.custom_fake = set_s16_custom_fake;
modem_info_params_get_fake.custom_fake = copy_modem_info;
modem_info_rsrp_register_fake.custom_fake = copy_rsrp_handler;
lwm2m_init_connmon();
Expand All @@ -174,7 +174,7 @@ ZTEST(lwm2m_client_utils_connmon, test_connected)
zassert_equal(lwm2m_set_string_fake.call_count, 3, "Strings not set");
modem_info_rsrp_cb(modem_rsrp_resource);
k_sleep(K_MSEC(100));
zassert_equal(lwm2m_set_s8_fake.call_count, 1, "RSRP not set");
zassert_equal(lwm2m_set_s16_fake.call_count, 1, "RSRP not set");
evt.nw_reg_status = LTE_LC_NW_REG_NOT_REGISTERED;
handler(&evt);
k_sleep(K_MSEC(100));
Expand Down
2 changes: 1 addition & 1 deletion tests/subsys/net/lib/lwm2m_client_utils/src/stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ DEFINE_FAKE_VALUE_FUNC(int, lwm2m_create_res_inst, const struct lwm2m_obj_path *
DEFINE_FAKE_VALUE_FUNC(int, lwm2m_set_res_buf, const struct lwm2m_obj_path *, void *, uint16_t,
uint16_t, uint8_t);
DEFINE_FAKE_VALUE_FUNC(int, lwm2m_set_u32, const struct lwm2m_obj_path *, uint32_t);
DEFINE_FAKE_VALUE_FUNC(int, lwm2m_set_s8, const struct lwm2m_obj_path *, int8_t);
DEFINE_FAKE_VALUE_FUNC(int, lwm2m_set_s16, const struct lwm2m_obj_path *, int16_t);
DEFINE_FAKE_VALUE_FUNC(int, lwm2m_set_s32, const struct lwm2m_obj_path *, int32_t);
DEFINE_FAKE_VALUE_FUNC(int, lwm2m_register_exec_callback, const struct lwm2m_obj_path *,
lwm2m_engine_execute_cb_t);
Expand Down
4 changes: 2 additions & 2 deletions tests/subsys/net/lib/lwm2m_client_utils/src/stubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ DECLARE_FAKE_VALUE_FUNC(int, lwm2m_create_res_inst, const struct lwm2m_obj_path
DECLARE_FAKE_VALUE_FUNC(int, lwm2m_set_res_buf, const struct lwm2m_obj_path *, void *, uint16_t,
uint16_t, uint8_t);
DECLARE_FAKE_VALUE_FUNC(int, lwm2m_set_u32, const struct lwm2m_obj_path *, uint32_t);
DECLARE_FAKE_VALUE_FUNC(int, lwm2m_set_s8, const struct lwm2m_obj_path *, int8_t);
DECLARE_FAKE_VALUE_FUNC(int, lwm2m_set_s16, const struct lwm2m_obj_path *, int16_t);
DECLARE_FAKE_VALUE_FUNC(int, lwm2m_set_s32, const struct lwm2m_obj_path *, int32_t);
DECLARE_FAKE_VALUE_FUNC(int, modem_info_rsrp_register, rsrp_cb_t);
DECLARE_FAKE_VALUE_FUNC(int, lwm2m_register_exec_callback, const struct lwm2m_obj_path *,
Expand Down Expand Up @@ -113,7 +113,7 @@ DECLARE_FAKE_VALUE_FUNC(int, at_params_list_init, struct at_param_list *, size_t
FUNC(lwm2m_get_res_buf) \
FUNC(lwm2m_get_u8) \
FUNC(lwm2m_get_bool) \
FUNC(lwm2m_set_s8) \
FUNC(lwm2m_set_s16) \
FUNC(lwm2m_set_s32) \
FUNC(lwm2m_set_opaque) \
FUNC(lwm2m_set_string) \
Expand Down

0 comments on commit c0aeffb

Please sign in to comment.