J-M-L:
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\norIRON\rLIKE\norROLLNECK\r\nbasically 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
Oops. Does this not fix the issue?:
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<cr><lf>\" termination string");
found = true;
}
}
else
{
index = 0;
}
}
return found;
}