MCPcopy Create free account
hub / github.com/Blueforcer/awtrix3 / parseCustomPage

Method parseCustomPage

src/DisplayManager.cpp:424–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424bool DisplayManager_::parseCustomPage(const String &name, const char *json, bool preventSave)
425{
426 if ((strcmp(json, "") == 0) || (strcmp(json, "{}") == 0))
427 {
428 removeCustomAppFromApps(name, true);
429 return true;
430 }
431
432 DynamicJsonDocument doc(8192);
433 DeserializationError error = deserializeJson(doc, json);
434 if (error)
435 {
436 DEBUG_PRINTLN(error.c_str());
437 doc.clear();
438 return false;
439 }
440
441 if (doc.is<JsonObject>())
442 {
443 JsonObject rootObj = doc.as<JsonObject>();
444 return generateCustomPage(name, rootObj, preventSave);
445 }
446 else if (doc.is<JsonArray>())
447 {
448 JsonArray customPagesArray = doc.as<JsonArray>();
449 int cpIndex = 0;
450 for (JsonObject customPageObject : customPagesArray)
451 {
452 generateCustomPage(name + String(cpIndex), customPageObject, preventSave);
453 ++cpIndex;
454 }
455 }
456
457 doc.clear();
458 return true;
459}
460
461// Function to subscribe to MQTT topics based on placeholders in text
462void subscribeToPlaceholders(String text)

Callers 2

processMqttMessageFunction · 0.80
addHandlerFunction · 0.80

Calls 2

removeCustomAppFromAppsFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected