diff --git a/CHANGELOG.md b/CHANGELOG.md index 20cbb8f5dc82..a89419f03c24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file. - Matter fail to report Shutter status if no shutter is configured in Tasmota - Matter fix Waterleak broken after Berry solidification optimisation #21885 - Berry avoid `readbytes()` from crashing when file is too large +- Zigbee avoid disabling console serial on ESP32 and improved log messages ### Removed - Berry remove reuse of methods for interface-like code reuse #21500 diff --git a/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_9_serial.ino b/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_9_serial.ino index 5decd1e393ad..d6453c24f49a 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_9_serial.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_9_serial.ino @@ -298,13 +298,25 @@ void ZigbeeInitSerial(void) if (PinUsed(GPIO_ZIGBEE_RX) && PinUsed(GPIO_ZIGBEE_TX)) { AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "GPIOs Rx:%d Tx:%d"), Pin(GPIO_ZIGBEE_RX), Pin(GPIO_ZIGBEE_TX)); // if TasmotaGlobal.seriallog_level is 0, we allow GPIO 13/15 to switch to Hardware Serial - ZigbeeSerial = new TasmotaSerial(Pin(GPIO_ZIGBEE_RX), Pin(GPIO_ZIGBEE_TX), TasmotaGlobal.seriallog_level ? 1 : 2, 0, 256); // set a receive buffer of 256 bytes + int32_t uart_num = TasmotaGlobal.seriallog_level ? 1 : 2; + ZigbeeSerial = new TasmotaSerial(Pin(GPIO_ZIGBEE_RX), Pin(GPIO_ZIGBEE_TX), uart_num, 0, 256); // set a receive buffer of 256 bytes + if (ZigbeeSerial == nullptr) { + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Failed to allocate TasmotaSerial - aborting Zigbee")); + return; + } + if (!ZigbeeSerial->isValid()) { + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Invalid Serial GPIOs - aborting Zigbee")); + delete ZigbeeSerial; + return; + } ZigbeeSerial->begin(115200); +#ifdef ESP8266 if (ZigbeeSerial->hardwareSerial()) { ClaimSerial(); } +#endif // ESP8266 #ifdef ESP32 - AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Serial UART%d"), ZigbeeSerial->getUart()); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Using Hardware Serial UART%d"), ZigbeeSerial->getUart()); #endif // ESP32 zigbee_buffer = new SBuffer(ZIGBEE_BUFFER_SIZE);