Skip to content

Commit

Permalink
Tweak updates
Browse files Browse the repository at this point in the history
  • Loading branch information
revk committed May 27, 2023
1 parent 063e145 commit 37c7547
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions revk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ task (void *pvParameters)
int64_t tick = 0;
uint32_t ota_check = 0;
if (otaauto)
ota_check = 3600 + (esp_random () % (86400 * otaauto));
ota_check = 3600 + (esp_random () % 3600); // Check at start anyway, but allow an hour anyway
while (1)
{ /* Idle */
{ // Fast (once per 100ms)
Expand Down Expand Up @@ -1435,11 +1435,11 @@ task (void *pvParameters)
time_t t = time (0);
struct tm tm = { 0 };
localtime_r (&t, &tm);
if (tm.tm_hour >= 6)
ota_check = now + (esp_random () % 21600); // Try later, ideally middle of the night
if (now > 7200 && tm.tm_hour >= 6)
ota_check = now + (esp_random () % 21600); // A periodic check should be in the middle of the night, so wait a bit more (<7200 is startup check)
else
{ // Do a check
ota_check = now + 86400 * otaauto - 43200 + (esp_random () % 86400); // Next check
ota_check = now + 86400 * otaauto - 43200 + (esp_random () % 86400); // Next check approx otaauto days later
#ifdef CONFIG_REVK_MESH
if (esp_mesh_is_root ())
#endif
Expand Down

0 comments on commit 37c7547

Please sign in to comment.