Skip to content

Commit 5228afe

Browse files
committed
app: Fixes for PPP restart logic with Zephyr host
When running on DLC1, we still need to detach from the pipe if PPP stops. Also, drop the check from AT#XCMUX=2 when it runs on the recovery. We don't keep track of the "current" channel anymore. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent c30f99e commit 5228afe

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

app/src/sm_cmux.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ static int do_at_and_ppp_channel_switch(int new_at_channel)
220220
LOG_DBG("Switching CMUX PPP channel to %d", !cmux.at_channel + 1);
221221
sm_at_host_release(sm_at_host_get_ctx_from(ppp_pipe));
222222
sm_ppp_attach(ppp_pipe);
223+
sm_ppp_detach_after_disconnect();
223224
}
224225
return -SILENT_AT_COMMAND_RET;
225226
}
@@ -293,17 +294,13 @@ static int handle_at_xcmux(enum at_parser_cmd_type cmd_type, struct at_parser *p
293294
const unsigned int at_channel = DLCI_TO_INDEX(at_dlci);
294295

295296
if (IS_ENABLED(CONFIG_SM_PPP)) {
296-
if (!sm_ppp_is_stopped() && at_channel != cmux.at_channel) {
297+
if (ppp_is_running() && at_channel != cmux.at_channel) {
297298
/* The AT channel cannot be changed when PPP has a channel reserved.
298299
*/
299300
return -ENOTSUP;
300301
}
301302
}
302303
if (sm_cmux_is_started()) {
303-
if (at_channel == cmux.at_channel) {
304-
/* No channel change requested and CMUX is already running */
305-
return -EALREADY;
306-
}
307304
return do_at_and_ppp_channel_switch(at_channel);
308305
}
309306
cmux.at_channel = at_channel;

app/src/sm_ppp.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static void delegate_ppp_event(enum ppp_action action, enum ppp_reason reason)
241241
}
242242
}
243243

244-
static bool ppp_is_running(void)
244+
bool ppp_is_running(void)
245245
{
246246
return (ppp_state == PPP_STATE_RUNNING);
247247
}
@@ -719,7 +719,7 @@ static int handle_at_ppp(enum at_parser_cmd_type cmd_type, struct at_parser *par
719719
} else {
720720
rsp_send_ok();
721721
sm_ppp_set_auto_start(false);
722-
delegate_ppp_event(PPP_STOP, PPP_REASON_CMD);
722+
sm_ppp_detach();
723723
}
724724
return -SILENT_AT_COMMAND_RET;
725725
}
@@ -943,4 +943,13 @@ void sm_ppp_detach(void)
943943
{
944944
ppp_pipe = NULL;
945945
sm_ppp_keep_pipe_attached = false;
946+
sm_ppp_auto_start = false;
947+
if (!sm_ppp_is_stopped()) {
948+
delegate_ppp_event(PPP_STOP, PPP_REASON_CMD);
949+
}
950+
}
951+
952+
void sm_ppp_detach_after_disconnect(void)
953+
{
954+
sm_ppp_keep_pipe_attached = false;
946955
}

app/src/sm_ppp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
extern bool sm_fwd_cgev_notifs;
1414

1515
bool sm_ppp_is_stopped(void);
16+
bool ppp_is_running(void);
1617
void sm_ppp_set_auto_start(bool enable);
1718

1819
/** Set the permanent modem pipe for PPP communication */
@@ -21,4 +22,7 @@ void sm_ppp_attach(struct modem_pipe *pipe);
2122
/** Detach the modem pipe from PPP communication */
2223
void sm_ppp_detach(void);
2324

25+
/** Ask to detach from PIPE after disconnecting PPP */
26+
void sm_ppp_detach_after_disconnect(void);
27+
2428
#endif

0 commit comments

Comments
 (0)