Skip to content

Commit 3b23537

Browse files
committed
app: Add command to start CMUX traces on any CMUX channel
Add AT#XCMUXTRACE command to start CMUX modem traces on a specified channel. This is required when using AT+CMUX which does not do hard coded channel assignments. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent acea556 commit 3b23537

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

app/src/sm_cmux.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,44 @@ static int handle_at_cmux(enum at_parser_cmd_type cmd_type, struct at_parser *pa
403403
return -EINVAL;
404404
}
405405
}
406+
407+
#if CONFIG_SM_MODEM_TRACE_BACKEND_CMUX
408+
409+
SM_AT_CMD_CUSTOM(xcmuxtrace, "AT#XCMUXTRACE", handle_at_xcmuxtrace);
410+
static int handle_at_xcmuxtrace(enum at_parser_cmd_type cmd_type, struct at_parser *parser,
411+
uint32_t param_count)
412+
{
413+
struct modem_pipe *pipe;
414+
415+
if (cmd_type == AT_PARSER_CMD_TYPE_TEST) {
416+
rsp_send("\r\n#XCMUXTRACE: (1 ... %d)\r\n", CONFIG_SM_CMUX_CHANNEL_COUNT);
417+
return 0;
418+
}
419+
if (cmd_type != AT_PARSER_CMD_TYPE_SET || param_count > 2) {
420+
return -EINVAL;
421+
}
422+
423+
if (param_count == 2) {
424+
int ch;
425+
int ret = at_parser_num_get(parser, 1, &ch);
426+
427+
if (ret || (ch < 2 || ch >= CONFIG_SM_CMUX_CHANNEL_COUNT)) {
428+
return -EINVAL;
429+
}
430+
pipe = sm_cmux_get_dlci(ch);
431+
} else {
432+
pipe = sm_at_host_get_current_pipe();
433+
}
434+
435+
if (!pipe) {
436+
return -ENODEV;
437+
}
438+
rsp_send_ok();
439+
sm_trace_backend_detach();
440+
sm_at_host_release(sm_at_host_get_ctx_from(pipe));
441+
sm_trace_backend_attach(pipe);
442+
443+
return -SILENT_AT_COMMAND_RET;
444+
}
445+
446+
#endif

0 commit comments

Comments
 (0)