Теперь читаем сценарии из JSON

This commit is contained in:
2022-08-23 15:17:06 +03:00
parent d22741d9f6
commit c0f9a0890b

View File

@@ -929,14 +929,18 @@ void IoTScenario::loadScenario(String fileName) { // посимвольно с
File myfile = seekFile(fileName); File myfile = seekFile(fileName);
if (myfile.available()) { if (myfile.available()) {
String strFromFile = ""; strFromFile = new String("");
strFromFile = myfile.readString();
Serial.println(strFromFile); String strFromF = myfile.readString();
jsonRead(strFromFile, "scen", strFromFile, true); Serial.println(strFromF);
jsonRead(strFromF, "scen", *strFromFile, true);
myfile.close(); myfile.close();
//Serial.println(*strFromFile);
if (strFromFile->length()) {
getNextToken(); getNextToken();
while (strIterator < strFromFile.length() - 1) { while (strIterator < strFromFile->length() - 1) {
// Serial.printf("-%c", LastChar); // Serial.printf("-%c", LastChar);
switch (CurTok) { switch (CurTok) {
// case tok_eof: return; // case tok_eof: return;
@@ -944,7 +948,6 @@ void IoTScenario::loadScenario(String fileName) { // посимвольно с
case tok_if: { case tok_if: {
String IDNames = ""; // накопитель встречающихся идентификаторов в условии String IDNames = ""; // накопитель встречающихся идентификаторов в условии
ScenarioElements.push_back(ParseIfExpr(&IDNames)); ScenarioElements.push_back(ParseIfExpr(&IDNames));
// Serial.printf("vvvvvvvvvvvvvvvv %s", IDNames.c_str());
break; break;
} }
default: default:
@@ -952,7 +955,10 @@ void IoTScenario::loadScenario(String fileName) { // посимвольно с
break; break;
} }
} }
// delete strFromFile; }
delete strFromFile;
strIterator = 0; strIterator = 0;
} else { } else {
Error("Open file scenario error"); Error("Open file scenario error");