Исправляем баг с выбором железного UART для ESP32

This commit is contained in:
2022-11-10 00:39:18 +05:00
parent c4ca01484b
commit 32a04e48f3
2 changed files with 6 additions and 5 deletions

View File

@@ -13,9 +13,6 @@
class UART : public IoTItem {
private:
int _tx;
int _rx;
int _speed;
int _eventFormat = 0; // 0 - нет приема, 1 - json IoTM, 2 - Nextion
#ifdef ESP8266
@@ -26,17 +23,19 @@ class UART : public IoTItem {
public:
UART(String parameters) : IoTItem(parameters) {
int _tx, _rx, _speed, _line;
jsonRead(parameters, "tx", _tx);
jsonRead(parameters, "rx", _rx);
jsonRead(parameters, "speed", _speed);
jsonRead(parameters, "line", _line);
jsonRead(parameters, "eventFormat", _eventFormat);
#ifdef ESP8266
myUART = _myUART = new SoftwareSerial(_tx, _rx);
myUART = _myUART = new SoftwareSerial(_rx, _tx);
_myUART->begin(_speed);
#endif
#ifdef ESP32
myUART = _myUART = new HardwareSerial(2);
myUART = _myUART = new HardwareSerial(_line);
_myUART->begin(_speed, SERIAL_8N1, _rx, _tx);
#endif
}

View File

@@ -11,6 +11,7 @@
"id": "u",
"tx": 12,
"rx": 13,
"line": 2,
"speed": 9600,
"eventFormat": 0
}
@@ -35,6 +36,7 @@
"tx": "TX пин",
"rx": "RX пин",
"speed": "Скорость UART",
"line": "Актуально только для ESP32: номер линии hardUART. =2 rx=16 tx=17",
"eventFormat": "Выбор формата обмена сообщениями с другими контроллерами. =0 - не указан формат, значит не следим за событиями, =1 - формат событий IoTM с использованием json, =2 - формат событий для Nextion отправка событий: ID.val=Value0xFF0xFF0xFF прием ордеров: ID=Value. Отправляться будут события тех элементов, которые имеют суффикс в ИД _val или _txt, которые влияют на передаваемый формат."
},
"retInfo": "Содержит полученное последнее по UART сообщение.",