From 8f728a436dd6be474573b99f446257beb30d696a Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Mon, 6 Feb 2023 23:19:20 +0100 Subject: [PATCH] fixed issue with Serial2 validation for ESP32C3 --- library.json | 2 +- library.properties | 2 +- src/Sensors.cpp | 15 ++++++++------- src/Sensors.hpp | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/library.json b/library.json index e595db28..fad06e03 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "CanAirIO Air Quality Sensors Library", - "version": "0.6.5", + "version": "0.6.6", "homepage":"https://canair.io", "keywords": [ diff --git a/library.properties b/library.properties index b32ff321..a60d0b24 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=CanAirIO Air Quality Sensors Library -version=0.6.5 +version=0.6.6 author=@hpsaturn, CanAirIO project maintainer=Antonio Vanegas url=https://github.com/kike-canaries/canairio_sensorlib diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 5b81617e..3c0664ac 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -599,7 +599,7 @@ bool Sensors::pmGenericRead() { String txtMsg = hwSerialRead(lenght_buffer); if (txtMsg[0] == 66) { if (txtMsg[1] == 77) { - DEBUG("-->[SLIB] UART PMGENERIC read \t\t: done!"); + DEBUG("-->[SLIB] UART PMGENERIC read!\t: :D"); pm25 = txtMsg[6] * 256 + (char)(txtMsg[7]); pm10 = txtMsg[8] * 256 + (char)(txtMsg[9]); @@ -1650,7 +1650,7 @@ void Sensors::disableWire1() { } bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, int pms_tx) { - if(devmode)Serial.printf("-->[SLIB] UART init with speed\t: %lu RX:%i TX:%i\n", speed_baud, pms_rx, pms_tx); + if(devmode)Serial.printf("-->[SLIB] UART init with speed\t: %lu TX:%i RX:%i\n", speed_baud, pms_tx, pms_rx); switch (SENSOR_COMMS) { case SERIALPORT: Serial.begin(speed_baud); @@ -1692,8 +1692,8 @@ bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, i Serial1.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx, false); _serial = &Serial1; break; -#ifdef Serial2 case SERIALPORT2: + #if SOC_UART_NUM > 2 DEBUG("-->[SLIB] UART COMM port \t: Serial2"); if (pms_type == SENSORS::SSPS30) Serial2.begin(speed_baud); @@ -1701,10 +1701,11 @@ bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, i Serial2.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx, false); _serial = &Serial2; break; -#else - DEBUG("-->[SLIB] UART COMM port \t: Undefined"); - return false; -#endif // Serial2 + #else + DEBUG("-->[SLIB] Force UART port \t: Serial1"); + Serial1.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx); + _serial = &Serial1; + #endif #endif default: diff --git a/src/Sensors.hpp b/src/Sensors.hpp index f6b040d3..63554cbe 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -21,7 +21,7 @@ #include #endif -#define CSL_VERSION "0.6.5" +#define CSL_VERSION "0.6.6" #define CSL_REVISION 373 /***************************************************************