Skip to content

Commit 2375ed1

Browse files
committed
[nrf fromlist] modem: cmux: Wake up before sending disconnect
If CMUX is going to be shut down while in power-saving mode, we need to wake-up before doing the state transitioning. If we directly transition from STATE_POWERSAVE to STATE_DISCONNECTING, the UART is not woken up and the disconnect commands are not send. Use is_connection() helper on both disconnect and connect APIs to clean up the state check. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no> Upstream PR #: 108978
1 parent 5c1a216 commit 2375ed1

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

subsys/modem/modem_cmux.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,15 @@ static void modem_cmux_disconnect_handler(struct k_work *item)
18311831
disconnect(cmux);
18321832
return;
18331833
}
1834-
} else if (cmux->state != MODEM_CMUX_STATE_DISCONNECTED) {
1834+
} else if (is_connected(cmux)) {
1835+
/* Check if we need to initiate wake-up before changing the state */
1836+
if (powersave_wait_wakeup(cmux)) {
1837+
/* Retry after the wake-up, if still alive */
1838+
if (is_connected(cmux)) {
1839+
modem_work_schedule(&cmux->disconnect_work, MODEM_CMUX_T1_TIMEOUT);
1840+
}
1841+
return;
1842+
}
18351843
set_state(cmux, MODEM_CMUX_STATE_DISCONNECTING);
18361844
cmux->retry_count = 0;
18371845
} else {
@@ -2208,7 +2216,7 @@ int modem_cmux_connect_async(struct modem_cmux *cmux)
22082216
{
22092217
int ret = 0;
22102218

2211-
if (cmux->state != MODEM_CMUX_STATE_DISCONNECTED) {
2219+
if (is_connecting(cmux)) {
22122220
return -EALREADY;
22132221
}
22142222

@@ -2246,7 +2254,7 @@ int modem_cmux_disconnect_async(struct modem_cmux *cmux)
22462254
{
22472255
int ret = 0;
22482256

2249-
if (cmux->state == MODEM_CMUX_STATE_DISCONNECTED) {
2257+
if (!is_connected(cmux)) {
22502258
return -EALREADY;
22512259
}
22522260

0 commit comments

Comments
 (0)