Is there a way to get it faster?
void setup() {
Serial.begin(115200);
delay(10);
Serial.print("Battery: ");
Serial.println(ESP.getVcc());
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
if (reconnectCount >= 60) {
ESP.restart();
}
Serial.print(".");
reconnectCount++;
}
reconnectCount = 0;
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
connectToServer();
}
void loop() {
while (Serial.available() > 0) {
byte inChar = Serial.read();
//if (client.connected()) {
client.write(inChar);
/*
} else {
delay(500);
if (reconnectCount >= 60) {
ESP.restart();
}
Serial.println("Connection lost!");
Serial.println("Try to reconnect...");
connectToServer();
reconnectCount++;
}
*/
}
if (client.available()) {
char c = client.read();
Serial.print(c);
}
}
void connectToServer() {
Serial.print("connecting to ");
Serial.println(host);
const int httpPort = 21;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
}