Skip to content

Commit

Permalink
modules: memfault-firmware-sdk: Don't get modem params in offline mode
Browse files Browse the repository at this point in the history
Check functional mode before fetching modem parameters.
Without this check, the modem info APIs will return an error
when the modem is offline.

Signed-off-by: Simen S. Røstad <[email protected]>
  • Loading branch information
simensrostad authored and tmon-nordic committed Aug 19, 2024
1 parent 37e656c commit 3914dcb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions modules/memfault-firmware-sdk/memfault_lte_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ static void lte_trace_cb(enum lte_lc_trace_type type)
}
}

static void lte_handler(const struct lte_lc_evt *const evt)
static void modem_params_get(void)
{
int err;

#if defined(CONFIG_MODEM_INFO)
int err;
int rsrp;
uint8_t band;
int snr;
Expand Down Expand Up @@ -93,6 +92,19 @@ static void lte_handler(const struct lte_lc_evt *const evt)
}
}
#endif
}

static void lte_handler(const struct lte_lc_evt *const evt)
{
int err;
enum lte_lc_func_mode mode = LTE_LC_FUNC_MODE_OFFLINE;

err = lte_lc_func_mode_get(&mode);
if (err) {
LOG_ERR("Failed to get LTE mode, error: %d", err);
} else if (mode != LTE_LC_FUNC_MODE_OFFLINE) {
modem_params_get();
}

switch (evt->type) {
case LTE_LC_EVT_NW_REG_STATUS:
Expand Down

0 comments on commit 3914dcb

Please sign in to comment.