Skip to content

Commit 0e411d8

Browse files
committed
Improved EchoBot example. More readable.
1 parent 0fa8f0a commit 0e411d8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

examples/ESP8266/EchoBot/EchoBot.ino

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*******************************************************************
2-
* An example of bot that echos back any messages received *
3-
* *
4-
* written by Giacarlo Bacchio (Gianbacchio on Github) *
5-
* adapted by Brian Lough *
6-
*******************************************************************/
2+
* An example of bot that echos back any messages received *
3+
* *
4+
* written by Giacarlo Bacchio (Gianbacchio on Github) *
5+
* adapted by Brian Lough *
6+
*******************************************************************/
77
#include <ESP8266WiFi.h>
88
#include <WiFiClientSecure.h>
99
#include <UniversalTelegramBot.h>
@@ -22,7 +22,6 @@ int Bot_mtbs = 1000; //mean time between scan messages
2222
long Bot_lasttime; //last time messages' scan has been done
2323

2424
void setup() {
25-
2625
Serial.begin(115200);
2726

2827
// Set WiFi to station mode and disconnect from an AP if it was Previously
@@ -35,30 +34,30 @@ void setup() {
3534
Serial.print("Connecting Wifi: ");
3635
Serial.println(ssid);
3736
WiFi.begin(ssid, password);
37+
3838
while (WiFi.status() != WL_CONNECTED) {
3939
Serial.print(".");
4040
delay(500);
4141
}
42+
4243
Serial.println("");
4344
Serial.println("WiFi connected");
44-
Serial.println("IP address: ");
45-
IPAddress ip = WiFi.localIP();
46-
Serial.println(ip);
47-
48-
45+
Serial.print("IP address: ");
46+
Serial.println(WiFi.localIP());
4947
}
5048

5149
void loop() {
52-
5350
if (millis() > Bot_lasttime + Bot_mtbs) {
5451
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
52+
5553
while(numNewMessages) {
5654
Serial.println("got response");
57-
for(int i=0; i<numNewMessages; i++) {
55+
for (int i=0; i<numNewMessages; i++) {
5856
bot.sendMessage(bot.messages[i].chat_id, bot.messages[i].text, "");
5957
}
6058
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
6159
}
60+
6261
Bot_lasttime = millis();
6362
}
6463
}

0 commit comments

Comments
 (0)