Skip to content

Commit 485ffe4

Browse files
MarkusLassilaSeppoTakalo
authored andcommitted
applications: serial_lte_modem: Fix cellular modem driver dialup
Dialup script in cellular modem driver sends AT#XCMUX=2 request to change the DLCI for AT-commands. "OK" response must be sent with the same channel that the request was received. Signed-off-by: Markus Lassila <[email protected]>
1 parent 770ce00 commit 485ffe4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

applications/serial_lte_modem/src/slm_cmux.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static struct {
5454
} dlcis[CHANNEL_COUNT];
5555
/* Index of the DLCI used for AT communication; defaults to 0. */
5656
unsigned int at_channel;
57+
unsigned int requested_at_channel;
5758

5859
/* Incoming data for DLCI's. */
5960
atomic_t dlci_channel_rx;
@@ -199,6 +200,12 @@ static void tx_work_fn(struct k_work *work)
199200
if (!ring_buf_is_empty(&cmux.tx_rb)) {
200201
LOG_DBG("Remaining bytes in TX buffer: %u.", ring_buf_size_get(&cmux.tx_rb));
201202
}
203+
204+
if (cmux.requested_at_channel != UINT_MAX) {
205+
cmux.at_channel = cmux.requested_at_channel;
206+
cmux.requested_at_channel = UINT_MAX;
207+
LOG_INF("DLCI %u (AT) updated.", INDEX_TO_DLCI(cmux.at_channel));
208+
}
202209
}
203210

204211
static int cmux_write_at_channel_nonblock(const uint8_t *data, size_t len)
@@ -333,6 +340,8 @@ void slm_cmux_init(void)
333340
ring_buf_init(&cmux.tx_rb, sizeof(cmux.tx_buffer), cmux.tx_buffer);
334341
k_mutex_init(&cmux.tx_rb_mutex);
335342
k_work_init(&cmux.tx_work, tx_work_fn);
343+
344+
cmux.requested_at_channel = UINT_MAX;
336345
}
337346

338347
static struct cmux_dlci *cmux_get_dlci(enum cmux_channel channel)
@@ -463,9 +472,9 @@ static int handle_at_cmux(enum at_parser_cmd_type cmd_type, struct at_parser *pa
463472
}
464473
#endif
465474
if (cmux_is_started()) {
466-
/* Just update the AT channel, first answering "OK" on the current DLCI. */
475+
/* Update the AT channel after answering "OK" on the current DLCI. */
467476
rsp_send_ok();
468-
cmux.at_channel = at_channel;
477+
cmux.requested_at_channel = at_channel;
469478
return -SILENT_AT_COMMAND_RET;
470479
}
471480
cmux.at_channel = at_channel;

0 commit comments

Comments
 (0)