shurillu / CTBot

A simple (and easy to use) Arduino Telegram BOT Library for ESP8266/ESP32
MIT License
147 stars 34 forks source link

reconnection when internet is restored #104

Closed mjtrini closed 1 year ago

mjtrini commented 1 year ago

Hello my friend,

Greetings again! I noticed when internet service is lost (we have occasional power blackouts from our utility) and then restored, I have to manually reboot (or power cycle) my esp8266 that controls my gate with CTBot. The bot won't respond to commands from the chat buttons when internet is restored until I manually reboot or power cycle the esp8266. I have been forced to set a timer in the sketch to restart the esp8266 every 30 minutes just to be on the safe side. My gate motor and the embedded esp8266 is powered via my home off-grid solar system so there is always power to the esp8266 and network infrastructure in my home. Is there a command to make the CTBot reconnect every x minutes (without restarting the entire esp8266) to ensure reliability with my gate control anytime internet is lost then restored?

Much thanks, Michael.

mjtrini commented 1 year ago

Hi Stefano,

I figured it out! In void loop and inserted this snippet:

if (myBot.testConnection()) {Serial.println("\nTelegram OK");} else {Serial.println("\nTelegram not OK"); myBot.setTelegramToken(token);}

Much respect and admiration, Michael.