dont try to sync if wifi is disconnected (just because whats the point really)
This commit is contained in:
parent
6a9976868b
commit
33db93deed
1 changed files with 31 additions and 30 deletions
51
src/main.cpp
51
src/main.cpp
|
@ -320,36 +320,37 @@ void handleData1Interrupt() {
|
||||||
#endif
|
#endif
|
||||||
vTaskDelay(pdMS_TO_TICKS(15000)); // Delay for 15 seconds
|
vTaskDelay(pdMS_TO_TICKS(15000)); // Delay for 15 seconds
|
||||||
|
|
||||||
Tinance2HttpClient httpClient;
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
std::pair<String, int> responsePair = httpClient.sendHttpRequest(tinance2_url_readerinfo, "GET", "");
|
Tinance2HttpClient httpClient;
|
||||||
String response = responsePair.first;
|
std::pair<String, int> responsePair = httpClient.sendHttpRequest(tinance2_url_readerinfo, "GET", "");
|
||||||
int httpResponseCode = responsePair.second;
|
String response = responsePair.first;
|
||||||
|
int httpResponseCode = responsePair.second;
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUG
|
|
||||||
// Print the response
|
|
||||||
Serial.println("HTTP Response: " + response);
|
|
||||||
Serial.println("HTTP Response Code: " + String(httpResponseCode));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Process the response
|
|
||||||
DynamicJsonDocument json = httpClient.decodeJsonResponse(response);
|
|
||||||
|
|
||||||
if (json.containsKey("enabled")) {
|
|
||||||
bool DisableDoor = json["enabled"].as<bool>();
|
|
||||||
settings.setDisableDoor(!DisableDoor);
|
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
Serial.println("JSON Reader Enabled: " + json["enabled"].as<String>());
|
// Print the response
|
||||||
|
Serial.println("HTTP Response: " + response);
|
||||||
|
Serial.println("HTTP Response Code: " + String(httpResponseCode));
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
if (json.containsKey("mode")) {
|
// Process the response
|
||||||
String doorMode = json["mode"].as<String>();
|
DynamicJsonDocument json = httpClient.decodeJsonResponse(response);
|
||||||
settings.setDoorMode(doorMode);
|
|
||||||
#ifdef SERIAL_DEBUG
|
|
||||||
Serial.println("JSON Reader Mode: " + json["mode"].as<String>());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (json.containsKey("enabled")) {
|
||||||
|
bool DisableDoor = json["enabled"].as<bool>();
|
||||||
|
settings.setDisableDoor(!DisableDoor);
|
||||||
|
#ifdef SERIAL_DEBUG
|
||||||
|
Serial.println("JSON Reader Enabled: " + json["enabled"].as<String>());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json.containsKey("mode")) {
|
||||||
|
String doorMode = json["mode"].as<String>();
|
||||||
|
settings.setDoorMode(doorMode);
|
||||||
|
#ifdef SERIAL_DEBUG
|
||||||
|
Serial.println("JSON Reader Mode: " + json["mode"].as<String>());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue