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

Function init_web

ESP32_AP-Flasher/src/web.cpp:283–893  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void init_web() {
284 wsMutex = xSemaphoreCreateMutex();
285 WiFi.mode(WIFI_STA);
286 WiFi.setTxPower(static_cast<wifi_power_t>(config.wifiPower));
287
288 wm.connectToWifi();
289
290 server.addHandler(new SPIFFSEditor(*contentFS));
291
292 server.addHandler(&ws);
293
294 server.on("/reboot", HTTP_POST, [](AsyncWebServerRequest *request) {
295 request->send(200, "text/plain", "OK Reboot");
296 logLine("Reboot request by user");
297 wsErr("REBOOTING");
298 delay(100);
299 ws.enable(false);
300 refreshAllPending();
301 saveDB("/current/tagDB.json");
302 ws.closeAll();
303 delay(100);
304 ESP.restart();
305 });
306
307 server.serveStatic("/current", *contentFS, "/current/").setCacheControl("max-age=604800");
308 server.serveStatic("/tagtypes", *contentFS, "/tagtypes/").setCacheControl("max-age=300");
309
310 server.on(
311 "/imgupload", HTTP_POST, [](AsyncWebServerRequest *request) {
312 request->send(200);
313 },
314 doImageUpload);
315 server.on("/jsonupload", HTTP_POST, doJsonUpload);
316
317 server.on("/get_db", HTTP_GET, [](AsyncWebServerRequest *request) {
318 String json = "";
319 if (request->hasParam("mac")) {
320 String dst = request->getParam("mac")->value();
321 uint8_t mac[8];
322 if (hex2mac(dst, mac)) {
323 json = tagDBtoJson(mac);
324 } else {
325 json = "{\"error\": \"malformatted parameter\"}";
326 }
327 } else {
328 uint8_t startPos = 0;
329 if (request->hasParam("pos")) {
330 startPos = atoi(request->getParam("pos")->value().c_str());
331 }
332 json = tagDBtoJson(nullptr, startPos);
333 }
334 request->send(200, "application/json", json);
335 });
336
337 server.on("/getdata", HTTP_GET, [](AsyncWebServerRequest *request) {
338 if (request->hasParam("mac")) {
339 String dst = request->getParam("mac")->value();
340 uint8_t mac[8];

Callers 1

setupFunction · 0.85

Calls 15

logLineFunction · 0.85
wsErrFunction · 0.85
refreshAllPendingFunction · 0.85
saveDBFunction · 0.85
hex2macFunction · 0.85
tagDBtoJsonFunction · 0.85
getQueueItemFunction · 0.85
getDataForFileFunction · 0.85
pushTagInfoFunction · 0.85
wsSendTaginfoFunction · 0.85
strcmpFunction · 0.85
deleteRecordFunction · 0.85

Tested by

no test coverage detected