Hi I've already read a tip to solve my problem here, but I'm not very experienced and can't apply it.
I load the botToken value from the EEPROM into the setup(). But I have to set the botToken value before executing the program.
The suggestion was to use update token method. I have implemented it as you can see in the setup(), void updateToken(String botToken);.
But that doesn't work, could you help me?
Thank you very much in advance
#include <ESP8266WiFi.h>
[...]
String defaultChatId;
String botToken;
WiFiClientSecure client;
UniversalTelegramBot bot(botToken, client);
[...]
void setup()
{
[...]
for (int i = 96; i < 160; ++i)
{
botToken += char(EEPROM.read(i));
}
Serial.print("TOKEN: ");
Serial.println(botToken);
botToken = botToken.c_str();
void updateToken(String botToken);
for (int i = 160; i < 176; ++i)
{
defaultChatId += char(EEPROM.read(i));
}
Serial.print("ChatId: ");
Serial.println(defaultChatId);
defaultChatId = defaultChatId.c_str();
[...]
}
void handleNewMessages(int numNewMessages) {
for (int i=0; i<numNewMessages; i++) {
[...]
}
}
void loop() {
if ((WiFi.status() == WL_CONNECTED))
{
long now = millis();
if(now >= checkTelegramDueTime) {
//Serial.println("---- Checking Telegram -----");
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
while(numNewMessages)
{
Serial.println("Bot recieved a message");
handleNewMessages(numNewMessages);
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
}
checkTelegramDueTime = now + checkTelegramDelay;
}
now = millis();
[...]
}
else {}
}
[...]```
Hi I've already read a tip to solve my problem here, but I'm not very experienced and can't apply it. I load the
botToken
value from the EEPROM into thesetup()
. But I have to set thebotToken
value before executing the program. The suggestion was to use update token method. I have implemented it as you can see in thesetup()
,void updateToken(String botToken);
. But that doesn't work, could you help me? Thank you very much in advance