Skip to content

Commit 6aa43a3

Browse files
juhaylinennordicjm
authored andcommitted
samples: nrf_provisioning: Check active GNSS
Connection manager disconnects only LTE and GNSS may still be active. Check modem's functional mode and deactivate GNSS before storing credentials to modem. Signed-off-by: Juha Ylinen <[email protected]>
1 parent 4c369f2 commit 6aa43a3

File tree

1 file changed

+17
-0
lines changed
  • samples/cellular/nrf_provisioning/src

1 file changed

+17
-0
lines changed

samples/cellular/nrf_provisioning/src/main.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ static int modem_mode_cb(enum lte_lc_func_mode new_mode, void *user_data)
8585
k_event_wait(&prov_events, NETWORK_DOWN, false, K_FOREVER);
8686

8787
LOG_DBG("Network is down.");
88+
89+
/* conn_mgr disables only LTE connectivity. GNSS may remain active.
90+
* Ensure GNSS is also disabled before storing credentials to the modem.
91+
*/
92+
enum lte_lc_func_mode current_mode;
93+
94+
if (lte_lc_func_mode_get(&current_mode)) {
95+
LOG_ERR("Failed to read modem functional mode");
96+
return -EFAULT;
97+
}
98+
if (current_mode == LTE_LC_FUNC_MODE_ACTIVATE_GNSS) {
99+
LOG_WRN("GNSS is still active. Deactivating GNSS.");
100+
if (lte_lc_func_mode_set(LTE_LC_FUNC_MODE_DEACTIVATE_GNSS)) {
101+
LOG_ERR("Failed to deactivate GNSS");
102+
return -EFAULT;
103+
}
104+
}
88105
}
89106

90107
return fmode;

0 commit comments

Comments
 (0)