From d3cec5d3b43d6ad4d85977f3e59307b838935ddd Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 22 Mar 2020 08:14:03 +0100 Subject: [PATCH] [Module] Removed String class from AT commands --- src/Module.cpp | 11 ++++++----- src/Module.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index 7a714d85..06213b55 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -137,19 +137,20 @@ bool Module::ATsendData(uint8_t* data, uint32_t len) { } bool Module::ATgetResponse() { - String data = ""; + char data[128]; + char* dataPtr = data; uint32_t start = millis(); - while (millis() - start < _ATtimeout) { + while(millis() - start < _ATtimeout) { while(ModuleSerial->available() > 0) { char c = ModuleSerial->read(); RADIOLIB_VERBOSE_PRINT(c); - data += c; + *dataPtr++ = c; } - if(data.indexOf("OK") != -1) { + if(strstr(data, "OK") == 0) { RADIOLIB_VERBOSE_PRINTLN(); return(true); - } else if (data.indexOf("ERROR") != -1) { + } else if(strstr(data, "ERROR") == 0) { RADIOLIB_VERBOSE_PRINTLN(); return(false); } diff --git a/src/Module.h b/src/Module.h index ddc43c51..fd0b4e25 100644 --- a/src/Module.h +++ b/src/Module.h @@ -172,7 +172,7 @@ class Module { /*! \brief Get response after sending AT command. - \returns True if AT response contains the string "OK", false otehrwise. + \returns True if AT response contains the string "OK", false otherwise. */ bool ATgetResponse();