Skip to content

Commit

Permalink
Properly initialize sleep seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstoer committed Nov 1, 2019
1 parent 2f13aa3 commit d933273
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion EspaperClient/EspaperClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void startDeviceSleep(uint32_t sleepSeconds, uint32_t sleepUntilEpoch) {
Board.deepSleep(effectiveSleepSeconds);
}

EspaperParser::ResourceResponse fetchAndDrawScreen(EspaperParser *parser, DeviceData *deviceData) {
EspaperParser::ResourceResponse fetchAndDrawScreen(EspaperParser *parser, DeviceData *deviceData) {
EspaperParser::ResourceResponse response = parser->getAndDrawScreen(SERVER_API_DEVICES_PATH + "/" + DEVICE_ID + "/screen", buildOptionalHeaderFields(deviceData), &BoardClass::sleepWifi);
if (response.httpCode == 410) {
saveDeviceRegistration("", "");
Expand Down Expand Up @@ -256,6 +256,11 @@ void setup() {
Serial.printf_P(PSTR("\n\n***Time before connecting to WiFi %d\n"), millis());
boolean success = Board.connectWifi(WIFI_SSID, WIFI_PASS);
EspaperParser::ResourceResponse response;
// Initialize to restarting in 60s, comes into effect if WiFi or NTP connect fails (server cannot
// deliver an effective value). In that case we probably want a fast retry rather than e.g. waiting
// for the default 20min or so.
response.sleepSeconds = 60;
response.sleepUntilEpoch = 60;
if (success) {
delay(200);
boolean timeInit = initTime();
Expand Down

0 comments on commit d933273

Please sign in to comment.