aarg:
Here is a non-blocking AT response check I coded recently:boolean foundOK()
{
const char targetString[] = {'O', 'K', '\r', '\n'};
static byte index = 0;
boolean found = false;
while (Serial3.available() > 0)
{
c = Serial3.read();
Serial.write(c);
if (c == targetString[index])
{
index++;
if (index >= sizeof(targetString))
{
index = 0;
Serial.println("found "OK" termination string");
found = true;
}
}
}
return found;
}
This is « pretty weak code” ![]()
it probably does the job for AT commands in most cases but would say you got your correct response if I were to send something like ESP DEADLOCKED\r\n or IRON\rLIKE\n or ROLLNECK\r\n basically just needs to have the letters in the right order even if you have junk in between. If you want to be true to the ask, you need a buffer as long as what you are searching for