witnessmenow / Universal-Arduino-Telegram-Bot

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

Is time sync really necessary ? #230

Open saikek opened 3 years ago

saikek commented 3 years ago

Hello, many of your examples contain this code snippet:

Serial.print("Retrieving time: ");
  configTime(0, 0, "pool.ntp.org"); // get UTC time via NTP
  time_t now = time(nullptr);
  while (now < 24 * 3600)
  {
    Serial.print(".");
    delay(100);
    now = time(nullptr);
  }
  Serial.println(now);

Is it really necessary for library to work?
I haven't found any references in you library that would require time.

anishsane commented 2 years ago

In the default code of esp8266 - InlineKeyboardMarkup example, the time sync is missing. This bot does not work. I copied the time sync from echobot. And then it started working. The time sync takes around 25-30 seconds on my setup. I tried just adding delay(30000), but that did not work. (My guess was it needed some extra time for some network-related initialization.) But it actually needs the time sync. However, I don't know why it is required. I am curious too.