FW v3 TWEEKS

This commit is contained in:
JonatanRek 2019-11-26 13:56:06 +01:00
parent 3e71be821c
commit 9e6968bf6c

View File

@ -8,6 +8,7 @@ const char* ssid = "";
const char* pasw = "";
const char* hwId = "";
const char* url = "http://dev.steelants.cz/vasek/home/api.php";
int unsuccessfulRounds = 0;
//Pins
#define pinDHT 4
@ -68,12 +69,26 @@ void loop() {
//configuration setup
String hostName = doc["device"]["hostname"];
int sleepTime = doc["device"]["sleepTime"];
String state = doc["state"];
if (state != "succes") {
unsuccessfulRounds++;
Serial.println("UNSUCCESSFUL ROUND NUMBER " + unsuccessfulRounds + "FROM 5");
} else if (state == "succes") {
unsuccessfulRounds = 0;
}
WiFi.hostname(hostName);
http.end(); //Close connection
Serial.println("DISCONECTED FROM WIFI");
WiFi.disconnect();
if(unsuccessfulRounds == 5) {
Serial.println("RESTARTING ESP");
ESP.restart()
}
Serial.println("GOING TO SLEEP FOR " + String(sleepTime));
if (sleepTime > 0) {
ESP.deepSleep((sleepTime * 60) * 1000000, RF_DEFAULT);