Skip to content

Commit 8d820cd

Browse files
author
zlpa
committed
feat(modem): execution of AT command in raw mode
Regular `cmd` function does not return the entire reply of the given AT command that is problematic for some use cases, e.g., quering GNSS data in CMUX mode. So, lets introduce `cmd_raw` call that, assuming correct CMUX behaviour, returns entire reply of the given AT command.
1 parent 4eff7f9 commit 8d820cd

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

libraries/PPP/src/PPP.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,18 @@ String PPPClass::cmd(const char *at_command, int timeout) {
747747
return String(out);
748748
}
749749

750+
String PPPClass::cmd_raw(const char *at_command, int timeout) {
751+
PPP_CMD_MODE_CHECK(String());
752+
753+
char out[CONFIG_ESP_MODEM_C_API_STR_MAX] = {0};
754+
esp_err_t err = _esp_modem_at_raw(_dce, at_command, out, "OK", "ERROR", timeout);
755+
if (err != ESP_OK) {
756+
log_e("esp_modem_at failed %d %s", err, esp_err_to_name(err));
757+
return String();
758+
}
759+
return String(out);
760+
}
761+
750762
size_t PPPClass::printDriverInfo(Print &out) const {
751763
size_t bytes = 0;
752764
if (_dce == NULL || _mode == ESP_MODEM_MODE_DATA) {

libraries/PPP/src/PPP.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ class PPPClass : public NetworkInterface {
7878
return cmd(at_command.c_str(), timeout);
7979
}
8080

81+
// Send AT command in raw mode (doesn’t append ‘\r’ to command, returns everything) with timeout in milliseconds
82+
String cmd_raw(const char *at_command, int timeout);
83+
String cmd_raw(String at_command, int timeout) {
84+
return cmd_raw(at_command.c_str(), timeout);
85+
}
86+
8187
// untested
8288
bool powerDown();
8389
bool reset();

0 commit comments

Comments
 (0)