blynk.connect(timeout), timeout not working correct in 0.4.10.
Test code below:
#include <Wire.h>
#include <TimeLib.h>
#include <TimeLib.h>
int secTimer;
bool secFlag;
int minTimersec;
bool minFlag;
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
unsigned int myEthernetTimeout = 500;
bool EthernetConnected;
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#define BLYNK_AUTH "############"
#include <BlynkSimpleEthernet.h>
#include <WidgetRTC.h>
long blynkInterval = 600000;
bool isFirstConnect = true;
BlynkTimer timer;
WidgetRTC rtc;
void setup(){
Serial.begin(115200);
// Инициируем Ethernet
if (Ethernet.begin(mac) == 0) {
Serial.println("Ethernet fail");
EthernetConnected=false;
}
else {
EthernetConnected=true;
}
if (EthernetConnected){
Blynk.config(BLYNK_AUTH);
reconnectBlynk();
timer.setInterval(blynkInterval, reconnectBlynk);
}
timer.setInterval(50, QuickInt);
}
void loop(){
if(Blynk.connected()){
Blynk.run();
}
timer.run();
if (secFlag){
secFunc();
}
if (minFlag){
minFunc();
}
}
void reconnectBlynk() {
unsigned long startConnecting = millis();
while(!Blynk.connected()){
BLYNK_LOG("Try to connect to server");
Blynk.connect(4333);
if(millis() > startConnecting + myEthernetTimeout){
BLYNK_LOG("Unable to connect to server.");
Blynk.disconnect();
break;
}
}
}
void QuickInt(){
if (secTimer<1000){secTimer+=50;}
else {secTimer=0;secFlag=true;}
}
void secFunc()
{
secFlag=false;
if (minTimersec<60){minTimersec++;}
else {minTimersec=0;minFlag=true;}
String currentTime = String(hour()) + ":" + minute() + ":" + second();
String currentDate = String(day()) + "." +month() + "." + year();
Serial.println(currentTime);
}
void minFunc(){
minFlag=false;
}
and on any setting timeout in Blynk.connect(???) I see a same log:
[8541]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.10 on Arduino Mega
[8548] Free RAM: 7082
[8550] Try to connect to server
[8552] Connecting to blynk-cloud.com:8442
[40522] Unable to connect to server.
[40522] Disconnected
0:0:41
0:0:42
0:0:43
...
0:10:37
0:10:39
0:10:40
[640523] Try to connect to server
[640523] Connecting to blynk-cloud.com:8442
[672490] Unable to connect to server.
[672491] Disconnected
0:11:12
0:11:12
0:11:12
if i block Blynk on firewall for simulation of Internet connection down.
My controller is Mega2560 and w5100 Ethernet shield