fix uart bk7231n

This commit is contained in:
Mit4el
2025-03-27 23:11:34 +03:00
parent f5ba827488
commit 6765f265ac
2 changed files with 8 additions and 2 deletions

View File

@@ -28,6 +28,8 @@ class IoTUart : public IoTItem {
protected: protected:
#ifdef ESP8266 #ifdef ESP8266
SoftwareSerial* _myUART; SoftwareSerial* _myUART;
#elif LIBRETINY
SerialClass* _myUART;
#else #else
Stream* _myUART; Stream* _myUART;
#endif #endif

View File

@@ -9,11 +9,11 @@ IoTUart::IoTUart(const String& parameters) : IoTItem(parameters) {
jsonRead(parameters, "speed", _speed); jsonRead(parameters, "speed", _speed);
jsonRead(parameters, "line", _line); jsonRead(parameters, "line", _line);
#ifdef ESP8266 #if defined (ESP8266)
_myUART = new SoftwareSerial(_rx, _tx); _myUART = new SoftwareSerial(_rx, _tx);
_myUART->begin(_speed); _myUART->begin(_speed);
#endif #endif
#ifdef ESP32 #if defined (ESP32)
if (_line >= 0) { if (_line >= 0) {
_myUART = new HardwareSerial(_line); _myUART = new HardwareSerial(_line);
((HardwareSerial*)_myUART)->begin(_speed, SERIAL_8N1, _rx, _tx); ((HardwareSerial*)_myUART)->begin(_speed, SERIAL_8N1, _rx, _tx);
@@ -22,6 +22,10 @@ IoTUart::IoTUart(const String& parameters) : IoTItem(parameters) {
((SoftwareSerial*)_myUART)->begin(_speed); ((SoftwareSerial*)_myUART)->begin(_speed);
} }
#endif #endif
#if defined (LIBRETINY)
_myUART = new SerialClass(_rx, _tx);
_myUART->begin((unsigned long)_speed);
#endif
} }
void IoTUart::loop() { void IoTUart::loop() {