Skip to content

Commit

Permalink
Adaptations for ESP8266 for last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gskjold committed Mar 30, 2022
1 parent 15fa452 commit 811625b
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions src/entsoe/EntsoeApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,39 +194,42 @@ bool EntsoeApi::retrieve(const char* url, Stream* doc) {
https.setReuse(false);
https.setTimeout(50000);
https.setUserAgent("ams2mqtt/" + String(VERSION));
if(https.begin(url)) {
printD("Connection established");
#if defined(ESP32)
if(https.begin(url)) {
printD("Connection established");

#if defined(ESP32)
esp_task_wdt_reset();
#elif defined(ESP8266)
ESP.wdtFeed();
#endif
#if defined(ESP32)
esp_task_wdt_reset();
#elif defined(ESP8266)
ESP.wdtFeed();
#endif

int status = https.GET();
int status = https.GET();

#if defined(ESP32)
esp_task_wdt_reset();
#elif defined(ESP8266)
ESP.wdtFeed();
#endif
#if defined(ESP32)
esp_task_wdt_reset();
#elif defined(ESP8266)
ESP.wdtFeed();
#endif

if(status == HTTP_CODE_OK) {
printD("Receiving data");
https.writeToStream(doc);
https.end();
return true;
} else {
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("(EntsoeApi) Communication error, returned status: %d\n", status);
printE(https.errorToString(status));
printD(https.getString());
if(status == HTTP_CODE_OK) {
printD("Receiving data");
https.writeToStream(doc);
https.end();
return true;
} else {
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("(EntsoeApi) Communication error, returned status: %d\n", status);
printE(https.errorToString(status));
printD(https.getString());

https.end();
https.end();
return false;
}
} else {
return false;
}
} else {
return false;
}
#endif
return false;
}

float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to) {
Expand Down

0 comments on commit 811625b

Please sign in to comment.