Skip to content

Commit

Permalink
lib: nrf_modem: allow modem shutdown in flight mode
Browse files Browse the repository at this point in the history
Allow the modem to be shut down when in flight mode (CFUN=4).

Signed-off-by: Eivind Jølsgard <eivind.jolsgard@nordicsemi.no>
  • Loading branch information
eivindj-nordic committed Jun 22, 2023
1 parent 64922e8 commit f2a6f76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doc/nrf/releases/release-notes-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ Modem libraries

* Added the :ref:`modem_battery_readme` library that obtains battery voltage information or notifications from a modem.

* :ref:`nrf_modem_lib_readme`:

* Updated the :c:func:`nrf_modem_lib_shutdown` function to allow the modem to be in flight mode (``CFUN=4``) when shutting down the modem.

* :ref:`pdn_readme` library:

* Updated the library to allow a ``PDP_type``-only configuration in the :c:func:`pdn_ctx_configure` function.
Expand Down
7 changes: 5 additions & 2 deletions lib/nrf_modem_lib/nrf_modem_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ BUILD_ASSERT(IPC_IRQn == NRF_MODEM_IPC_IRQ, "NRF_MODEM_IPC_IRQ mismatch");

#define AT_CFUN_READ "AT+CFUN?"
#define AT_CFUN0_VAL 0
#define AT_CFUN4_VAL 4

/* The heap implementation in `nrf_modem_os.c` require some overhead
* to allow allocating up to `NRF_MODEM_LIB_SHMEM_TX_SIZE` bytes.
Expand Down Expand Up @@ -163,9 +164,11 @@ int nrf_modem_lib_shutdown(void)
e->callback(e->context);
}

/* The application must set CFUN=0 before calling nrf_modem_shutdown. */
/* The application must disable both transmit and receive RF circuits, and deactivate
* LTE and GNSS services, before calling nrf_modem_shutdown.
*/
ret = nrf_modem_at_scanf(AT_CFUN_READ, "+CFUN: %hu", &mode);
if (ret == 1 && mode != AT_CFUN0_VAL) {
if (ret == 1 && (mode != AT_CFUN0_VAL && mode != AT_CFUN4_VAL)) {
LOG_WRN("Application should set minimal functional mode (CFUN=0) before "
"shutting down modem library");
nrf_modem_at_printf("AT+CFUN=0");
Expand Down

0 comments on commit f2a6f76

Please sign in to comment.