262 Logging added, working version

This commit is contained in:
Dmitry Borisenko
2020-11-01 04:48:35 +03:00
parent 1126575822
commit d96aea8eef
12 changed files with 105 additions and 215 deletions

View File

@@ -108,7 +108,7 @@ class LineParsing {
_descr.replace("%ver%", String(FIRMWARE_VERSION));
_descr.replace("%name%", jsonReadStr(configSetupJson, F("name")));
createWidgetClass(_descr, _page, _order, _file, _key);
createWidget(_descr, _page, _order, _file, _key);
}
//jsonWriteStr(configOptionJson, _key + "_pin", _pin);
@@ -188,13 +188,15 @@ class LineParsing {
return str.substring(p1 + 1, p2);
}
void createWidgetClass(String descr, String page, String order, String filename, String topic) {
void createWidget(String descr, String page, String order, String filename, String topic) {
if (filename != "na") {
String buf = "{}";
if (!loadWidgetClass(filename, buf)) {
if (!loadWidget(filename, buf)) {
return;
}
if(filename.indexOf("chart") != -1) jsonWriteStr(buf, "maxCount", _cnt);
jsonWriteStr(buf, "page", page);
jsonWriteStr(buf, "order", order);
jsonWriteStr(buf, "descr", descr);
@@ -208,8 +210,8 @@ class LineParsing {
}
}
bool loadWidgetClass(const String& filename, String& buf) {
buf = readFile(getWidgetFileClass(filename), 2048);
bool loadWidget(const String& filename, String& buf) {
buf = readFile(getWidgetFile(filename), 2048);
bool res = !(buf == "Failed" || buf == "Large");
if (!res) {
//SerialPrint("[E]","module","on load" + filename);
@@ -217,18 +219,9 @@ class LineParsing {
return res;
}
const String getWidgetFileClass(const String& name) {
const String getWidgetFile(const String& name) {
return "/widgets/" + name + ".json";
}
//String jsonWriteStr1(String& json, String name, String value) {
// DynamicJsonBuffer jsonBuffer;
// JsonObject& root = jsonBuffer.parseObject(json);
// root[name] = value;
// json = "";
// root.printTo(json);
// return json;
//}
};
extern LineParsing myLineParsing;