Skip to content

Commit

Permalink
samples: nrf9160: modem_shell: LED #1 to indicate LTE reg status
Browse files Browse the repository at this point in the history
LED #1 is now on indicating if LTE is registered.
Jira: MOSH-154

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
  • Loading branch information
jhirsi authored and rlubos committed Jan 24, 2022
1 parent ba5fbc6 commit 6074b44
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/nrf/releases/release-notes-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
8 changes: 8 additions & 0 deletions samples/nrf9160/modem_shell/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=======

Expand Down
1 change: 1 addition & 0 deletions samples/nrf9160/modem_shell/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions samples/nrf9160/modem_shell/src/link/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <modem/lte_lc.h>
#include <modem/pdn.h>

#include <dk_buttons_and_leds.h>

#include <nrf_socket.h>

#include "link_settings.h"
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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(&registered_work);
} else {
dk_set_led_off(REGISTERED_STATUS_LED);
}
break;
case LTE_LC_EVT_CELL_UPDATE:
Expand Down
5 changes: 5 additions & 0 deletions samples/nrf9160/modem_shell/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 6074b44

Please sign in to comment.