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();