From 2411474cf21023d42b7245967e676a9794656b1b Mon Sep 17 00:00:00 2001 From: TaeZStkyoht Date: Tue, 12 Nov 2024 16:52:44 +0100 Subject: [PATCH] bring echo functionality on slm --- applications/serial_lte_modem/Kconfig | 6 ++++++ applications/serial_lte_modem/src/slm_at_host.c | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/applications/serial_lte_modem/Kconfig b/applications/serial_lte_modem/Kconfig index 318eaa984761..2812e09d4ca1 100644 --- a/applications/serial_lte_modem/Kconfig +++ b/applications/serial_lte_modem/Kconfig @@ -68,6 +68,12 @@ config SLM_UART_TX_BUF_SIZE help Amount of UART traffic waiting to be sent (TX), that can be held. If the buffers are full, will send synchronously. +config SLM_UART_ECHO + bool "Set echo status of UART" + default n + help + Echo the string which is typed + # # GPIO functionality # diff --git a/applications/serial_lte_modem/src/slm_at_host.c b/applications/serial_lte_modem/src/slm_at_host.c index e395a5bd06bf..4ecfe85fb1e3 100644 --- a/applications/serial_lte_modem/src/slm_at_host.c +++ b/applications/serial_lte_modem/src/slm_at_host.c @@ -42,6 +42,7 @@ static int datamode_handler_result; uint16_t slm_datamode_time_limit; /* Send trigger by time in data mode */ K_MUTEX_DEFINE(mutex_mode); /* Protects the operation mode variables. */ +static size_t at_cmd_len; uint8_t slm_at_buf[SLM_AT_MAX_CMD_LEN + 1]; uint8_t slm_data_buf[SLM_MAX_MESSAGE_SIZE]; @@ -569,7 +570,6 @@ static size_t cmd_rx_handler(const uint8_t *buf, const size_t len) { size_t processed; static bool inside_quotes; - static size_t at_cmd_len; static uint8_t prev_character; bool send = false; @@ -705,6 +705,14 @@ void slm_at_receive(const uint8_t *buf, size_t len) len -= ret; } +#if defined(CONFIG_SLM_UART_ECHO) + if (get_slm_mode() == SLM_AT_COMMAND_MODE && at_backend.send) { + const uint8_t clear_line_cmd[] = "\33[2K\r"; /* VT100 Clear line escape sequence */ + at_backend.send(clear_line_cmd, sizeof(clear_line_cmd)); + at_backend.send(slm_at_buf, at_cmd_len); + } +#endif + /* start inactivity timer in datamode */ if (get_slm_mode() == SLM_DATA_MODE) { k_timer_start(&inactivity_timer, K_MSEC(slm_datamode_time_limit), K_NO_WAIT);