mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-18 13:02:21 +02:00
C API cleanup, add SMS support
This commit is contained in:
@ -26,7 +26,7 @@ DTE::DTE(std::unique_ptr<Terminal> terminal):
|
||||
term(std::move(terminal)), command_term(term.get()), other_term(nullptr),
|
||||
mode(modem_mode::UNDEF) {}
|
||||
|
||||
command_result DTE::command(const std::string &command, got_line_cb got_line, uint32_t time_ms)
|
||||
command_result DTE::command(const std::string &command, got_line_cb got_line, uint32_t time_ms, const char separator)
|
||||
{
|
||||
Scoped<Lock> l(lock);
|
||||
command_result res = command_result::TIMEOUT;
|
||||
@ -37,7 +37,7 @@ command_result DTE::command(const std::string &command, got_line_cb got_line, ui
|
||||
len = command_term->read(data, data_to_read);
|
||||
}
|
||||
consumed += len;
|
||||
if (memchr(data, '\n', len)) {
|
||||
if (memchr(data, separator, len)) {
|
||||
res = got_line(data, consumed);
|
||||
if (res == command_result::OK || res == command_result::FAIL) {
|
||||
signal.set(GOT_LINE);
|
||||
@ -65,4 +65,9 @@ void DTE::setup_cmux()
|
||||
term = std::make_unique<CMuxInstance>(cmux_term, 0);
|
||||
command_term = term.get(); // use command terminal as previously
|
||||
other_term = std::make_unique<CMuxInstance>(cmux_term, 1);
|
||||
}
|
||||
}
|
||||
|
||||
command_result DTE::command(const std::string &cmd, got_line_cb got_line, uint32_t time_ms)
|
||||
{
|
||||
return command(cmd, got_line, time_ms, '\n');
|
||||
}
|
||||
|
Reference in New Issue
Block a user