From 946979bafe6cc2ca11ceb82c70f008fe9114b041 Mon Sep 17 00:00:00 2001 From: biver Date: Sat, 18 Mar 2023 15:06:43 +0300 Subject: [PATCH 01/15] =?UTF-8?q?=D0=A3=D1=82=D0=BE=D1=87=D0=BD=D1=8F?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F=20HttpGet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/exec/HttpGet/modinfo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/exec/HttpGet/modinfo.json b/src/modules/exec/HttpGet/modinfo.json index c48638a5..b954636a 100644 --- a/src/modules/exec/HttpGet/modinfo.json +++ b/src/modules/exec/HttpGet/modinfo.json @@ -34,14 +34,14 @@ "name": "get", "descr": "Отправить http запрос методом GET.", "params": [ - "http.get('URL')" + "URL" ] }, { "name": "post", "descr": "Отправить http запрос методом POST.", "params": [ - "http.post('URL','message')" + "URL","message" ] } ] From 4f7923e7aae31b385c19cec41673cfe1e7945763 Mon Sep 17 00:00:00 2001 From: biver Date: Thu, 23 Mar 2023 23:51:02 +0300 Subject: [PATCH 02/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=B2=20Pzem004t=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D1=83=20=D0=B3=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BA=D0=B0=D0=BA=20=D1=81=D0=BE=D0=B1=D1=8B=D1=82?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/Pzem004t/Pzem004t.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/sensors/Pzem004t/Pzem004t.cpp b/src/modules/sensors/Pzem004t/Pzem004t.cpp index 8aa8b1c2..1cfccaa8 100644 --- a/src/modules/sensors/Pzem004t/Pzem004t.cpp +++ b/src/modules/sensors/Pzem004t/Pzem004t.cpp @@ -28,7 +28,7 @@ class Pzem004v : public IoTItem { regEvent(value.valD, "Pzem V"); } else { regEvent(NAN, "Pzem V"); - SerialPrint("E", "Pzem", "V error"); + SerialPrint("E", "Pzem", "V error", _id); } } } @@ -57,7 +57,7 @@ class Pzem004a : public IoTItem { regEvent(value.valD, "Pzem A"); } else { regEvent(NAN, "Pzem A"); - SerialPrint("E", "Pzem", "A error"); + SerialPrint("E", "Pzem", "A error", _id); } } } @@ -86,7 +86,7 @@ class Pzem004w : public IoTItem { regEvent(value.valD, "Pzem W"); } else { regEvent(NAN, "Pzem W"); - SerialPrint("E", "Pzem", "W error"); + SerialPrint("E", "Pzem", "W error", _id); } } } @@ -115,7 +115,7 @@ class Pzem004wh : public IoTItem { regEvent(value.valD, "Pzem Wh"); } else { regEvent(NAN, "Pzem Wh"); - SerialPrint("E", "Pzem", "Wh error"); + SerialPrint("E", "Pzem", "Wh error", _id); } } } @@ -144,7 +144,7 @@ class Pzem004hz : public IoTItem { regEvent(value.valD, "Pzem Hz"); } else { regEvent(NAN, "Pzem Hz"); - SerialPrint("E", "Pzem", "Hz error"); + SerialPrint("E", "Pzem", "Hz error", _id); } } } @@ -173,7 +173,7 @@ class Pzem004pf : public IoTItem { regEvent(value.valD, "Pzem Pf"); } else { regEvent(NAN, "Pzem Pf"); - SerialPrint("E", "Pzem", "Pf error"); + SerialPrint("E", "Pzem", "Pf error", _id); } } } From ff84a18fd02218133574530a73e41c568fb6060a Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 26 Mar 2023 13:23:46 +0300 Subject: [PATCH 03/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=20=D1=8D?= =?UTF-8?q?=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D1=87=D0=B0=D1=81=D1=82=D0=B8=20=D0=98=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/classes/IoTItem.h | 2 ++ src/classes/IoTItem.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/classes/IoTItem.h b/include/classes/IoTItem.h index 342bc02f..794dae73 100644 --- a/include/classes/IoTItem.h +++ b/include/classes/IoTItem.h @@ -24,6 +24,7 @@ class IoTItem { String getSubtype(); String getID(); + bool isStrInID(const String& str); int getIntFromNet(); virtual String getValue(); long getInterval(); @@ -91,6 +92,7 @@ class IoTItem { }; IoTItem* findIoTItem(const String& name); // поиск экземпляра элемента модуля по имени +IoTItem* findIoTItemByPartOfName(const String& partName); // поиск элемента модуля в существующей конфигурации по части имени String getItemValue(const String& name); // поиск плюс получение значения bool isItemExist(const String& name); // существует ли айтем //StaticJsonDocument* getLocalItemsAsJSON(); // сбор всех локальных значений Items diff --git a/src/classes/IoTItem.cpp b/src/classes/IoTItem.cpp index 26fb41d1..3a5c9a7d 100644 --- a/src/classes/IoTItem.cpp +++ b/src/classes/IoTItem.cpp @@ -200,6 +200,10 @@ String IoTItem::getID() { return _id; }; +bool IoTItem::isStrInID(const String& str) { + return _id.indexOf(str) != -1; +} + void IoTItem::setInterval(long interval) { _interval = interval; } @@ -245,6 +249,17 @@ IoTItem* findIoTItem(const String& name) { return nullptr; } + +// поиск элемента модуля в существующей конфигурации по части имени +IoTItem* findIoTItemByPartOfName(const String& partName) { + if (partName == "") return nullptr; + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { + if ((*it)->isStrInID(partName)) return *it; + } + + return nullptr; +} + // поиск плюс получение значения String getItemValue(const String& name) { IoTItem* tmp = findIoTItem(name); From edf966f66b5c3b2b2e56ed86fc7a75f25549e13c Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 26 Mar 2023 13:24:30 +0300 Subject: [PATCH 04/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BF=D1=80=D0=B8=D0=B5=D0=BC=20=D1=81?= =?UTF-8?q?=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D0=B9=20=D1=81=20=D1=8D=D0=BA?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=BE=D0=B2=20dwin=20=D0=B2=20=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D1=82=D0=B8=D0=B9=20=D1=80=D0=B5=D0=B6=D0=B8=D0=BC=20UAR?= =?UTF-8?q?T=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B9=20=D1=86?= =?UTF-8?q?=D0=B5=D0=BB=D1=8B=D1=85=20=D1=87=D0=B8=D1=81=D0=B5=D0=BB=20int?= =?UTF-8?q?16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/UART/Uart.cpp | 76 ++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 17 deletions(-) diff --git a/src/modules/sensors/UART/Uart.cpp b/src/modules/sensors/UART/Uart.cpp index 5428eecd..0ce8fd15 100644 --- a/src/modules/sensors/UART/Uart.cpp +++ b/src/modules/sensors/UART/Uart.cpp @@ -14,6 +14,10 @@ class UART : public IoTItem { private: int _eventFormat = 0; // 0 - нет приема, 1 - json IoTM, 2 - Nextion + char _inc; + String _inStr = ""; // буфер приема строк в режимах 0, 1, 2 + uint8_t _headerBuf[260]; // буфер для приема пакета dwin + int _headerIndex = 0; // счетчик принятых байт пакета #ifdef ESP8266 SoftwareSerial* _myUART = nullptr; @@ -70,23 +74,61 @@ class UART : public IoTItem { if (!_myUART) return; if (_myUART->available()) { - static String inStr = ""; - char inc; - - inc = _myUART->read(); - if (inc == 0xFF) { - inc = _myUART->read(); - inc = _myUART->read(); - inStr = ""; - return; - } + if (_eventFormat == 3) { // третий режим, значит ожидаем бинарный пакет данных от dwin + _headerBuf[_headerIndex] = _myUART->read(); - if (inc == '\r') return; - - if (inc == '\n') { - analyzeString(inStr); - inStr = ""; - } else inStr += inc; + // ищем валидный заголовок пакета dwin, проверяя каждый следующий байт + if (_headerIndex == 0 && _headerBuf[_headerIndex] != 0x5A || + _headerIndex == 1 && _headerBuf[_headerIndex] != 0xA5 || + _headerIndex == 2 && _headerBuf[_headerIndex] == 0 || + _headerIndex == 3 && _headerBuf[_headerIndex] == 0x82 ) { + _headerIndex = 0; + return; + } + + if (_headerIndex == _headerBuf[2] + 2) { // получили все данные из пакета + // Serial.print("ffffffff"); + // for (int i=0; i<=_headerIndex; i++) + // Serial.printf("%#x ", _headerBuf[i]); + // Serial.println("!!!"); + + String valStr, id = "_"; + if (_headerIndex == 8) { // предполагаем, что получили int16 + valStr = (String)((_headerBuf[7] << 8) | _headerBuf[8]); + } + + char buf[5]; + hex2string(_headerBuf + 4, 2, buf); + id += (String)buf; + + IoTItem* item = findIoTItemByPartOfName(id); + if (item) { + //Serial.printf("received data: %s for VP: %s for ID: %s\n", valStr, buf, item->getID()); + generateOrder(item->getID(), valStr); + } + + _headerIndex = 0; + return; + } + + _headerIndex++; + + } else { + _inc = _myUART->read(); + if (_inc == 0xFF) { + _inc = _myUART->read(); + _inc = _myUART->read(); + _inStr = ""; + return; + } + + if (_inc == '\r') return; + + if (_inc == '\n') { + analyzeString(_inStr); + _inStr = ""; + } else _inStr += _inc; + } } } @@ -161,7 +203,7 @@ class UART : public IoTItem { _myUART->write((eventItem->value.valS.length() - u16counter) * 2 + 5); // подсчитываем и отправляем размер итоговой строки + служебные байты _myUART->write(0x82); // требуем запись в память uartPrintHex(VP); // отправляем адрес в памяти VP - Serial.println("ffffff " + VP); + //Serial.println("ffffff " + VP); //_myUART->write(0x53); //_myUART->write(0x00); uartPrintStrInUTF16(eventItem->value.valS.c_str(), eventItem->value.valS.length()); // отправляем строку для записи From 057a95a43433d36dbf1ed5d064a6e10bac1506ce Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 26 Mar 2023 13:26:57 +0300 Subject: [PATCH 05/15] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D1=83=D0=B5=D0=BC=20=D0=BE=D0=BF=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20ulong=20=D0=BD?= =?UTF-8?q?=D0=B0=20unsigned=20long=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=83=20=D0=BA=D0=BE=D0=B4=D0=B0=20=D0=B2=20?= =?UTF-8?q?VS=20=D0=BD=D0=B5=20=D0=BD=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D0=BE?= =?UTF-8?q?=D1=81=D1=8C=20=D0=BA=D0=BE=D1=80=D0=BE=D1=82=D0=BA=D0=BE=D0=B5?= =?UTF-8?q?=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/classes/IoTItem.h | 2 +- src/classes/IoTItem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/classes/IoTItem.h b/include/classes/IoTItem.h index 794dae73..ff899a20 100644 --- a/include/classes/IoTItem.h +++ b/include/classes/IoTItem.h @@ -48,7 +48,7 @@ class IoTItem { virtual IoTGpio* getGpioDriver(); virtual IoTItem* getRtcDriver(); - virtual ulong getRtcUnixTime(); + virtual unsigned long getRtcUnixTime(); virtual void setValue(const IoTValue& Value, bool genEvent = true); virtual void setValue(const String& valStr, bool genEvent = true); diff --git a/src/classes/IoTItem.cpp b/src/classes/IoTItem.cpp index 3a5c9a7d..bb79c6b5 100644 --- a/src/classes/IoTItem.cpp +++ b/src/classes/IoTItem.cpp @@ -216,7 +216,7 @@ IoTItem* IoTItem::getRtcDriver() { return nullptr; } -ulong IoTItem::getRtcUnixTime() { +unsigned long IoTItem::getRtcUnixTime() { return 0; } From 35829ede3bc5d21c2773dec6378ea50e90148b6e Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 26 Mar 2023 20:34:33 +0300 Subject: [PATCH 06/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D1=83=20=D0=B4=D1=80=D0=BE=D0=B1=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BD=D0=B0=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=20Dwin?= =?UTF-8?q?=20=D0=94=D0=BB=D1=8F=20=D1=8D=D1=82=D0=BE=D0=B3=D0=BE=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=BE=D0=B1=D1=85=D0=BE=D0=B4=D0=B8=D0=BC=D0=BE=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D0=B5=D1=86=20=D0=98=D0=94=20=D0=BC=D0=B0=D1=80?= =?UTF-8?q?=D0=BA=D0=B5=D1=80=20f=20=D1=82.=D0=B5.=20var1=5F5000f=20=D0=90?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=D0=BE=D0=B3=D0=B8=D1=87=D0=BD=D0=BE=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5=D0=BC=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D1=83=20=D1=82=D0=B8=D0=BF?= =?UTF-8?q?=D0=BE=D0=B2=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=20-=20s=20=D0=B8?= =?UTF-8?q?=20=D1=86=D0=B5=D0=BB=D1=8B=D1=85=20-=20i=20=D0=9F=D0=BE=20?= =?UTF-8?q?=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8=D1=8E,=20?= =?UTF-8?q?=D0=B1=D0=B5=D0=B7=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=82=D0=B8=D0=BF=D0=B0=20=D0=B4=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B1=D1=83=D0=B4=D1=83=D1=82=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D1=8F=D1=82=D1=8C=D1=81=D1=8F=20?= =?UTF-8?q?=D0=B2=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D1=81=D0=B2?= =?UTF-8?q?=D0=B8=D0=B8=20=D1=81=20=D0=B2=D0=BD=D1=83=D1=82=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=B5=D0=B9=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D0=BF?= =?UTF-8?q?=D1=80=D0=B5=D1=82=D0=B0=D1=86=D0=B8=D0=B5=D0=B9,=20=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=B2=D1=81=D0=B5=D0=B3=D0=B4=D0=B0=20=D0=B8=D0=BB?= =?UTF-8?q?=D0=B8=20=D1=86=D0=B5=D0=BB=D0=BE=D0=B5=20=D0=B8=D0=BB=D0=B8=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/UART/Uart.cpp | 74 +++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/src/modules/sensors/UART/Uart.cpp b/src/modules/sensors/UART/Uart.cpp index 0ce8fd15..1f8708ca 100644 --- a/src/modules/sensors/UART/Uart.cpp +++ b/src/modules/sensors/UART/Uart.cpp @@ -170,51 +170,81 @@ class UART : public IoTItem { break; case 3: // формат событий для Dwin - //for (int i=0; i<2; i++) { printStr = eventItem->getID(); indexOf_ = printStr.indexOf("_"); - if (indexOf_ == -1 || !_myUART) return; // пропускаем событие, если нет используемого признака типа данных - _txt или _vol + uint8_t sizeOfVPPart = printStr.length() - indexOf_ - 1; + if (indexOf_ == -1 || !_myUART || sizeOfVPPart < 4 || indexOf_ == 0) return; // пропускаем событие, если нет признака _ или признак пустой - String VP = selectToMarkerLast(printStr, "_"); + char typeOfVP = sizeOfVPPart == 5 ? printStr.charAt(indexOf_ + 5) : 0; + String VP = printStr.substring(indexOf_ + 1, indexOf_ + 5); - _myUART->write(0x5A); - _myUART->write(0xA5); + if (typeOfVP == 0) { // если не указан тип, то додумываем на основании типа данных источника + if (eventItem->value.isDecimal) + typeOfVP = 'i'; + else + typeOfVP = 's'; + } - if (eventItem->value.isDecimal) { // пока отправляем только целые числа + if (typeOfVP == 'i') { + _myUART->write(0x5A); + _myUART->write(0xA5); _myUART->write(0x05); // размер данных отправляемых с учетом целых чисел int _myUART->write(0x82); // требуем запись в память uartPrintHex(VP); // отправляем адрес в памяти VP + + if (!eventItem->value.isDecimal) { + eventItem->value.valD = atoi(eventItem->value.valS.c_str()); + } + + _myUART->write(highByte((int)eventItem->value.valD)); + _myUART->write(lowByte((int)eventItem->value.valD)); + } + + if (typeOfVP == 's') { + if (eventItem->value.isDecimal) { + eventItem->value.valS = eventItem->getValue(); + } - byte raw[2]; - (int&)raw = eventItem->value.valD; - _myUART->write(raw[1]); - _myUART->write(raw[0]); - } else { // подсчитываем количество символов отличающихся от ASCII, для понимания сколько символов состоит из дух байт int u16counter = 0; const char* valSptr = eventItem->value.valS.c_str(); - //Serial.print("iiiii "); for (int i=0; i < eventItem->value.valS.length(); i++) { if (valSptr[i] > 200) u16counter++; - //Serial.printf("%d ", valSptr[i]); } - //Serial.println(); + _myUART->write(0x5A); + _myUART->write(0xA5); _myUART->write((eventItem->value.valS.length() - u16counter) * 2 + 5); // подсчитываем и отправляем размер итоговой строки + служебные байты _myUART->write(0x82); // требуем запись в память uartPrintHex(VP); // отправляем адрес в памяти VP - //Serial.println("ffffff " + VP); - //_myUART->write(0x53); - //_myUART->write(0x00); uartPrintStrInUTF16(eventItem->value.valS.c_str(), eventItem->value.valS.length()); // отправляем строку для записи _myUART->write(0xFF); // терминируем строку, чтоб экран очистил все остальное в элементе своем _myUART->write(0xFF); - //uint8_t Data[8] = {0x00, 0x31, 0x00, 0x44, 0x04, 0x10, 0x00, 0x00}; - //uartPrintArray(Data, 6); //Serial.printf("fffffffff %#x %#x %#x %#x \n", Data[0], Data[1], Data[2], Data[3]); } - //} + + if (typeOfVP == 'f') { + _myUART->write(0x5A); + _myUART->write(0xA5); + _myUART->write(0x07); // размер данных отправляемых с учетом дробных чисел dword + _myUART->write(0x82); // требуем запись в память + uartPrintHex(VP); // отправляем адрес в памяти VP + + byte hex[4] = {0}; + if (!eventItem->value.isDecimal) { + eventItem->value.valD = atof(eventItem->value.valS.c_str()); + } + + byte* f_byte = reinterpret_cast(&(eventItem->value.valD)); + memcpy(hex, f_byte, 4); + + _myUART->write(hex[3]); + _myUART->write(hex[2]); + _myUART->write(hex[1]); + _myUART->write(hex[0]); + } + break; } } @@ -244,10 +274,6 @@ class UART : public IoTItem { } } - void uartPrintArray(uint8_t *_Data, uint8_t _Size) { - for (size_t i = 0; i < _Size; i++) _myUART->write(_Data[i]); - } - virtual void loop() { uartHandle(); } From 0e6a83089d64e7962ebf33aca517d73917bbab69 Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 26 Mar 2023 21:27:40 +0300 Subject: [PATCH 07/15] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=BE=D1=81=D0=B8?= =?UTF-8?q?=D0=BC=20=D0=B2=D1=8B=D0=B7=D0=BE=D0=B2=20=D1=85=D1=83=D0=BA?= =?UTF-8?q?=D0=B0=20onRegEvent=20=D0=B2=20=D0=BE=D0=B1=D1=89=D1=83=D1=8E?= =?UTF-8?q?=20=D0=BE=D1=87=D0=B5=D1=80=D0=B5=D0=B4=D1=8C=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=B1=D0=BE=D1=80=D0=BA=D0=B8=20=D1=81=D0=BE=D0=B1=D1=8B?= =?UTF-8?q?=D1=82=D0=B8=D0=B9=20=D0=9D=D0=B0=D1=85=D0=BE=D0=B4=D0=B8=D0=BB?= =?UTF-8?q?=D1=81=D1=8F=20=D1=80=D0=B0=D0=BD=D0=B5=D0=B5=20=D0=B2=20=D0=BF?= =?UTF-8?q?=D1=80=D1=8F=D0=BC=D0=BE=D0=BC=20=D0=B2=D1=8B=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=20=D0=B2=D0=BE=20=D0=B2=D1=80=D0=B5=D0=BC=D1=8F=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D1=8F,=20=D1=87=D1=82?= =?UTF-8?q?=D0=BE=20=D0=BD=D0=B5=20=D0=B2=D0=B5=D1=80=D0=BD=D0=BE=20=D1=81?= =?UTF-8?q?=20=D1=82=D0=BE=D1=87=D0=BA=D0=B8=20=D0=B7=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=80=D0=B0=D1=81=D0=BF=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=B0=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B7=D0=BA=D0=B8=20=D0=B8=20=D0=BD=D0=B5=20=D0=B7=D0=B0=D1=85?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D1=8B=D0=B2=D0=B0=D0=BB=D0=BE=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B1=D1=8B=D1=82=D0=B8=D1=8F=20=D0=B8=D0=B7=20=D0=B4=D1=80?= =?UTF-8?q?=D1=83=D0=B3=D0=B8=D1=85=20=D0=B8=D1=81=D1=82=D0=BE=D1=87=D0=BD?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=B2,=20=D0=BD=D0=B0=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D1=80,=20MQTT.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EventsAndOrders.cpp | 8 +++++++- src/classes/IoTItem.cpp | 5 ----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/EventsAndOrders.cpp b/src/EventsAndOrders.cpp index 2af00a66..20416471 100644 --- a/src/EventsAndOrders.cpp +++ b/src/EventsAndOrders.cpp @@ -51,10 +51,16 @@ void handleEvent() { if (eventBuf.length()) { String event = selectToMarker(eventBuf, ","); SerialPrint("i", F("EVENT"), event); + String enentIdName = selectToMarker(event, " "); + + // распространяем событие через хуки + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { + (*it)->onRegEvent(findIoTItem(enentIdName)); + } //здесь нужно пропускать данное событие через условия сценариев //и если оно есть в условии сценария и совподает - iotScen.exec(selectToMarker(event, " ")); + iotScen.exec(enentIdName); eventBuf = deleteBeforeDelimiter(eventBuf, ","); } diff --git a/src/classes/IoTItem.cpp b/src/classes/IoTItem.cpp index bb79c6b5..73918f46 100644 --- a/src/classes/IoTItem.cpp +++ b/src/classes/IoTItem.cpp @@ -101,11 +101,6 @@ void IoTItem::regEvent(const String& value, const String& consoleInfo, bool erro if (genEvent) { generateEvent(_id, value); - // распространяем событие через хуки - for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { - (*it)->onRegEvent(this); - } - // отправка события другим устройствам в сети если не было ошибки if (_global && !error) { String json = "{}"; From 30a07548233c013bd16a742da22c4d454c63f24b Mon Sep 17 00:00:00 2001 From: biver Date: Tue, 28 Mar 2023 08:59:15 +0300 Subject: [PATCH 08/15] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D0=B5=D0=BC=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B5=D1=80=D0=B0=D0=B2=D0=B5=D0=BD=D1=81=D1=82=D0=B2?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=20?= =?UTF-8?q?=D0=B2=20=D1=81=D1=86=D0=B5=D0=BD=D0=B0=D1=80=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/IoTScenario.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/classes/IoTScenario.cpp b/src/classes/IoTScenario.cpp index 9980fce0..b1c7b988 100644 --- a/src/classes/IoTScenario.cpp +++ b/src/classes/IoTScenario.cpp @@ -156,8 +156,8 @@ class BinaryExprAST : public ExprAST { IoTValue *lhs = LHS->exec(); // если присваивания не произошло, значит операция иная и необходимо значение левого операнда if (lhs == nullptr) return nullptr; - // все бинарные операции кроме +, - и == обязаны работать с числами - if (Op != '+' && Op != '-' && Op != tok_equal) { + // все бинарные операции кроме +, -, != и == обязаны работать с числами + if (Op != '+' && Op != '-' && Op != tok_equal && Op != tok_notequal) { // поэтому преобразовываем строки в булевые интерпретации if (!lhs->isDecimal) lhs->valD = lhs->valS != ""; // пустая строка = false if (!rhs->isDecimal) rhs->valD = rhs->valS != ""; // пустая строка = false @@ -175,9 +175,6 @@ class BinaryExprAST : public ExprAST { case tok_greateq: val.valD = lhs->valD >= rhs->valD; break; - case tok_notequal: - val.valD = lhs->valD != rhs->valD; - break; case '*': val.valD = lhs->valD * rhs->valD; @@ -199,7 +196,7 @@ class BinaryExprAST : public ExprAST { default: break; } - } else { // иначе имеем дело с операциями + или - или ==, которые могут работать с разными типами данных + } else { // иначе имеем дело с операциями + или - или == или !=, которые могут работать с разными типами данных if (lhs->isDecimal && lhs->valS == "") lhs->valS = (String)lhs->valD; // небольшой костыль пока не переделаем работу со значениями, планируется добавить long, работу со временем, перенести округление и модификаторы в IoTValue if (rhs->isDecimal && rhs->valS == "") rhs->valS = (String)rhs->valD; // пока для сохранения округления в IoTItem применяется хитрость с сохранением внешнего вида числа в строку valS, // но некоторые модули и системные не делают этого, поэтому отлавливаем эту ситуацию тут и учитываем. @@ -211,6 +208,13 @@ class BinaryExprAST : public ExprAST { val.valD = compStr(lhs->valS, rhs->valS); break; + case tok_notequal: + if (lhs->isDecimal && rhs->isDecimal) + val.valD = lhs->valD != rhs->valD; + else + val.valD = !compStr(lhs->valS, rhs->valS); + break; + case '+': if (lhs->isDecimal && rhs->isDecimal) val.valD = lhs->valD + rhs->valD; From a68b143e549b43d14097da69a2202a1a577efe19 Mon Sep 17 00:00:00 2001 From: biver Date: Tue, 28 Mar 2023 09:14:03 +0300 Subject: [PATCH 09/15] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D1=8B=D0=B2=D0=B0=D0=B5=D0=BC=20class?= =?UTF-8?q?=20UART=20=D0=B2=20IoTmUART,=20=D1=82.=D0=BA.=20=D0=B8=D0=BC?= =?UTF-8?q?=D1=8F=20=D0=B7=D0=B0=D0=B1=D1=80=D0=BE=D0=BD=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/UART/Uart.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/sensors/UART/Uart.cpp b/src/modules/sensors/UART/Uart.cpp index 1f8708ca..27bc898e 100644 --- a/src/modules/sensors/UART/Uart.cpp +++ b/src/modules/sensors/UART/Uart.cpp @@ -11,7 +11,7 @@ HardwareSerial* myUART = nullptr; #endif -class UART : public IoTItem { +class IoTmUART : public IoTItem { private: int _eventFormat = 0; // 0 - нет приема, 1 - json IoTM, 2 - Nextion char _inc; @@ -26,7 +26,7 @@ class UART : public IoTItem { #endif public: - UART(String parameters) : IoTItem(parameters) { + IoTmUART(String parameters) : IoTItem(parameters) { int _tx, _rx, _speed, _line; jsonRead(parameters, "tx", _tx); jsonRead(parameters, "rx", _rx); @@ -351,7 +351,7 @@ class UART : public IoTItem { void* getAPI_UART(String subtype, String param) { if (subtype == F("UART")) { - return new UART(param); + return new IoTmUART(param); } else { return nullptr; } From 45748cd67fcf0a6f7c4a1e8901efb6283aed6e64 Mon Sep 17 00:00:00 2001 From: biver Date: Tue, 28 Mar 2023 09:15:43 +0300 Subject: [PATCH 10/15] =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0?= =?UTF-8?q?=D1=89=D0=B0=D0=B5=D0=BC=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E?= =?UTF-8?q?=20EspSoftwareSerial=20=D0=B4=D0=BE=20=D0=BF=D0=BE=D1=81=D0=BB?= =?UTF-8?q?=D0=B5=D0=B4=D0=BD=D0=B5=D0=B9=20=D0=BE=D1=82=D0=BA=D0=B0=D1=82?= =?UTF-8?q?=D1=8B=D0=B2=D0=B0=D0=BB=D0=B8=D1=81=D1=8C=20=D0=B2=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE=20=D0=B8=D0=B7-=D0=B7=D0=B0=20?= =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=B2=20=D0=B1=D0=B8?= =?UTF-8?q?=D0=B1=D0=BB=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformio.ini | 6 ++---- src/modules/sensors/UART/modinfo.json | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index 42c25d4c..16c84fe2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -116,7 +116,6 @@ build_src_filter = lib_deps = ${common_env_data.lib_deps_external} ${env:esp32_4mb_fromitems.lib_deps} - plerup/EspSoftwareSerial@^7.0.0 build_flags = -Desp32_4mb="esp32_4mb" framework = arduino board = esp32dev @@ -264,7 +263,7 @@ lib_deps = https://github.com/tremaru/iarduino_RTC robtillaart/SHT2x@^0.1.1 WEMOS SHT3x@1.0.0 - plerup/EspSoftwareSerial@^7.0.0 + plerup/EspSoftwareSerial adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 adafruit/Adafruit BusIO @ ^1.13.2 dfrobot/DFRobotDFPlayerMini @ ^1.0.5 @@ -313,7 +312,7 @@ lib_deps = https://github.com/tremaru/iarduino_RTC robtillaart/SHT2x@^0.1.1 WEMOS SHT3x@1.0.0 - plerup/espsoftwareserial + plerup/EspSoftwareSerial https://github.com/RoboticsBrno/ServoESP32 adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 adafruit/Adafruit BusIO @ ^1.13.2 @@ -351,6 +350,5 @@ build_src_filter = + + + - + + diff --git a/src/modules/sensors/UART/modinfo.json b/src/modules/sensors/UART/modinfo.json index b32dbde0..041f2ca1 100644 --- a/src/modules/sensors/UART/modinfo.json +++ b/src/modules/sensors/UART/modinfo.json @@ -66,10 +66,10 @@ "defActive": true, "usedLibs": { "esp32_4mb": [ - "plerup/EspSoftwareSerial@^7.0.0" + "plerup/EspSoftwareSerial" ], "esp8266_4mb": [ - "plerup/EspSoftwareSerial@^7.0.0" + "plerup/EspSoftwareSerial" ] } } \ No newline at end of file From c64a2e7793a0503f5e605e04d93ff77a02ae8f2b Mon Sep 17 00:00:00 2001 From: Mit4el Date: Mon, 3 Apr 2023 20:34:07 +0300 Subject: [PATCH 11/15] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D0=B5=D0=BC=20=D0=B4=D0=BD=D0=B5=D0=B2=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=B8=20=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE?= =?UTF-8?q?=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/virtual/Loging/Loging.cpp | 8 ++++---- src/modules/virtual/LogingDaily/LogingDaily.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/virtual/Loging/Loging.cpp b/src/modules/virtual/Loging/Loging.cpp index 7a8efb3b..9671632e 100644 --- a/src/modules/virtual/Loging/Loging.cpp +++ b/src/modules/virtual/Loging/Loging.cpp @@ -68,8 +68,8 @@ class Loging : public IoTItem { String logData; - jsonWriteInt(logData, "x", unixTime); - jsonWriteFloat(logData, "y1", value.toFloat()); + jsonWriteInt(logData, "x", unixTime, false); + jsonWriteFloat(logData, "y1", value.toFloat(), false); // прочитаем путь к файлу последнего сохранения String filePath = readDataDB(id); @@ -119,8 +119,8 @@ class Loging : public IoTItem { } regEvent(value, F("LogingEvent")); String logData; - jsonWriteInt(logData, "x", unixTime); - jsonWriteFloat(logData, "y1", value.toFloat()); + jsonWriteInt(logData, "x", unixTime, false); + jsonWriteFloat(logData, "y1", value.toFloat(), false); // прочитаем путь к файлу последнего сохранения String filePath = readDataDB(id); diff --git a/src/modules/virtual/LogingDaily/LogingDaily.cpp b/src/modules/virtual/LogingDaily/LogingDaily.cpp index 14413df2..6e7e87b4 100644 --- a/src/modules/virtual/LogingDaily/LogingDaily.cpp +++ b/src/modules/virtual/LogingDaily/LogingDaily.cpp @@ -156,7 +156,7 @@ class LogingDaily : public IoTItem { if (!firstTimeInit) { if (prevDate != currentDate) { changed = true; - SerialPrint("i", F("NTP"), "Change day event"); + SerialPrint("i", F("NTP"), F("Change day event")); #if defined(ESP8266) FileFS.gc(); #endif @@ -164,7 +164,7 @@ class LogingDaily : public IoTItem { #endif } } - firstTimeInit = false; + if (isTimeSynch) firstTimeInit = false; prevDate = currentDate; return changed; } From ac77b8fb4acc8cad16c033e645aeb91f93d34847 Mon Sep 17 00:00:00 2001 From: Mit4el Date: Mon, 3 Apr 2023 20:40:19 +0300 Subject: [PATCH 12/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BA=D0=BE=D0=BD=D1=82=D1=80=D0=BE=D0=BB?= =?UTF-8?q?=D0=BB=D0=B5=D1=80=20esp8266=5F2mb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrepareProject.py | 4 +- include/Const.h | 8 + platformio.ini | 190 ++++++++---------- src/UpgradeFirm.cpp | 2 +- src/modules/display/Lcd2004/modinfo.json | 8 + src/modules/exec/ButtonIn/modinfo.json | 4 +- src/modules/exec/ButtonOut/modinfo.json | 4 +- src/modules/exec/HttpGet/modinfo.json | 4 +- src/modules/exec/Mcp23008/modinfo.json | 8 + src/modules/exec/Mcp23017/modinfo.json | 8 + src/modules/exec/Multitouch/modinfo.json | 4 +- src/modules/exec/Pcf8574/modinfo.json | 6 + src/modules/exec/Pwm8266/modinfo.json | 4 +- src/modules/exec/TelegramLT/modinfo.json | 4 +- src/modules/exec/Thermostat/modinfo.json | 4 +- src/modules/sensors/AnalogAdc/modinfo.json | 4 +- src/modules/sensors/Bme280/modinfo.json | 18 ++ src/modules/sensors/Bmp280/modinfo.json | 9 + src/modules/sensors/DS2401/modinfo.json | 20 +- src/modules/sensors/Ds18b20/modinfo.json | 6 + src/modules/sensors/ExternalMQTT/modinfo.json | 4 +- src/modules/sensors/Pzem004t/modinfo.json | 8 +- src/modules/sensors/RCswitch/modinfo.json | 6 + src/modules/sensors/RTC/modinfo.json | 4 +- src/modules/sensors/Sgp30/modinfo.json | 6 + src/modules/sensors/Sht20/modinfo.json | 6 + src/modules/sensors/Sht30/modinfo.json | 6 + src/modules/sensors/Sonar/modinfo.json | 4 +- src/modules/sensors/UART/modinfo.json | 17 +- src/modules/virtual/Cron/modinfo.json | 4 +- src/modules/virtual/Loging/modinfo.json | 8 +- src/modules/virtual/LogingDaily/modinfo.json | 8 +- src/modules/virtual/Timer/modinfo.json | 4 +- src/modules/virtual/VButton/modinfo.json | 4 +- src/modules/virtual/Variable/modinfo.json | 4 +- .../virtual/VariableColor/modinfo.json | 4 +- src/modules/virtual/Weather/modinfo.json | 4 +- 37 files changed, 282 insertions(+), 138 deletions(-) diff --git a/PrepareProject.py b/PrepareProject.py index b40b24cb..50e37ebd 100644 --- a/PrepareProject.py +++ b/PrepareProject.py @@ -20,6 +20,8 @@ # esp8266_1mb_ota # esp8285_1mb # esp8285_1mb_ota +# esp8266_2mb +# esp8266_2mb_ota import configparser import os, json, sys, getopt @@ -119,7 +121,7 @@ deviceName = profJson['projectProp']['platformio']['default_envs'] # назначаем папку с файлами прошивки в зависимости от устройства и запоминаем в профиле dataDir = 'data_svelte' -if deviceName == 'esp8266_1mb_ota' or deviceName == 'esp8285_1mb_ota': +if deviceName == 'esp8266_1mb_ota' or deviceName == 'esp8285_1mb_ota' or deviceName == 'esp8266_2mb_ota': dataDir = 'data_svelte_lite' profJson['projectProp'] = { 'platformio': { diff --git a/include/Const.h b/include/Const.h index e80ae50e..75efb4bb 100644 --- a/include/Const.h +++ b/include/Const.h @@ -11,6 +11,14 @@ #define FIRMWARE_NAME "esp8266_1mb" #endif +#ifdef esp8266_2mb +#define FIRMWARE_NAME "esp8266_2mb" +#endif + +#ifdef esp8266_2mb_ota +#define FIRMWARE_NAME "esp8266_2mb_ota" +#endif + #ifdef esp8266_4mb #define FIRMWARE_NAME "esp8266_4mb" #endif diff --git a/platformio.ini b/platformio.ini index 16c84fe2..bf13dc11 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1,6 +1,6 @@ [platformio] -default_envs = esp8266_4mb -data_dir = data_svelte +default_envs = esp8266_2mb_ota +data_dir = data_svelte_lite [common_env_data] lib_deps_external = @@ -70,6 +70,48 @@ build_src_filter = + ${env:esp8285_1mb_ota_fromitems.build_src_filter} +[env:esp8266_2mb] +lib_deps = + ${common_env_data.lib_deps_external} + ${env:esp8266_2mb_fromitems.lib_deps} + ESPAsyncUDP +build_flags = -Desp8266_2mb="esp8266_2mb" +framework = arduino +board = d1_wroom_02 +board_build.ldscript = eagle.flash.2m1m.ld +platform = espressif8266 +monitor_filters = esp8266_exception_decoder +upload_speed = 921600 +monitor_speed = 115200 +board_build.filesystem = littlefs +build_src_filter = + +<*.cpp> + + + + + + + ${env:esp8266_2mb_fromitems.build_src_filter} + +[env:esp8266_2mb_ota] +lib_deps = + ${common_env_data.lib_deps_external} + ${env:esp8266_2mb_fromitems.lib_deps} + ESPAsyncUDP +build_flags = -Desp8266_2mb_ota="esp8266_2mb_ota" +framework = arduino +board = d1_wroom_02 +board_build.ldscript = eagle.flash.2m256.ld +platform = espressif8266 +monitor_filters = esp8266_exception_decoder +upload_speed = 921600 +monitor_speed = 115200 +board_build.filesystem = littlefs +build_src_filter = + +<*.cpp> + + + + + + + ${env:esp8266_2mb_fromitems.build_src_filter} + [env:esp8285_1mb] lib_deps = ${common_env_data.lib_deps_external} @@ -134,69 +176,74 @@ build_src_filter = [env:esp8266_1mb_ota_fromitems] lib_deps = + adafruit/Adafruit BME280 Library adafruit/Adafruit BMP280 Library - https://github.com/milesburton/Arduino-Temperature-Control-Library - https://github.com/tremaru/iarduino_RTC - robtillaart/SHT2x@^0.1.1 - WEMOS SHT3x@1.0.0 - adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 - adafruit/Adafruit BusIO @ ^1.13.2 - adafruit/Adafruit BusIO @ ^1.13.2 - https://github.com/robotclass/RobotClass_LiquidCrystal_I2C - marcoschwartz/LiquidCrystal_I2C@^1.1.4 + plerup/espsoftwareserial build_src_filter = + + + + + + + + + - + + + + + - + - + - + - + - + - + - + - + - + - + - + + + + + + - + [env:esp8266_1mb_fromitems] lib_deps = adafruit/Adafruit BME280 Library adafruit/Adafruit BMP280 Library - milesburton/DallasTemperature@^3.9.1 - robtillaart/SHT2x@^0.1.1 - WEMOS SHT3x@1.0.0 - adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 - adafruit/Adafruit BusIO @ ^1.13.2 - adafruit/Adafruit BusIO @ ^1.13.2 - marcoschwartz/LiquidCrystal_I2C@^1.1.4 + plerup/espsoftwareserial build_src_filter = + + + + + + + + + + - + + + - + - + - + - + + + + + + + - + - + - + - + + - + + +[env:esp8266_2mb_fromitems] +lib_deps = + plerup/EspSoftwareSerial +build_src_filter = + + + + + + + + + + + + + + + + + + + + + +[env:esp8266_2mb_ota_fromitems] +lib_deps = + plerup/EspSoftwareSerial +build_src_filter = + + + + + + + + + + + + + + + + + + + + [env:esp8285_1mb_ota_fromitems] lib_deps = @@ -255,21 +302,7 @@ build_src_filter = [env:esp8266_4mb_fromitems] lib_deps = - https://github.com/enjoyneering/AHTxx.git - adafruit/Adafruit BME280 Library - adafruit/Adafruit BMP280 Library - beegee-tokyo/DHT sensor library for ESPx - https://github.com/milesburton/Arduino-Temperature-Control-Library - https://github.com/tremaru/iarduino_RTC - robtillaart/SHT2x@^0.1.1 - WEMOS SHT3x@1.0.0 plerup/EspSoftwareSerial - adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 - adafruit/Adafruit BusIO @ ^1.13.2 - dfrobot/DFRobotDFPlayerMini @ ^1.0.5 - adafruit/Adafruit BusIO @ ^1.13.2 - https://github.com/robotclass/RobotClass_LiquidCrystal_I2C - marcoschwartz/LiquidCrystal_I2C@^1.1.4 build_src_filter = + + @@ -278,48 +311,16 @@ build_src_filter = + + + - + - + - + - + - + - + - + + - + - + - + - + + - + - + - + - + - + - + - + - + + - + [env:esp32_4mb_fromitems] lib_deps = - https://github.com/enjoyneering/AHTxx.git adafruit/Adafruit BME280 Library adafruit/Adafruit BMP280 Library - beegee-tokyo/DHT sensor library for ESPx - https://github.com/milesburton/Arduino-Temperature-Control-Library https://github.com/tremaru/iarduino_RTC - robtillaart/SHT2x@^0.1.1 - WEMOS SHT3x@1.0.0 plerup/EspSoftwareSerial - https://github.com/RoboticsBrno/ServoESP32 - adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 - adafruit/Adafruit BusIO @ ^1.13.2 - dfrobot/DFRobotDFPlayerMini @ ^1.0.5 - adafruit/Adafruit BusIO @ ^1.13.2 - https://github.com/robotclass/RobotClass_LiquidCrystal_I2C - marcoschwartz/LiquidCrystal_I2C@^1.1.4 build_src_filter = + + @@ -328,27 +329,12 @@ build_src_filter = + + + - + - + - + + + - + - + + + - + - + - + + + + - + - + - + - + - + - + + - + diff --git a/src/UpgradeFirm.cpp b/src/UpgradeFirm.cpp index 53c6e15b..20385771 100644 --- a/src/UpgradeFirm.cpp +++ b/src/UpgradeFirm.cpp @@ -72,7 +72,7 @@ bool upgradeBuild() { handleUpdateStatus(true, PATH_ERROR); return ret; } -#if defined (esp8266_4mb) || defined (esp8266_1mb) || defined (esp8266_1mb_ota) +#if defined (esp8266_4mb) || defined (esp8266_1mb) || defined (esp8266_1mb_ota) || defined (esp8266_2mb) || defined (esp8266_2mb_ota) ESPhttpUpdate.rebootOnUpdate(false); t_httpUpdate_return retBuild = ESPhttpUpdate.update(wifiClient, getBinPath("firmware.bin")); #endif diff --git a/src/modules/display/Lcd2004/modinfo.json b/src/modules/display/Lcd2004/modinfo.json index 24faf854..024750b8 100644 --- a/src/modules/display/Lcd2004/modinfo.json +++ b/src/modules/display/Lcd2004/modinfo.json @@ -127,6 +127,14 @@ "esp8285_1mb_ota": [ "https://github.com/robotclass/RobotClass_LiquidCrystal_I2C", "marcoschwartz/LiquidCrystal_I2C@^1.1.4" + ], + "esp8266_2mb": [ + "https://github.com/robotclass/RobotClass_LiquidCrystal_I2C", + "marcoschwartz/LiquidCrystal_I2C@^1.1.4" + ], + "esp8266_2mb_ota": [ + "https://github.com/robotclass/RobotClass_LiquidCrystal_I2C", + "marcoschwartz/LiquidCrystal_I2C@^1.1.4" ] } } \ No newline at end of file diff --git a/src/modules/exec/ButtonIn/modinfo.json b/src/modules/exec/ButtonIn/modinfo.json index 951df888..690ace99 100644 --- a/src/modules/exec/ButtonIn/modinfo.json +++ b/src/modules/exec/ButtonIn/modinfo.json @@ -50,6 +50,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/exec/ButtonOut/modinfo.json b/src/modules/exec/ButtonOut/modinfo.json index f4c2af3c..35e4d5c7 100644 --- a/src/modules/exec/ButtonOut/modinfo.json +++ b/src/modules/exec/ButtonOut/modinfo.json @@ -49,6 +49,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/exec/HttpGet/modinfo.json b/src/modules/exec/HttpGet/modinfo.json index b954636a..56c4d57b 100644 --- a/src/modules/exec/HttpGet/modinfo.json +++ b/src/modules/exec/HttpGet/modinfo.json @@ -53,6 +53,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/exec/Mcp23008/modinfo.json b/src/modules/exec/Mcp23008/modinfo.json index 6181b062..d04c12f7 100644 --- a/src/modules/exec/Mcp23008/modinfo.json +++ b/src/modules/exec/Mcp23008/modinfo.json @@ -62,6 +62,14 @@ "esp8285_1mb_ota": [ "adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0", "adafruit/Adafruit BusIO @ ^1.13.2" + ], + "esp8266_2mb": [ + "adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0", + "adafruit/Adafruit BusIO @ ^1.13.2" + ], + "esp8266_2mb_ota": [ + "adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0", + "adafruit/Adafruit BusIO @ ^1.13.2" ] } } \ No newline at end of file diff --git a/src/modules/exec/Mcp23017/modinfo.json b/src/modules/exec/Mcp23017/modinfo.json index 35b10926..ad20b6ca 100644 --- a/src/modules/exec/Mcp23017/modinfo.json +++ b/src/modules/exec/Mcp23017/modinfo.json @@ -62,6 +62,14 @@ "esp8285_1mb_ota": [ "adafruit/Adafruit MCP23017 Arduino Library@^2.1.0", "adafruit/Adafruit BusIO @ ^1.13.2" + ], + "esp8266_2mb": [ + "adafruit/Adafruit MCP23017 Arduino Library@^2.1.0", + "adafruit/Adafruit BusIO @ ^1.13.2" + ], + "esp8266_2mb_ota": [ + "adafruit/Adafruit MCP23017 Arduino Library@^2.1.0", + "adafruit/Adafruit BusIO @ ^1.13.2" ] } } \ No newline at end of file diff --git a/src/modules/exec/Multitouch/modinfo.json b/src/modules/exec/Multitouch/modinfo.json index 3f49e91a..b83a1f9e 100644 --- a/src/modules/exec/Multitouch/modinfo.json +++ b/src/modules/exec/Multitouch/modinfo.json @@ -48,6 +48,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } diff --git a/src/modules/exec/Pcf8574/modinfo.json b/src/modules/exec/Pcf8574/modinfo.json index e763280b..c3bfd7f4 100644 --- a/src/modules/exec/Pcf8574/modinfo.json +++ b/src/modules/exec/Pcf8574/modinfo.json @@ -50,6 +50,12 @@ ], "esp8285_1mb_ota": [ "adafruit/Adafruit BusIO @ ^1.13.2" + ], + "esp8266_2mb": [ + "adafruit/Adafruit BusIO @ ^1.13.2" + ], + "esp8266_2mb_ota": [ + "adafruit/Adafruit BusIO @ ^1.13.2" ] } } \ No newline at end of file diff --git a/src/modules/exec/Pwm8266/modinfo.json b/src/modules/exec/Pwm8266/modinfo.json index 362ca327..dfd53149 100644 --- a/src/modules/exec/Pwm8266/modinfo.json +++ b/src/modules/exec/Pwm8266/modinfo.json @@ -46,6 +46,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/exec/TelegramLT/modinfo.json b/src/modules/exec/TelegramLT/modinfo.json index 384e23f5..e718fd62 100644 --- a/src/modules/exec/TelegramLT/modinfo.json +++ b/src/modules/exec/TelegramLT/modinfo.json @@ -60,6 +60,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } diff --git a/src/modules/exec/Thermostat/modinfo.json b/src/modules/exec/Thermostat/modinfo.json index 61594db4..9c356ea3 100644 --- a/src/modules/exec/Thermostat/modinfo.json +++ b/src/modules/exec/Thermostat/modinfo.json @@ -134,6 +134,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } diff --git a/src/modules/sensors/AnalogAdc/modinfo.json b/src/modules/sensors/AnalogAdc/modinfo.json index dd0df107..a9a55c17 100644 --- a/src/modules/sensors/AnalogAdc/modinfo.json +++ b/src/modules/sensors/AnalogAdc/modinfo.json @@ -46,6 +46,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/sensors/Bme280/modinfo.json b/src/modules/sensors/Bme280/modinfo.json index 965551f7..5bb6f9b2 100644 --- a/src/modules/sensors/Bme280/modinfo.json +++ b/src/modules/sensors/Bme280/modinfo.json @@ -85,6 +85,24 @@ ], "esp8266_4mb": [ "adafruit/Adafruit BME280 Library" + ], + "esp8266_1mb": [ + "adafruit/Adafruit BME280 Library" + ], + "esp8266_1mb_ota": [ + "adafruit/Adafruit BME280 Library" + ], + "esp8285_1mb": [ + "adafruit/Adafruit BME280 Library" + ], + "esp8285_1mb_ota": [ + "adafruit/Adafruit BME280 Library" + ], + "esp8266_2mb": [ + "adafruit/Adafruit BME280 Library" + ], + "esp8266_2mb_ota": [ + "adafruit/Adafruit BME280 Library" ] } } \ No newline at end of file diff --git a/src/modules/sensors/Bmp280/modinfo.json b/src/modules/sensors/Bmp280/modinfo.json index de46f163..4ce96b66 100644 --- a/src/modules/sensors/Bmp280/modinfo.json +++ b/src/modules/sensors/Bmp280/modinfo.json @@ -64,11 +64,20 @@ "esp8266_1mb_ota": [ "adafruit/Adafruit BMP280 Library" ], + "esp8266_2mb": [ + "adafruit/Adafruit BMP280 Library" + ], "esp8285_1mb": [ "adafruit/Adafruit BMP280 Library" ], "esp8285_1mb_ota": [ "adafruit/Adafruit BMP280 Library" + ], + "esp8266_2mb": [ + "adafruit/Adafruit BMP280 Library" + ], + "esp8266_2mb_ota": [ + "adafruit/Adafruit BMP280 Library" ] } } \ No newline at end of file diff --git a/src/modules/sensors/DS2401/modinfo.json b/src/modules/sensors/DS2401/modinfo.json index 1e241d4e..8364b4f0 100644 --- a/src/modules/sensors/DS2401/modinfo.json +++ b/src/modules/sensors/DS2401/modinfo.json @@ -35,17 +35,13 @@ }, "defActive": false, "usedLibs": { - "esp32_4mb": [ - ], - "esp8266_4mb": [ - ], - "esp8266_1mb": [ - ], - "esp8266_1mb_ota": [ - ], - "esp8285_1mb": [ - ], - "esp8285_1mb_ota": [ - ] + "esp32_4mb": [], + "esp8266_4mb": [], + "esp8266_1mb": [], + "esp8266_1mb_ota": [], + "esp8285_1mb": [], + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/sensors/Ds18b20/modinfo.json b/src/modules/sensors/Ds18b20/modinfo.json index c140839c..9a4519a4 100644 --- a/src/modules/sensors/Ds18b20/modinfo.json +++ b/src/modules/sensors/Ds18b20/modinfo.json @@ -56,6 +56,12 @@ ], "esp8285_1mb_ota": [ "https://github.com/milesburton/Arduino-Temperature-Control-Library" + ], + "esp8266_2mb": [ + "https://github.com/milesburton/Arduino-Temperature-Control-Library" + ], + "esp8266_2mb_ota": [ + "https://github.com/milesburton/Arduino-Temperature-Control-Library" ] } } \ No newline at end of file diff --git a/src/modules/sensors/ExternalMQTT/modinfo.json b/src/modules/sensors/ExternalMQTT/modinfo.json index 090344e1..02c41fb3 100644 --- a/src/modules/sensors/ExternalMQTT/modinfo.json +++ b/src/modules/sensors/ExternalMQTT/modinfo.json @@ -53,6 +53,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } diff --git a/src/modules/sensors/Pzem004t/modinfo.json b/src/modules/sensors/Pzem004t/modinfo.json index f76cf366..56a1fd58 100644 --- a/src/modules/sensors/Pzem004t/modinfo.json +++ b/src/modules/sensors/Pzem004t/modinfo.json @@ -128,6 +128,12 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], - "esp8266_4mb": [] + "esp8266_4mb": [], + "esp8266_1mb": [], + "esp8266_1mb_ota": [], + "esp8285_1mb": [], + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/sensors/RCswitch/modinfo.json b/src/modules/sensors/RCswitch/modinfo.json index a5c6fa3c..dae2a245 100644 --- a/src/modules/sensors/RCswitch/modinfo.json +++ b/src/modules/sensors/RCswitch/modinfo.json @@ -78,6 +78,12 @@ ], "esp8285_1mb_ota": [ "rc-switch @ ^2.6.4" + ], + "esp8266_2mb": [ + "rc-switch @ ^2.6.4" + ], + "esp8266_2mb_ota": [ + "rc-switch @ ^2.6.4" ] } } \ No newline at end of file diff --git a/src/modules/sensors/RTC/modinfo.json b/src/modules/sensors/RTC/modinfo.json index 464dcb9c..3ecef7f7 100644 --- a/src/modules/sensors/RTC/modinfo.json +++ b/src/modules/sensors/RTC/modinfo.json @@ -62,6 +62,8 @@ "esp8266_1mb": ["https://github.com/tremaru/iarduino_RTC"], "esp8266_1mb_ota": ["https://github.com/tremaru/iarduino_RTC"], "esp8285_1mb": ["https://github.com/tremaru/iarduino_RTC"], - "esp8285_1mb_ota": ["https://github.com/tremaru/iarduino_RTC"] + "esp8285_1mb_ota": ["https://github.com/tremaru/iarduino_RTC"], + "esp8266_2mb": ["https://github.com/tremaru/iarduino_RTC"], + "esp8266_2mb_ota": ["https://github.com/tremaru/iarduino_RTC"] } } \ No newline at end of file diff --git a/src/modules/sensors/Sgp30/modinfo.json b/src/modules/sensors/Sgp30/modinfo.json index 4f5c521a..94c59309 100644 --- a/src/modules/sensors/Sgp30/modinfo.json +++ b/src/modules/sensors/Sgp30/modinfo.json @@ -65,6 +65,12 @@ ], "esp8285_1mb_ota": [ "sparkfun/SparkFun SGP30 Arduino Library@^1.0.5" + ], + "esp8266_2mb": [ + "sparkfun/SparkFun SGP30 Arduino Library@^1.0.5" + ], + "esp8266_2mb_ota": [ + "sparkfun/SparkFun SGP30 Arduino Library@^1.0.5" ] } } \ No newline at end of file diff --git a/src/modules/sensors/Sht20/modinfo.json b/src/modules/sensors/Sht20/modinfo.json index aae500a3..39b07e6d 100644 --- a/src/modules/sensors/Sht20/modinfo.json +++ b/src/modules/sensors/Sht20/modinfo.json @@ -66,6 +66,12 @@ ], "esp8285_1mb_ota": [ "robtillaart/SHT2x@^0.1.1" + ], + "esp8266_2mb": [ + "robtillaart/SHT2x@^0.1.1" + ], + "esp8266_2mb_ota": [ + "robtillaart/SHT2x@^0.1.1" ] } } \ No newline at end of file diff --git a/src/modules/sensors/Sht30/modinfo.json b/src/modules/sensors/Sht30/modinfo.json index 9f9647c9..47e42933 100644 --- a/src/modules/sensors/Sht30/modinfo.json +++ b/src/modules/sensors/Sht30/modinfo.json @@ -66,6 +66,12 @@ ], "esp8285_1mb_ota": [ "WEMOS SHT3x@1.0.0" + ], + "esp8266_2mb": [ + "WEMOS SHT3x@1.0.0" + ], + "esp8266_2mb_ota": [ + "WEMOS SHT3x@1.0.0" ] } } \ No newline at end of file diff --git a/src/modules/sensors/Sonar/modinfo.json b/src/modules/sensors/Sonar/modinfo.json index 2aa30e72..8c79734a 100644 --- a/src/modules/sensors/Sonar/modinfo.json +++ b/src/modules/sensors/Sonar/modinfo.json @@ -42,6 +42,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/sensors/UART/modinfo.json b/src/modules/sensors/UART/modinfo.json index 041f2ca1..8ba5ea0a 100644 --- a/src/modules/sensors/UART/modinfo.json +++ b/src/modules/sensors/UART/modinfo.json @@ -9,8 +9,8 @@ "descr": "", "widget": "nil", "id": "u", - "tx": 12, - "rx": 13, + "tx": 4, + "rx": 5, "line": 2, "speed": 9600, "eventFormat": 0 @@ -70,6 +70,19 @@ ], "esp8266_4mb": [ "plerup/EspSoftwareSerial" + ], + "esp8266_1mb": [ + "plerup/EspSoftwareSerial" + ], + "esp8266_1mb_ota": [ + "plerup/EspSoftwareSerial" + ], + "esp8266_2mb": [ + "plerup/EspSoftwareSerial" + ], + "esp8266_2mb_ota": [ + "plerup/EspSoftwareSerial" ] + } } \ No newline at end of file diff --git a/src/modules/virtual/Cron/modinfo.json b/src/modules/virtual/Cron/modinfo.json index ab5eca11..54783e3f 100644 --- a/src/modules/virtual/Cron/modinfo.json +++ b/src/modules/virtual/Cron/modinfo.json @@ -54,6 +54,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/virtual/Loging/modinfo.json b/src/modules/virtual/Loging/modinfo.json index 53a962f7..8fbdcbe3 100644 --- a/src/modules/virtual/Loging/modinfo.json +++ b/src/modules/virtual/Loging/modinfo.json @@ -51,6 +51,12 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], - "esp8266_4mb": [] + "esp8266_4mb": [], + "esp8266_1mb": [], + "esp8266_1mb_ota": [], + "esp8285_1mb": [], + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/virtual/LogingDaily/modinfo.json b/src/modules/virtual/LogingDaily/modinfo.json index 1f4edd66..8118c82a 100644 --- a/src/modules/virtual/LogingDaily/modinfo.json +++ b/src/modules/virtual/LogingDaily/modinfo.json @@ -44,6 +44,12 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], - "esp8266_4mb": [] + "esp8266_4mb": [], + "esp8266_1mb": [], + "esp8266_1mb_ota": [], + "esp8285_1mb": [], + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/virtual/Timer/modinfo.json b/src/modules/virtual/Timer/modinfo.json index 7f097b29..def3437c 100644 --- a/src/modules/virtual/Timer/modinfo.json +++ b/src/modules/virtual/Timer/modinfo.json @@ -74,6 +74,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/virtual/VButton/modinfo.json b/src/modules/virtual/VButton/modinfo.json index 2f233598..36e5fabf 100644 --- a/src/modules/virtual/VButton/modinfo.json +++ b/src/modules/virtual/VButton/modinfo.json @@ -40,6 +40,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/virtual/Variable/modinfo.json b/src/modules/virtual/Variable/modinfo.json index 4c2bfbfa..2a50d1c2 100644 --- a/src/modules/virtual/Variable/modinfo.json +++ b/src/modules/virtual/Variable/modinfo.json @@ -100,6 +100,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/virtual/VariableColor/modinfo.json b/src/modules/virtual/VariableColor/modinfo.json index 7a2a6d72..e03c1ff9 100644 --- a/src/modules/virtual/VariableColor/modinfo.json +++ b/src/modules/virtual/VariableColor/modinfo.json @@ -41,6 +41,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } \ No newline at end of file diff --git a/src/modules/virtual/Weather/modinfo.json b/src/modules/virtual/Weather/modinfo.json index 0530ebdf..cbdad91f 100644 --- a/src/modules/virtual/Weather/modinfo.json +++ b/src/modules/virtual/Weather/modinfo.json @@ -48,6 +48,8 @@ "esp8266_1mb": [], "esp8266_1mb_ota": [], "esp8285_1mb": [], - "esp8285_1mb_ota": [] + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] } } From 471a9d94bf26884779c8de7c32cda3a16f2109ce Mon Sep 17 00:00:00 2001 From: Mit4el Date: Mon, 3 Apr 2023 21:44:07 +0300 Subject: [PATCH 13/15] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8?= =?UTF-8?q?=D0=B7=D0=B8=D1=83=D0=B5=D0=BC=20Pzem,=20=D0=BD=D0=B5=D1=82=20?= =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20UART?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/Pzem004t/PZEMSensor.h | 3 +- src/modules/sensors/Pzem004t/Pzem004t.cpp | 124 +++++++++++++--------- 2 files changed, 75 insertions(+), 52 deletions(-) diff --git a/src/modules/sensors/Pzem004t/PZEMSensor.h b/src/modules/sensors/Pzem004t/PZEMSensor.h index 25ddf175..d76dfc5c 100644 --- a/src/modules/sensors/Pzem004t/PZEMSensor.h +++ b/src/modules/sensors/Pzem004t/PZEMSensor.h @@ -30,9 +30,10 @@ class PZEMSensor { bool search(); // Get most up to date values from device registers and cache them bool refresh(); + void updateSerial(Stream *serial) {_serial = serial;} private: - void init(void); + void init(void); private: PZEM_Info _values; // Measured values diff --git a/src/modules/sensors/Pzem004t/Pzem004t.cpp b/src/modules/sensors/Pzem004t/Pzem004t.cpp index 1cfccaa8..22975387 100644 --- a/src/modules/sensors/Pzem004t/Pzem004t.cpp +++ b/src/modules/sensors/Pzem004t/Pzem004t.cpp @@ -1,23 +1,25 @@ - + #include "Global.h" #include "classes/IoTItem.h" #include "PZEMSensor.h" #include "modules/sensors/UART/Uart.h" +#include + +// глобальные списки необходимы для хранения объектов об экземплярах Pzem . Ключ - адрес +std::map pzemSensorArray; +//PZEMContainer _pzemCntr; + + class Pzem004v : public IoTItem { private: String addr; - PZEMSensor* pzem; + PZEMSensor* pzem = nullptr; public: - Pzem004v(String parameters) : IoTItem(parameters) { - addr = jsonReadStr(parameters, "addr"); - if (myUART) { - pzem = new PZEMSensor(myUART, hexStringToUint8(addr)); - // раскомментируйте эту строку если нужно поменять адрес pzem - // SerialPrint("i", "Pzem", String(pzem->setAddress(0x03))); - } + Pzem004v(PZEMSensor* _pzem, String parameters) : IoTItem(parameters) { + pzem = _pzem; } void doByInterval() { @@ -30,6 +32,9 @@ class Pzem004v : public IoTItem { regEvent(NAN, "Pzem V"); SerialPrint("E", "Pzem", "V error", _id); } + } else { + regEvent(NAN, "Pzem V"); + SerialPrint("E", "Pzem", "V error", _id); } } @@ -39,14 +44,11 @@ class Pzem004v : public IoTItem { class Pzem004a : public IoTItem { private: String addr; - PZEMSensor* pzem; + PZEMSensor* pzem = nullptr; public: - Pzem004a(String parameters) : IoTItem(parameters) { - addr = jsonReadStr(parameters, "addr"); - if (myUART) { - pzem = new PZEMSensor(myUART, hexStringToUint8(addr)); - } + Pzem004a(PZEMSensor* _pzem, String parameters) : IoTItem(parameters) { + pzem = _pzem; } void doByInterval() { @@ -59,6 +61,9 @@ class Pzem004a : public IoTItem { regEvent(NAN, "Pzem A"); SerialPrint("E", "Pzem", "A error", _id); } + } else { + regEvent(NAN, "Pzem V"); + SerialPrint("E", "Pzem", "V error", _id); } } @@ -68,14 +73,11 @@ class Pzem004a : public IoTItem { class Pzem004w : public IoTItem { private: String addr; - PZEMSensor* pzem; + PZEMSensor* pzem = nullptr; public: - Pzem004w(String parameters) : IoTItem(parameters) { - addr = jsonReadStr(parameters, "addr"); - if (myUART) { - pzem = new PZEMSensor(myUART, hexStringToUint8(addr)); - } + Pzem004w(PZEMSensor* _pzem, String parameters) : IoTItem(parameters) { + pzem = _pzem; } void doByInterval() { @@ -88,6 +90,9 @@ class Pzem004w : public IoTItem { regEvent(NAN, "Pzem W"); SerialPrint("E", "Pzem", "W error", _id); } + } else { + regEvent(NAN, "Pzem V"); + SerialPrint("E", "Pzem", "V error", _id); } } @@ -97,14 +102,11 @@ class Pzem004w : public IoTItem { class Pzem004wh : public IoTItem { private: String addr; - PZEMSensor* pzem; + PZEMSensor* pzem = nullptr; public: - Pzem004wh(String parameters) : IoTItem(parameters) { - addr = jsonReadStr(parameters, "addr"); - if (myUART) { - pzem = new PZEMSensor(myUART, hexStringToUint8(addr)); - } + Pzem004wh(PZEMSensor* _pzem, String parameters) : IoTItem(parameters) { + pzem = _pzem; } void doByInterval() { @@ -117,6 +119,9 @@ class Pzem004wh : public IoTItem { regEvent(NAN, "Pzem Wh"); SerialPrint("E", "Pzem", "Wh error", _id); } + } else { + regEvent(NAN, "Pzem V"); + SerialPrint("E", "Pzem", "V error", _id); } } @@ -126,14 +131,11 @@ class Pzem004wh : public IoTItem { class Pzem004hz : public IoTItem { private: String addr; - PZEMSensor* pzem; + PZEMSensor* pzem = nullptr; public: - Pzem004hz(String parameters) : IoTItem(parameters) { - addr = jsonReadStr(parameters, "addr"); - if (myUART) { - pzem = new PZEMSensor(myUART, hexStringToUint8(addr)); - } + Pzem004hz(PZEMSensor* _pzem, String parameters) : IoTItem(parameters) { + pzem = _pzem; } void doByInterval() { @@ -146,6 +148,9 @@ class Pzem004hz : public IoTItem { regEvent(NAN, "Pzem Hz"); SerialPrint("E", "Pzem", "Hz error", _id); } + } else { + regEvent(NAN, "Pzem V"); + SerialPrint("E", "Pzem", "V error", _id); } } @@ -155,14 +160,11 @@ class Pzem004hz : public IoTItem { class Pzem004pf : public IoTItem { private: String addr; - PZEMSensor* pzem; + PZEMSensor* pzem = nullptr; public: - Pzem004pf(String parameters) : IoTItem(parameters) { - addr = jsonReadStr(parameters, "addr"); - if (myUART) { - pzem = new PZEMSensor(myUART, hexStringToUint8(addr)); - } + Pzem004pf(PZEMSensor* _pzem, String parameters) : IoTItem(parameters) { + pzem = _pzem; } void doByInterval() { @@ -175,6 +177,9 @@ class Pzem004pf : public IoTItem { regEvent(NAN, "Pzem Pf"); SerialPrint("E", "Pzem", "Pf error", _id); } + } else { + regEvent(NAN, "Pzem V"); + SerialPrint("E", "Pzem", "V error", _id); } } @@ -187,17 +192,17 @@ class Pzem004cmd : public IoTItem { int changeaddr; String setaddr; int reset; - PZEMSensor* pzem; + PZEMSensor* pzem = nullptr; public: - Pzem004cmd(String parameters) : IoTItem(parameters) { + Pzem004cmd(PZEMSensor* _pzem, String parameters) : IoTItem(parameters) { jsonRead(parameters, F("addr"), addr); jsonRead(parameters, F("changeaddr"), changeaddr); jsonRead(parameters, F("setaddr"), setaddr); jsonRead(parameters, F("reset"), reset); - if (myUART) { - pzem = new PZEMSensor(myUART, hexStringToUint8(addr)); + pzem = _pzem; + if (pzem && myUART) { if (changeaddr == 1) { if (pzem->setAddress(hexStringToUint8(setaddr))) { SerialPrint("i", "Pzem", "address set: " + setaddr); @@ -212,7 +217,7 @@ class Pzem004cmd : public IoTItem { SerialPrint("i", "Pzem", "reset error"); } } - } + } else SerialPrint("i", "Pzem", "Pzem command error"); } void doByInterval() { @@ -224,20 +229,37 @@ class Pzem004cmd : public IoTItem { }; void* getAPI_Pzem004(String subtype, String param) { + PZEMSensor *pzem = nullptr; + if (myUART) { + if (subtype == F("Pzem004v") || subtype == F("Pzem004a") || subtype == F("Pzem004w") + || subtype == F("Pzem004wh") || subtype == F("Pzem004hz") || subtype == F("Pzem004pf") + || subtype == F("Pzem004cmd") ) { + String addr; + jsonRead(param, "addr", addr); + if (pzemSensorArray.find(addr) == pzemSensorArray.end()) { + // pzem = new PZEMSensor(myUART, hexStringToUint8(addr)); + pzemSensorArray[addr] = new PZEMSensor(myUART, hexStringToUint8(addr)); + } else { + pzemSensorArray[addr]->updateSerial(myUART); + } + pzem = pzemSensorArray[addr]; + } + } + if (subtype == F("Pzem004v")) { - return new Pzem004v(param); + return new Pzem004v(pzem, param); } else if (subtype == F("Pzem004a")) { - return new Pzem004a(param); + return new Pzem004a(pzem, param); } else if (subtype == F("Pzem004w")) { - return new Pzem004w(param); + return new Pzem004w(pzem, param); } else if (subtype == F("Pzem004wh")) { - return new Pzem004wh(param); + return new Pzem004wh(pzem, param); } else if (subtype == F("Pzem004hz")) { - return new Pzem004hz(param); + return new Pzem004hz(pzem, param); } else if (subtype == F("Pzem004pf")) { - return new Pzem004pf(param); + return new Pzem004pf(pzem, param); } else if (subtype == F("Pzem004cmd")) { - return new Pzem004cmd(param); + return new Pzem004cmd(pzem, param); } else { return nullptr; } From c82197c71df3326c1e90579592ac0c3408a513cc Mon Sep 17 00:00:00 2001 From: Mit4el Date: Fri, 7 Apr 2023 14:26:03 +0300 Subject: [PATCH 14/15] =?UTF-8?q?=D0=98=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D1=83=D0=B5=D0=BC=20ntp=20=D0=B8=D0=B7=20settings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Теперь ntp из settings.json используется --- src/NTP.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NTP.cpp b/src/NTP.cpp index f9f8a4a1..046f1612 100644 --- a/src/NTP.cpp +++ b/src/NTP.cpp @@ -44,7 +44,7 @@ void ntpInit() { } void synchTime() { - configTime(0, 0, "pool.ntp.org", "ru.pool.ntp.org", "pool.ntp.org"); + configTime(0, 0, "pool.ntp.org", "ru.pool.ntp.org", jsonReadStr(settingsFlashJson, F("ntp")).c_str()); } //событие смены даты From 293f0369f9311bec649162e431271e5ac9c2dc93 Mon Sep 17 00:00:00 2001 From: biver Date: Fri, 7 Apr 2023 20:54:50 +0300 Subject: [PATCH 15/15] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=B2=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D0=BC=20=D1=80=D0=B5=D0=BF=D1=83=20=D0=BA=208266=5F4mb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_svelte/items.json | 4 ++-- platformio.ini | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/data_svelte/items.json b/data_svelte/items.json index 8a7927f8..c5190460 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -574,8 +574,8 @@ "descr": "", "widget": "nil", "id": "u", - "tx": 12, - "rx": 13, + "tx": 4, + "rx": 5, "line": 2, "speed": 9600, "eventFormat": 0, diff --git a/platformio.ini b/platformio.ini index bf13dc11..7ba76a98 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1,6 +1,6 @@ [platformio] -default_envs = esp8266_2mb_ota -data_dir = data_svelte_lite +default_envs = esp8266_4mb +data_dir = data_svelte [common_env_data] lib_deps_external = @@ -302,7 +302,21 @@ build_src_filter = [env:esp8266_4mb_fromitems] lib_deps = + https://github.com/enjoyneering/AHTxx.git + adafruit/Adafruit BME280 Library + adafruit/Adafruit BMP280 Library + beegee-tokyo/DHT sensor library for ESPx + https://github.com/milesburton/Arduino-Temperature-Control-Library + https://github.com/tremaru/iarduino_RTC + robtillaart/SHT2x@^0.1.1 + WEMOS SHT3x@1.0.0 plerup/EspSoftwareSerial + adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 + adafruit/Adafruit BusIO @ ^1.13.2 + dfrobot/DFRobotDFPlayerMini @ ^1.0.5 + adafruit/Adafruit BusIO @ ^1.13.2 + https://github.com/robotclass/RobotClass_LiquidCrystal_I2C + marcoschwartz/LiquidCrystal_I2C@^1.1.4 build_src_filter = + + @@ -311,9 +325,29 @@ build_src_filter = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [env:esp32_4mb_fromitems] lib_deps =