From 6074b44e850fa421bde3b70378ccb74b5f28ebfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jani=20Hirsim=C3=A4ki?= Date: Thu, 13 Jan 2022 11:04:22 +0200 Subject: [PATCH] samples: nrf9160: modem_shell: LED #1 to indicate LTE reg status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LED #1 is now on indicating if LTE is registered. Jira: MOSH-154 Signed-off-by: Jani Hirsimäki --- doc/nrf/releases/release-notes-changelog.rst | 1 + samples/nrf9160/modem_shell/README.rst | 8 ++++++++ samples/nrf9160/modem_shell/prj.conf | 1 + samples/nrf9160/modem_shell/src/link/link.c | 8 ++++++++ samples/nrf9160/modem_shell/src/main.c | 5 +++++ 5 files changed, 23 insertions(+) diff --git a/doc/nrf/releases/release-notes-changelog.rst b/doc/nrf/releases/release-notes-changelog.rst index 91042cd661f..b6c21477c34 100644 --- a/doc/nrf/releases/release-notes-changelog.rst +++ b/doc/nrf/releases/release-notes-changelog.rst @@ -130,6 +130,7 @@ nRF9160 samples * Added a new shell command ``cloud`` for establishing an MQTT connection to nRF Cloud. * Removed support for the GPS driver. + * The LED 1 on the development kit indicates the LTE registration status. * :ref:`http_application_update_sample` sample: diff --git a/samples/nrf9160/modem_shell/README.rst b/samples/nrf9160/modem_shell/README.rst index a1ea79eba3e..4b90590168f 100644 --- a/samples/nrf9160/modem_shell/README.rst +++ b/samples/nrf9160/modem_shell/README.rst @@ -621,6 +621,14 @@ Button 1: Button 2: Enables or disables the UARTs for power consumption measurements. Toggles between UARTs enabled and disabled. +LED indications +=============== + +The LEDs have the following functions: + +LED 1: + Indicates the LTE registration status. + Testing ======= diff --git a/samples/nrf9160/modem_shell/prj.conf b/samples/nrf9160/modem_shell/prj.conf index 7c22d925c84..f6c3dd9db18 100644 --- a/samples/nrf9160/modem_shell/prj.conf +++ b/samples/nrf9160/modem_shell/prj.conf @@ -141,6 +141,7 @@ CONFIG_MULTICELL_LOCATION_SERVICE_NRF_CLOUD=y # Library for buttons and LEDs CONFIG_DK_LIBRARY=y +CONFIG_DK_LIBRARY_INVERT_LEDS=n # FOTA CONFIG_FLASH=y diff --git a/samples/nrf9160/modem_shell/src/link/link.c b/samples/nrf9160/modem_shell/src/link/link.c index cd963392f1c..be8db49ff9f 100644 --- a/samples/nrf9160/modem_shell/src/link/link.c +++ b/samples/nrf9160/modem_shell/src/link/link.c @@ -17,6 +17,8 @@ #include #include +#include + #include #include "link_settings.h" @@ -47,6 +49,8 @@ struct pdn_activation_status_info { uint8_t cid; }; +#define REGISTERED_STATUS_LED DK_LED1 + /* Work for getting the modem info that ain't in lte connection ind: */ static struct k_work registered_work; @@ -147,6 +151,8 @@ static void link_registered_work(struct k_work *unused) ARG_UNUSED(unused); + dk_set_led_on(REGISTERED_STATUS_LED); + memset(pdn_act_status_arr, 0, CONFIG_PDN_CONTEXTS_MAX * sizeof(struct pdn_activation_status_info)); @@ -333,6 +339,8 @@ void link_ind_handler(const struct lte_lc_evt *const evt) evt->nw_reg_status == LTE_LC_NW_REG_REGISTERED_HOME || evt->nw_reg_status == LTE_LC_NW_REG_REGISTERED_ROAMING) { k_work_submit(®istered_work); + } else { + dk_set_led_off(REGISTERED_STATUS_LED); } break; case LTE_LC_EVT_CELL_UPDATE: diff --git a/samples/nrf9160/modem_shell/src/main.c b/samples/nrf9160/modem_shell/src/main.c index 665c1c08120..dcd9e235de5 100644 --- a/samples/nrf9160/modem_shell/src/main.c +++ b/samples/nrf9160/modem_shell/src/main.c @@ -200,6 +200,11 @@ void main(void) #endif k_poll_signal_init(&mosh_signal); + err = dk_leds_init(); + if (err) { + printk("Cannot initialize LEDs (err: %d)", err); + } + /* Resize terminal width and height of the shell to have proper command editing. */ shell_execute_cmd(shell, "resize"); /* Run empty command because otherwise "resize" would be set to the command line. */