Skip to content

Commit

Permalink
Add fast retry on communication failures
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstoer committed Nov 1, 2019
1 parent 2538cb4 commit 5bd1a6e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions EspaperClient/EspaperParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ EspaperParser::ResourceResponse EspaperParser::getAndDrawScreen(String requestPa
gfx->init();
gfx->fillBuffer(1);


if (response.httpCode == 200) {
gfx->drawPalettedBitmapFromFile(0, 0, "/screen");
} else {
Expand All @@ -151,12 +150,16 @@ EspaperParser::ResourceResponse EspaperParser::getAndDrawScreen(String requestPa

String message = "";
switch(response.httpCode) {
case -2: message = String(F("Connection to the server could not be established. Verify this device has access to the internet."));
case -2: message = String(F("Connection to the server could not be established or it timed out. Verify this device has access to the internet. Will retry in 1min."));
response.sleepSeconds = 60;
response.sleepUntilEpoch = 60; // anything beyond 0 is ok, see startDeviceSleep() in sketch
break;
// TODO: "Starting registration process." is not correct, this parser can't possibly know that...
case 410: message = String(F("This device is unknown to the server. It might have been deleted. Starting registration process."));
break;
default: message = String(F("Error communicating with the server. HTTP status: ")) + String(response.httpCode);
default: message = String(F("Error communicating with the server. HTTP status: ")) + String(response.httpCode) + ". Will retry in 1min.";
response.sleepSeconds = 60;
response.sleepUntilEpoch = 60; // anything beyond 0 is ok, see startDeviceSleep() in sketch
break;
}

Expand Down

0 comments on commit 5bd1a6e

Please sign in to comment.