Skip to content

Commit

Permalink
applications: serial_lte_modem: Fix CMUX and PPP
Browse files Browse the repository at this point in the history
Fixes to CMUX and PPP after upmerge.

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
  • Loading branch information
MarkusLassila authored and rlubos committed Oct 8, 2024
1 parent d10c71a commit 8bd71ba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
8 changes: 8 additions & 0 deletions applications/serial_lte_modem/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ config SLM_CMUX_AUTOMATIC_FALLBACK_ON_PPP_STOPPAGE

endif

if SLM_CMUX || SLM_PPP

config SLM_MODEM_PIPE_TIMEOUT
int "Timeout for the CMUX and PPP modem pipe operations in seconds"
default 10

endif

module = SLM
module-str = serial modem
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
Expand Down
13 changes: 10 additions & 3 deletions applications/serial_lte_modem/src/slm_cmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ LOG_MODULE_REGISTER(slm_cmux, CONFIG_SLM_LOG_LEVEL);
static struct {
/* UART backend */
struct modem_pipe *uart_pipe;
bool uart_pipe_open;
struct modem_backend_uart uart_backend;
uint8_t uart_backend_receive_buf[RECV_BUF_LEN];
uint8_t uart_backend_transmit_buf[TRANSMIT_BUF_LEN];
Expand Down Expand Up @@ -138,17 +139,19 @@ static void close_pipe(struct modem_pipe **pipe)

static int cmux_stop(void)
{
if (cmux.uart_pipe && cmux.uart_pipe->state == MODEM_PIPE_STATE_OPEN) {
if (cmux.uart_pipe && cmux.uart_pipe_open) {
/* CMUX is running. Just close the UART pipe to pause and be able to resume.
* This allows AT data to be cached by the CMUX module while the UART is off.
*/
modem_pipe_close_async(cmux.uart_pipe);
cmux.uart_pipe_open = false;
return 0;
}

modem_cmux_release(&cmux.instance);

close_pipe(&cmux.uart_pipe);
cmux.uart_pipe_open = false;

for (size_t i = 0; i != ARRAY_SIZE(cmux.dlcis); ++i) {
close_pipe(&cmux.dlcis[i].pipe);
Expand Down Expand Up @@ -222,8 +225,9 @@ static int cmux_start(void)
int ret;

if (cmux_is_started()) {
ret = modem_pipe_open(cmux.uart_pipe);
ret = modem_pipe_open(cmux.uart_pipe, K_SECONDS(CONFIG_SLM_MODEM_PIPE_TIMEOUT));
if (!ret) {
cmux.uart_pipe_open = true;
LOG_INF("CMUX resumed.");
}
return ret;
Expand All @@ -249,7 +253,10 @@ static int cmux_start(void)
return ret;
}

ret = modem_pipe_open(cmux.uart_pipe);
ret = modem_pipe_open(cmux.uart_pipe, K_SECONDS(CONFIG_SLM_MODEM_PIPE_TIMEOUT));
if (!ret) {
cmux.uart_pipe_open = true;
}
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions applications/serial_lte_modem/src/slm_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static int ppp_start_internal(void)
modem_ppp_attach(&ppp_module, ppp_pipe);

#if !defined(CONFIG_SLM_CMUX)
ret = modem_pipe_open(ppp_pipe);
ret = modem_pipe_open(ppp_pipe, K_SECONDS(CONFIG_SLM_MODEM_PIPE_TIMEOUT));
if (ret) {
LOG_ERR("Failed to open PPP pipe (%d).", ret);
return ppp_start_failure(ret);
Expand Down Expand Up @@ -297,7 +297,7 @@ static void ppp_stop_internal(void)
}

#if !defined(CONFIG_SLM_CMUX)
modem_pipe_close(ppp_pipe);
modem_pipe_close(ppp_pipe, K_SECONDS(CONFIG_SLM_MODEM_PIPE_TIMEOUT));
#endif

modem_ppp_release(&ppp_module);
Expand Down

0 comments on commit 8bd71ba

Please sign in to comment.