I\'m sending AT commands to an ESP8266 from an Arduino Uno/Nano (ATmega328) and attempting to parse the end of the strings received in response to establish how the ESP reac
Your if
after the while
is indeed wrong because you might have read more stuff back and thus you don't end with the target string even though "ok" was received.
You should just test if responseBuffer ends with target and return true only when you receive a new character in the while
loop and not after.
After you have a timeout, just return false.