mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
Merge pull request #228 from biveraxe/ver4dev
Корректируем алгоритм приема сообщений по UART
This commit is contained in:
@@ -106,7 +106,7 @@ void setup() {
|
|||||||
for (std::list<IoTItem *>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
for (std::list<IoTItem *>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||||
(*it)->checkIntFromNet();
|
(*it)->checkIntFromNet();
|
||||||
|
|
||||||
Serial.printf("[ITEM] size: %d, id: %s, int: %d, intnet: %d\n", sizeof(**it), (*it)->getID(), (*it)->getInterval(), (*it)->getIntFromNet());
|
//Serial.printf("[ITEM] size: %d, id: %s, int: %d, intnet: %d\n", sizeof(**it), (*it)->getID(), (*it)->getInterval(), (*it)->getIntFromNet());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
|
|||||||
@@ -54,11 +54,9 @@ class UART : public IoTItem {
|
|||||||
|
|
||||||
case 2: // формат команд от Nextion ID=Value
|
case 2: // формат команд от Nextion ID=Value
|
||||||
String id = selectToMarker(msg, "=");
|
String id = selectToMarker(msg, "=");
|
||||||
IoTItem *item = findIoTItem(id);
|
|
||||||
if (!item) return;
|
|
||||||
String valStr = selectToMarkerLast(msg, "=");
|
String valStr = selectToMarkerLast(msg, "=");
|
||||||
valStr.replace("\"", "");
|
valStr.replace("\"", "");
|
||||||
item->setValue(valStr);
|
generateOrder(id, valStr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,12 +67,21 @@ class UART : public IoTItem {
|
|||||||
if (_myUART->available()) {
|
if (_myUART->available()) {
|
||||||
static String inStr = "";
|
static String inStr = "";
|
||||||
char inc;
|
char inc;
|
||||||
|
|
||||||
inc = _myUART->read();
|
inc = _myUART->read();
|
||||||
inStr += inc;
|
if (inc == 0xFF) {
|
||||||
|
inc = _myUART->read();
|
||||||
|
inc = _myUART->read();
|
||||||
|
inStr = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inc == '\r') return;
|
||||||
|
|
||||||
if (inc == '\n') {
|
if (inc == '\n') {
|
||||||
analyzeString(inStr);
|
analyzeString(inStr);
|
||||||
inStr = "";
|
inStr = "";
|
||||||
}
|
} else inStr += inc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user