mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-19 13:32:21 +02:00
feat(modem): Added support for at_raw() command
at_raw() sends raw string and supports custom pass/fail phrases for the API to return OK/FAIL. It also returns raw, unprocessed string as output. This allows sending custom requests, such as: * dce->at_raw("", resp, "RDY", "...", 20000) -- waiting for reset * esp_modem_at_raw(dce, "+++", resp, "DISCONNECTED", "ERROR", 5000) -- exits PPP mode Closes https://github.com/espressif/esp-protocols/issues/471 Partially addresses https://github.com/espressif/esp-protocols/issues/468
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -394,6 +394,22 @@ command_result at(CommandableIf *t, const std::string &cmd, std::string &out, in
|
||||
return generic_get_string(t, at_command, out, timeout);
|
||||
}
|
||||
|
||||
command_result at_raw(CommandableIf *t, const std::string &cmd, std::string &out, const std::string &pass, const std::string &fail, int timeout = 500)
|
||||
{
|
||||
ESP_LOGV(TAG, "%s", __func__ );
|
||||
return t->command(cmd, [&](uint8_t *data, size_t len) {
|
||||
out.assign(reinterpret_cast<char *>(data), len);
|
||||
|
||||
if (out.find(pass) != std::string::npos) {
|
||||
return command_result::OK;
|
||||
} else if (out.find(fail) != std::string::npos) {
|
||||
return command_result::FAIL;
|
||||
}
|
||||
|
||||
return command_result::TIMEOUT;
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
command_result get_signal_quality(CommandableIf *t, int &rssi, int &ber)
|
||||
{
|
||||
ESP_LOGV(TAG, "%s", __func__ );
|
||||
|
Reference in New Issue
Block a user