From b266253d340106e9561dae55886ac571c507702c Mon Sep 17 00:00:00 2001 From: Jan Tore Guggedal Date: Wed, 2 Oct 2024 12:48:49 +0200 Subject: [PATCH] modules: memfault: Add cell ID and TAC metrics Add collection of cell ID and tracking area code metrics when a cell update event is received. Signed-off-by: Jan Tore Guggedal --- .../config/memfault_metrics_heartbeat_extra.def | 2 ++ .../memfault-firmware-sdk/memfault_lte_metrics.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/memfault-firmware-sdk/config/memfault_metrics_heartbeat_extra.def b/modules/memfault-firmware-sdk/config/memfault_metrics_heartbeat_extra.def index 62c2d357d31a..82f725fcadda 100644 --- a/modules/memfault-firmware-sdk/config/memfault_metrics_heartbeat_extra.def +++ b/modules/memfault-firmware-sdk/config/memfault_metrics_heartbeat_extra.def @@ -31,6 +31,8 @@ MEMFAULT_METRICS_KEY_DEFINE(ncs_lte_edrx_ptw_ms, kMemfaultMetricType_Unsigned) MEMFAULT_METRICS_KEY_DEFINE(ncs_lte_mode, kMemfaultMetricType_Unsigned) MEMFAULT_METRICS_KEY_DEFINE(ncs_lte_on_time_ms, kMemfaultMetricType_Timer) MEMFAULT_METRICS_KEY_DEFINE(ncs_lte_reset_loop_detected_count, kMemfaultMetricType_Unsigned) +MEMFAULT_METRICS_KEY_DEFINE(ncs_lte_cell_id, kMemfaultMetricType_Signed) +MEMFAULT_METRICS_KEY_DEFINE(ncs_lte_tracking_area_code, kMemfaultMetricType_Signed) #endif /* CONFIG_MEMFAULT_NCS_LTE_METRICS */ #ifdef CONFIG_MEMFAULT_NCS_BT_METRICS diff --git a/modules/memfault-firmware-sdk/memfault_lte_metrics.c b/modules/memfault-firmware-sdk/memfault_lte_metrics.c index 68918254bd7e..ed204f800430 100644 --- a/modules/memfault-firmware-sdk/memfault_lte_metrics.c +++ b/modules/memfault-firmware-sdk/memfault_lte_metrics.c @@ -99,7 +99,7 @@ static void modem_params_get(void) err = modem_info_get_snr(&snr); if (err) { - LOG_DBG("Failed to get SNR") + LOG_DBG("Failed to get SNR"); return; } @@ -120,6 +120,17 @@ static void lte_handler(const struct lte_lc_evt *const evt) } switch (evt->type) { + case LTE_LC_EVT_CELL_UPDATE: + err = MEMFAULT_METRIC_SET_SIGNED(ncs_lte_cell_id, evt->cell.id); + if (err) { + LOG_ERR("Failed to set ncs_lte_cell_id"); + } + + err = MEMFAULT_METRIC_SET_SIGNED(ncs_lte_tracking_area_code, evt->cell.tac); + if (err) { + LOG_ERR("Failed to set ncs_lte_tracking_area_code"); + } + break; case LTE_LC_EVT_NW_REG_STATUS: switch (evt->nw_reg_status) {