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
61
src/main.cpp
61
src/main.cpp
|
@ -319,37 +319,38 @@ void handleData1Interrupt() {
|
|||
Serial.println("Syncing Tinance2");
|
||||
#endif
|
||||
vTaskDelay(pdMS_TO_TICKS(15000)); // Delay for 15 seconds
|
||||
|
||||
Tinance2HttpClient httpClient;
|
||||
std::pair<String, int> responsePair = httpClient.sendHttpRequest(tinance2_url_readerinfo, "GET", "");
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
Tinance2HttpClient httpClient;
|
||||
std::pair<String, int> responsePair = httpClient.sendHttpRequest(tinance2_url_readerinfo, "GET", "");
|
||||
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
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue