Skip to content

Commit 76b2e6d

Browse files
trantanenrlubos
authored andcommitted
lib: lte_link_control: Don't restore func mode in connect always
Functional mode was restored in connect_lte even if it was not obtained. This branch wasn't tested in unit tests and almost impossible to get into in system tests. Signed-off-by: Tommi Rantanen <[email protected]>
1 parent b601c6d commit 76b2e6d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/lte_link_control/lte_lc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ static int connect_lte(bool blocking)
664664
{
665665
int err;
666666
enum lte_lc_func_mode original_func_mode;
667+
bool func_mode_changed = false;
667668
enum lte_lc_nw_reg_status reg_status;
668669
static atomic_t in_progress;
669670

@@ -705,14 +706,16 @@ static int connect_lte(bool blocking)
705706
goto exit;
706707
}
707708

709+
func_mode_changed = true;
710+
708711
err = k_sem_take(&link, K_SECONDS(CONFIG_LTE_NETWORK_TIMEOUT));
709712
if (err == -EAGAIN) {
710713
LOG_INF("Network connection attempt timed out");
711714
err = -ETIMEDOUT;
712715
}
713716

714717
exit:
715-
if (err) {
718+
if (err && func_mode_changed) {
716719
/* Connecting to LTE network failed, restore original functional mode. */
717720
lte_lc_func_mode_set(original_func_mode);
718721
}

0 commit comments

Comments
 (0)