0

I am doing code of esp while switching hotspot for connecting esp i am getting some problem . I am using this line of code:

while ((!esp.find("WIFI ")) || (!esp.find("+CWJAP:3")));

but it is not working. Anybody please give me alternate how to use this type of looping.

  • 1
    What exactly is "not working". Can you explain? Otherwise it is hard, if not impossible, to help. – MichaelT Jun 15 '19 at 11:55
1

The find method reads the characters until the searched string is found or a timeout interval is passed.

In your case if the connection is not successful, the first find will not find "WIFI" and will read all the input including the "+CWJAP:3", then on timeout it returns false. The second find will wait until timeout and then return false.

  • so what i can do i have to wait until WIFI or +CWJAP=3 is come on serial monitor – Anuj goyal Jun 15 '19 at 11:04
  • read the lines returned by AT firmware into a buffer and compare the content of the buffer with expected strings. or use the WiFiEsp library, which handles the AT commands and responses for you – Juraj Jun 15 '19 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.