Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void keeplive(){
- check=0;
- if((millis() - wifi_reconnect_time) > wifi_check_time){//se sono passati piu x secondi dall ultimo controllo
- DEBUG_PRINT("Controllo WiFi");
- smartDebug();
- wifi_reconnect_time = millis(); //questo รจ il tempo dell'ultimo controllo
- if(WiFi.isConnected()) {
- wifi_check_time = 15000L; //se sono connesso,controllo ogni 15 secondi che la connessione ci sia
- }else { //se non connesso cerca di connettere e collegarti a MQTT
- check=connectWiFi();
- delay(1000);
- }
- smartDelay(100);
- client.loop();
- if (client.connected()==0){ //MQTT non รจ collegato 0 = f
- //DEBUG_PRINT("MQTT KO!! " + String(client.connected()));
- mqtt_reconnect_tries++;
- smartDelay(100);
- connectMQTTmia();
- //resub();
- //reconnect();
- }
- else {
- mqtt_reconnect_tries=0; //se collegato azzero
- DEBUG_PRINT("MQTT OK!!");
- }
- if(mqtt_reconnect_tries > 3){
- wifi_check_time = 300000L;
- smartDelay(100);
- spegniChr();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement