Skip to content

Commit

Permalink
bring echo functionality on slm
Browse files Browse the repository at this point in the history
  • Loading branch information
TaeZStkyoht committed Nov 14, 2024
1 parent 27bf358 commit b3870b1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions applications/serial_lte_modem/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
14 changes: 13 additions & 1 deletion applications/serial_lte_modem/src/slm_at_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -705,6 +705,18 @@ 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) {
static const uint8_t clear_line_cmd[] = "\33[2K\r"; /* VT100 Clear line escape sequence */
at_backend.send(clear_line_cmd, sizeof(clear_line_cmd));
for (size_t i = 0; i < at_cmd_len; ++i)
if (slm_at_buf[i] == '\r')
at_backend.send("\r\n", 2);
else
at_backend.send(slm_at_buf + i, 1);
}
#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);
Expand Down

0 comments on commit b3870b1

Please sign in to comment.