Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring echo functionality on slm #18823

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this deal with backspace?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it clears the line before putting buffer on it.

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