witnessmenow / Universal-Arduino-Telegram-Bot

Use Telegram on your Arduino (ESP8266 or Wifi-101 boards)
MIT License
1.09k stars 302 forks source link

Infinite loop on wifi.disconnect() #246

Closed PCov3r closed 3 years ago

PCov3r commented 3 years ago

Hi everyone,

I made a small security bot using this library and an ESP32-cam. I added the autoconnect library to choose between multiple wifi AP. To trigger it, I added a /reset command. Basically, when the bot receives it, I disconnect from wifi using Wifi.disconnect() and then reboot the ESP using ESP.restart().

Once the bot receive the command, it does everything it is supposed to do, but as soon as I reconnect, it get stuck in a infinite loop, getting the /reset command over and over again. Thus making it disconnect over and over.

Has anyone faced a similar issue? Thanks

PCov3r commented 3 years ago

Solved the problem.

For anyone facing the same issue, it might be because you don't give enough time for processing. I fixed it by using flags. When the command is being received, a flag is set on, and then it get processed in the loop, setting off the flag.