From 5dce817580abbe13089ff907e4e420360488268d Mon Sep 17 00:00:00 2001 From: biver Date: Fri, 25 Nov 2022 13:29:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B8=D1=80=D1=83=D0=B5=D0=BC=20=D0=BD=D0=B5=D0=BA=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D1=83=D1=8E=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=83?= =?UTF-8?q?=20=D1=81=D0=BE=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0=D0=BC?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/classes/IoTScenario.h | 2 +- src/classes/IoTScenario.cpp | 54 +++++++++++++++++------------------ src/utils/SerialPrint.cpp | 4 +-- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/classes/IoTScenario.h b/include/classes/IoTScenario.h index c1a6cf83..bee35bb0 100644 --- a/include/classes/IoTScenario.h +++ b/include/classes/IoTScenario.h @@ -51,7 +51,7 @@ class IoTScenario { int GetTokPrecedence(); /// Error* - Это небольшие вспомогательные функции для обработки ошибок. - ExprAST *Error(const char *Str); + ExprAST *Error(const String& Str); /// identifierexpr /// ::= identifier diff --git a/src/classes/IoTScenario.cpp b/src/classes/IoTScenario.cpp index 0140a158..8173ffb9 100644 --- a/src/classes/IoTScenario.cpp +++ b/src/classes/IoTScenario.cpp @@ -296,7 +296,7 @@ class CallExprAST : public ExprAST { //if (!ItemIsLocal) Item = findIoTItem(Callee); // пробуем найти переменную если она не локальная (могла придти по сети в процессе) if (!Item) return nullptr; // ret = zeroIotVal; // если все же не пришла, то либо опечатка, либо уже стерлась - выходим - if (Cmd == "getIntFromNet") { + if (Cmd == F("getIntFromNet")) { ret.valD = Item->getIntFromNet(); ret.isDecimal = true; return &ret; @@ -467,43 +467,43 @@ class SysCallExprAST : public ExprAST { public: SysCallExprAST(const String &callee, std::vector &args) : Callee(callee), Args(args) { - if (Callee == "reboot") + if (Callee == F("reboot")) operation = sysop_reboot; - else if (Callee == "digitalRead") + else if (Callee == F("digitalRead")) operation = sysop_digitalRead; - else if (Callee == "analogRead") + else if (Callee == F("analogRead")) operation = sysop_analogRead; - else if (Callee == "digitalWrite") + else if (Callee == F("digitalWrite")) operation = sysop_digitalWrite; - else if (Callee == "digitalInvert") + else if (Callee == F("digitalInvert")) operation = sysop_digitalInvert; - else if (Callee == "deepSleep") + else if (Callee == F("deepSleep")) operation = sysop_deepSleep; - else if (Callee == "getTime") + else if (Callee == F("getTime")) operation = sysop_getTime; - else if (Callee == "getHours") + else if (Callee == F("getHours")) operation = sysop_getHours; - else if (Callee == "getMinutes") + else if (Callee == F("getMinutes")) operation = sysop_getMinutes; - else if (Callee == "getSeconds") + else if (Callee == F("getSeconds")) operation = sysop_getSeconds; - else if (Callee == "getMonth") + else if (Callee == F("getMonth")) operation = sysop_getMonth; - else if (Callee == "getDay") + else if (Callee == F("getDay")) operation = sysop_getDay; - else if (Callee == "getRSSI") + else if (Callee == F("getRSSI")) operation = sysop_getRSSI; - else if (Callee == "getIP") + else if (Callee == F("getIP")) operation = sysop_getIP; - else if (Callee == "mqttPub") + else if (Callee == F("mqttPub")) operation = sysop_mqttPub; - else if (Callee == "gethhmm") + else if (Callee == F("gethhmm")) operation = sysop_gethhmm; - else if (Callee == "gethhmmss") + else if (Callee == F("gethhmmss")) operation = sysop_gethhmmss; - else if (Callee == "getTime") + else if (Callee == F("getTime")) operation = sysop_getTime; - else if (Callee == "getUptime") + else if (Callee == F("getUptime")) operation = sysop_getUptime; else operation = sysop_notfound; @@ -790,8 +790,8 @@ int IoTScenario::GetTokPrecedence() { } /// Error* - Это небольшие вспомогательные функции для обработки ошибок. -ExprAST *IoTScenario::Error(const char *Str) { - Serial.printf("Scenario error in line %d: %s\n", curLine, Str); +ExprAST *IoTScenario::Error(const String& Str) { + Serial.printf("Scenario error in line %d: %s\n", curLine, Str.c_str()); isIotScenException = true; return nullptr; } @@ -834,7 +834,7 @@ ExprAST *IoTScenario::ParseIdentifierExpr(String *IDNames, bool callFromConditio if (CurTok == ')') break; if (CurTok != ',') { - return Error("Expected ')' or ',' in argument list"); + return Error(F("Expected ')' or ',' in argument list")); } getNextToken(); } @@ -891,7 +891,7 @@ ExprAST *IoTScenario::ParseBracketsExpr(String *IDNames, bool callFromCondition) // int ttok = getNextToken(); if (CurTok == tok_eof) { - return Error("Expected '}'"); + return Error(F("Expected '}'")); } } @@ -946,7 +946,7 @@ ExprAST *IoTScenario::ParsePrimary(String *IDNames, bool callFromCondition) { switch (CurTok) { default: Serial.println(CurTok); - return Error("unknown token when expecting an expression"); + return Error(F("unknown token when expecting an expression")); case tok_identifier: { if (callFromCondition && IDNames) { String tmpstr = *IDNames; @@ -1018,13 +1018,13 @@ void IoTScenario::loadScenario(String fileName) { // подготавливае if (file) file.close(); file = FileFS.open(fileName.c_str(), "r"); if (!file) { - Error("Open file scenario error"); + Error(F("Open file scenario error")); return; } } else if (mode == 1) { file = FileFS.open(fileName.c_str(), "r"); if (!file) { - Error("Open file scenario error"); + Error(F("Open file scenario error")); return; } strFromFile = file.readString(); diff --git a/src/utils/SerialPrint.cpp b/src/utils/SerialPrint.cpp index a1e8fde2..8ed907e2 100644 --- a/src/utils/SerialPrint.cpp +++ b/src/utils/SerialPrint.cpp @@ -13,7 +13,7 @@ void SerialPrint(const String& errorLevel, const String& module, const String& m if (isNetworkActive()) { if (jsonReadInt(settingsFlashJson, F("log")) != 0) { - sendStringToWs("corelg", tosend, -1); + sendStringToWs(F("corelg"), tosend, -1); } } @@ -21,7 +21,7 @@ void SerialPrint(const String& errorLevel, const String& module, const String& m cleanString(tosend); // создаем событие об ошибке для возможной реакции в сценарии if (itemId != "") { - createItemFromNet(itemId + "_onError", tosend, -4); + createItemFromNet(itemId + F("_onError"), tosend, -4); } else { // createItemFromNet("onError", tosend, -4); }