MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / contentRunner

Function contentRunner

ESP32_AP-Flasher/src/contentmanager.cpp:53–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void contentRunner() {
54 if (config.runStatus == RUNSTATUS_STOP) return;
55
56 time_t now;
57 time(&now);
58 uint8_t wifimac[8];
59 WiFi.macAddress(wifimac);
60 memset(&wifimac[6], 0, 2);
61
62 for (tagRecord *taginfo : tagDB) {
63
64 const bool isAp = memcmp(taginfo->mac, wifimac, 8) == 0;
65 if (taginfo->RSSI &&
66 (now >= taginfo->nextupdate || needRedraw(taginfo->contentMode, taginfo->wakeupReason)) &&
67 config.runStatus == RUNSTATUS_RUN &&
68 (taginfo->expectedNextCheckin < now + 300 || isAp || (wsClientCount() && config.stopsleep == 1)) &&
69 Storage.freeSpace() > 31000 && !util::isSleeping(config.sleepTime1, config.sleepTime2)) {
70 drawNew(taginfo->mac, taginfo);
71 taginfo->wakeupReason = 0;
72 }
73
74 if (taginfo->expectedNextCheckin > now - 10 && taginfo->expectedNextCheckin < now + 30 && taginfo->pendingIdle == 0 && taginfo->pendingCount == 0 && !isAp) {
75 int32_t minutesUntilNextUpdate = (taginfo->nextupdate - now) / 60;
76 if (minutesUntilNextUpdate > config.maxsleep) {
77 minutesUntilNextUpdate = config.maxsleep;
78 }
79 if (util::isSleeping(config.sleepTime1, config.sleepTime2)) {
80 struct tm timeinfo;
81 getLocalTime(&timeinfo);
82 struct tm nextSleepTimeinfo = timeinfo;
83 nextSleepTimeinfo.tm_hour = config.sleepTime2;
84 nextSleepTimeinfo.tm_min = 0;
85 nextSleepTimeinfo.tm_sec = 0;
86 time_t nextWakeTime = mktime(&nextSleepTimeinfo);
87 if (nextWakeTime < now) nextWakeTime += 24 * 3600;
88 minutesUntilNextUpdate = (nextWakeTime - now) / 60 - 2;
89 }
90 if (minutesUntilNextUpdate > 1 && (wsClientCount() == 0 || config.stopsleep == 0)) {
91 taginfo->pendingIdle = minutesUntilNextUpdate * 60;
92 taginfo->expectedNextCheckin = now + taginfo->pendingIdle;
93 if (taginfo->isExternal == false) {
94 prepareIdleReq(taginfo->mac, minutesUntilNextUpdate);
95 }
96 }
97 }
98
99 vTaskDelay(1 / portTICK_PERIOD_MS); // add a small delay to allow other threads to run
100 }
101}
102
103void checkVars() {
104 JsonDocument cfgobj;

Callers 1

loopFunction · 0.85

Calls 8

memsetFunction · 0.85
memcmpFunction · 0.85
needRedrawFunction · 0.85
wsClientCountFunction · 0.85
isSleepingFunction · 0.85
drawNewFunction · 0.85
prepareIdleReqFunction · 0.85
freeSpaceMethod · 0.45

Tested by

no test coverage detected