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

Function drawNew

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

Source from the content-addressed store, hash-verified

157}
158
159void drawNew(const uint8_t mac[8], tagRecord *&taginfo) {
160 time_t now;
161 time(&now);
162
163 const HwType hwdata = getHwType(taginfo->hwType);
164 if (hwdata.bpp == 0) {
165 taginfo->nextupdate = now + 300;
166 Serial.println("No definition found for tag type " + String(taginfo->hwType));
167 return;
168 }
169
170 uint8_t wifimac[8];
171 WiFi.macAddress(wifimac);
172 memset(&wifimac[6], 0, 2);
173
174 const bool isAp = memcmp(mac, wifimac, 8) == 0;
175 if ((taginfo->wakeupReason == WAKEUP_REASON_FIRSTBOOT || taginfo->wakeupReason == WAKEUP_REASON_WDT_RESET) && taginfo->contentMode == 0) {
176 if (isAp) {
177 taginfo->contentMode = 21;
178 taginfo->nextupdate = 0;
179 } else if (contentFS->exists("/tag_defaults.json")) {
180 JsonDocument doc;
181 fs::File tagDefaults = contentFS->open("/tag_defaults.json", "r");
182 DeserializationError err = deserializeJson(doc, tagDefaults);
183 if (!err) {
184 if (doc["contentMode"].is<uint8_t>()) {
185 taginfo->contentMode = doc["contentMode"];
186 }
187 if (doc["modecfgjson"].is<String>()) {
188 taginfo->modeConfigJson = doc["modecfgjson"].as<String>();
189 }
190 }
191 tagDefaults.close();
192 }
193 }
194
195 char hexmac[17];
196 mac2hex(mac, hexmac);
197 String filename = "/temp/" + String(hexmac) + ".raw";
198#ifdef HAS_TFT
199 if (isAp) {
200 filename = "direct";
201 }
202#endif
203
204 JsonDocument doc;
205 deserializeJson(doc, taginfo->modeConfigJson);
206 JsonObject cfgobj = doc.as<JsonObject>();
207 char buffer[64];
208
209 wsLog("Updating " + String(hexmac));
210 taginfo->nextupdate = now + 60;
211
212 imgParam imageParams;
213 imageParams.hwdata = hwdata;
214 imageParams.width = hwdata.width;
215 imageParams.height = hwdata.height;
216 imageParams.bpp = hwdata.bpp;

Callers 1

contentRunnerFunction · 0.85

Calls 15

getHwTypeFunction · 0.85
memsetFunction · 0.85
memcmpFunction · 0.85
mac2hexFunction · 0.85
wsLogFunction · 0.85
getColorFunction · 0.85
getMidnightTimeFunction · 0.85
getTemplateFunction · 0.85
isEmptyOrNullFunction · 0.85
wsErrFunction · 0.85
jpg2bufferFunction · 0.85
prepareDataAvailFunction · 0.85

Tested by

no test coverage detected