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

Function getTemplate

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

Source from the content-addressed store, hash-verified

3157#endif
3158
3159void getTemplate(JsonDocument &json, const uint8_t id, const uint8_t hwtype) {
3160 JsonDocument filter;
3161 JsonDocument doc;
3162
3163 const String idstr = String(id);
3164 constexpr const char *templateKey = "template";
3165
3166 char filename[20];
3167 snprintf(filename, sizeof(filename), "/tagtypes/%02X.json", hwtype);
3168 File jsonFile = contentFS->open(filename, "r");
3169
3170 if (jsonFile) {
3171 filter[templateKey][idstr] = true;
3172 filter["usetemplate"] = true;
3173 const DeserializationError error = deserializeJson(doc, jsonFile, DeserializationOption::Filter(filter));
3174 jsonFile.close();
3175 if (!error && doc[templateKey].is<JsonVariant>() && doc[templateKey][idstr].is<JsonVariant>()) {
3176 json.set(doc[templateKey][idstr]);
3177 return;
3178 }
3179 if (!error && doc["usetemplate"].is<uint8_t>()) {
3180 getTemplate(json, id, doc["usetemplate"]);
3181 return;
3182 }
3183 Serial.println("json error in " + String(filename));
3184 Serial.println(error.c_str());
3185 } else {
3186 Serial.println("Failed to open " + String(filename));
3187 }
3188}

Callers 12

drawNewFunction · 0.85
drawDateFunction · 0.85
drawNumberFunction · 0.85
drawWeatherFunction · 0.85
drawForecastFunction · 0.85
getRssFeedFunction · 0.85
getCalFeedFunction · 0.85
getDayAheadFeedFunction · 0.85
drawQRFunction · 0.85
drawBuienradarFunction · 0.85
drawAPinfoFunction · 0.85
drawTimestampFunction · 0.85

Calls 5

FilterClass · 0.85
openMethod · 0.80
closeMethod · 0.80
printlnMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected