Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions app/src/sm_cmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ static int do_at_and_ppp_channel_switch(int new_at_channel)
LOG_DBG("Switching CMUX PPP channel to %d", !cmux.at_channel + 1);
sm_at_host_release(sm_at_host_get_ctx_from(ppp_pipe));
sm_ppp_attach(ppp_pipe);
sm_ppp_detach_after_disconnect();
}
return -SILENT_AT_COMMAND_RET;
}
Expand Down Expand Up @@ -293,17 +294,13 @@ static int handle_at_xcmux(enum at_parser_cmd_type cmd_type, struct at_parser *p
const unsigned int at_channel = DLCI_TO_INDEX(at_dlci);

if (IS_ENABLED(CONFIG_SM_PPP)) {
if (!sm_ppp_is_stopped() && at_channel != cmux.at_channel) {
if (ppp_is_running() && at_channel != cmux.at_channel) {
/* The AT channel cannot be changed when PPP has a channel reserved.
*/
return -ENOTSUP;
}
}
if (sm_cmux_is_started()) {
if (at_channel == cmux.at_channel) {
/* No channel change requested and CMUX is already running */
return -EALREADY;
}
return do_at_and_ppp_channel_switch(at_channel);
}
cmux.at_channel = at_channel;
Expand Down
13 changes: 11 additions & 2 deletions app/src/sm_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static void delegate_ppp_event(enum ppp_action action, enum ppp_reason reason)
}
}

static bool ppp_is_running(void)
bool ppp_is_running(void)
{
return (ppp_state == PPP_STATE_RUNNING);
}
Expand Down Expand Up @@ -719,7 +719,7 @@ static int handle_at_ppp(enum at_parser_cmd_type cmd_type, struct at_parser *par
} else {
rsp_send_ok();
sm_ppp_set_auto_start(false);
delegate_ppp_event(PPP_STOP, PPP_REASON_CMD);
sm_ppp_detach();
}
return -SILENT_AT_COMMAND_RET;
}
Expand Down Expand Up @@ -943,4 +943,13 @@ void sm_ppp_detach(void)
{
ppp_pipe = NULL;
sm_ppp_keep_pipe_attached = false;
sm_ppp_auto_start = false;
if (!sm_ppp_is_stopped()) {
delegate_ppp_event(PPP_STOP, PPP_REASON_CMD);
}
}

void sm_ppp_detach_after_disconnect(void)
{
sm_ppp_keep_pipe_attached = false;
}
4 changes: 4 additions & 0 deletions app/src/sm_ppp.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
extern bool sm_fwd_cgev_notifs;

bool sm_ppp_is_stopped(void);
bool ppp_is_running(void);
void sm_ppp_set_auto_start(bool enable);

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

/** Ask to detach from PIPE after disconnecting PPP */
void sm_ppp_detach_after_disconnect(void);

#endif
Loading