Problemi gestione messaggi Telegram
Posted: Thu Mar 18, 2021 8:07 am
Buongiorno @cicciocb volevo segnalarti un problema con la gestione dei messaggi verso Telegram.
Ho utilizzato il tuo ottimo programma, inserendolo nel mio sistema e la gestione dei messaggi funzionava bene.
Poco dopo pero' ho cominciato ad avere dei problemi, frequentemente il sistema si riavviava (codice roboot 12).
Ho pensato che per qulche ragione questa nuova parte "litigasse" con il mio codice ma non trovando niente di strano ho provato a caricare il tuo programma (che riporto qui')
in un altro ESP32 (Annex32 WiFi 1.43.2 CAN BLE) e l'ho lasciato girare per tutta la notte e ho scoperto che anche questo si riavviava fequentemente.
Per darti un idea dalle 21 di ieri alle 6 di stamattina si e' riavviato circa 20 volte.
Per il resto come ho detto la gestione dei messaggi funziona bene.
Grazie
Fabrizio
'Telegram example on how receive messages from Telegram
'Simple Echo demo: Reply with the message received
'requires the BOT TOKEN
BOT_TOKEN$ = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
CHAT_ID$ = "yyyyyyyy"
tx$ = wget$("https://api.telegram.org/bot" + BOT_TOKEN$ + "/sendMessage?chat_id=" + CHAT_ID$ + "&text=" + "Riavvio Software")
onwgetasync asynco
timer0 5000, check_telegram
next_id$ = ""
'simulate program activity
z = 0
while 1
wlog z
z = z + 1
pause 10000
wend
wait
check_telegram:
wgetasync "https://api.telegram.org/bot" + BOT_TOKEN$ + "/getUpdates?offset=" + next_id$
return
asynco:
b$ = WGETRESULT$
msg$ = json$(b$, "message.text")
if (msg$ <> "not found") then
id$ = json$(b$, "update_id")
next_id$ = trim$(str$(val(id$) + 1, "%11.0f")) ' set the id for the next message
CHAT_ID$ = json$(b$, "chat.id")
wlog "Message : "; msg$
wlog "Chat ID : "; CHAT_ID$
wlog "From :"; json$(b$, "username")
'Reply message
msg$ = "You sent me: " + msg$
wlog wget$("https://api.telegram.org/bot" + BOT_TOKEN$ + "/sendMessage?chat_id=" + CHAT_ID$ + "&text=" + msg$)
end if
return
Ho utilizzato il tuo ottimo programma, inserendolo nel mio sistema e la gestione dei messaggi funzionava bene.
Poco dopo pero' ho cominciato ad avere dei problemi, frequentemente il sistema si riavviava (codice roboot 12).
Ho pensato che per qulche ragione questa nuova parte "litigasse" con il mio codice ma non trovando niente di strano ho provato a caricare il tuo programma (che riporto qui')
in un altro ESP32 (Annex32 WiFi 1.43.2 CAN BLE) e l'ho lasciato girare per tutta la notte e ho scoperto che anche questo si riavviava fequentemente.
Per darti un idea dalle 21 di ieri alle 6 di stamattina si e' riavviato circa 20 volte.
Per il resto come ho detto la gestione dei messaggi funziona bene.
Grazie
Fabrizio
'Telegram example on how receive messages from Telegram
'Simple Echo demo: Reply with the message received
'requires the BOT TOKEN
BOT_TOKEN$ = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
CHAT_ID$ = "yyyyyyyy"
tx$ = wget$("https://api.telegram.org/bot" + BOT_TOKEN$ + "/sendMessage?chat_id=" + CHAT_ID$ + "&text=" + "Riavvio Software")
onwgetasync asynco
timer0 5000, check_telegram
next_id$ = ""
'simulate program activity
z = 0
while 1
wlog z
z = z + 1
pause 10000
wend
wait
check_telegram:
wgetasync "https://api.telegram.org/bot" + BOT_TOKEN$ + "/getUpdates?offset=" + next_id$
return
asynco:
b$ = WGETRESULT$
msg$ = json$(b$, "message.text")
if (msg$ <> "not found") then
id$ = json$(b$, "update_id")
next_id$ = trim$(str$(val(id$) + 1, "%11.0f")) ' set the id for the next message
CHAT_ID$ = json$(b$, "chat.id")
wlog "Message : "; msg$
wlog "Chat ID : "; CHAT_ID$
wlog "From :"; json$(b$, "username")
'Reply message
msg$ = "You sent me: " + msg$
wlog wget$("https://api.telegram.org/bot" + BOT_TOKEN$ + "/sendMessage?chat_id=" + CHAT_ID$ + "&text=" + msg$)
end if
return