I am trying to write a function to return true if the ESP8266 is connected to a Wifi network and false if it isn't.
I am using software serial on an Arduino Nano
my initial idea was something like this (forgive if there are some small differences, dont have the ability to C+P just now):
boolean ConnTest()
{
String received;
ESP.print("AT+CWJAP?\r\n");
while (ESP.available())
{
char c = ESP.read();
received += c;
if (c == '\n')
{
Serial.println (received);
}
if (received == "ERROR")
{ return false }
else
{return true}
}
}
the last part was a little different, to do with parsing the string and checking if it came back with the connected response (dont remember it off the top of my head), but what I am really looking for is a way to query the ESP and react according to its response but no matter what I do I cannot get the correct response back.
I've been searching for days with no luck so any help would be appreciated.
Thank you,