From 604a03e6178d95a82f8dfd6331c7ccef9a10dfdc Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 30 Oct 2020 18:27:34 +0100 Subject: [PATCH] Fix ESP32 serial reconfig Fix ESP32 serial reconfig (#9664) --- tasmota/support.ino | 7 +++++++ tasmota/tasmota.h | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/tasmota/support.ino b/tasmota/support.ino index 697a61015..32187beb0 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -913,7 +913,14 @@ void SetSerialBegin(void) { TasmotaGlobal.baudrate = Settings.baudrate * 300; AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_SERIAL "Set to %s %d bit/s"), GetSerialConfig().c_str(), TasmotaGlobal.baudrate); Serial.flush(); + Serial.end(); + delay(10); // Allow time to cleanup queues - if not used hangs ESP32 +#ifdef ESP8266 Serial.begin(TasmotaGlobal.baudrate, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + Settings.serial_config)); +#else // ESP32 + uint32_t config = pgm_read_dword(kTasmotaSerialConfig + Settings.serial_config); + Serial.begin(TasmotaGlobal.baudrate, config); +#endif } void SetSerialConfig(uint32_t serial_config) { diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index 6a5c4f851..442bf93aa 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -348,6 +348,7 @@ enum TasmotaSerialConfig { TS_SERIAL_5O1, TS_SERIAL_6O1, TS_SERIAL_7O1, TS_SERIAL_8O1, TS_SERIAL_5O2, TS_SERIAL_6O2, TS_SERIAL_7O2, TS_SERIAL_8O2 }; +#ifdef ESP8266 const SerConfu8 kTasmotaSerialConfig[] PROGMEM = { SERIAL_5N1, SERIAL_6N1, SERIAL_7N1, SERIAL_8N1, SERIAL_5N2, SERIAL_6N2, SERIAL_7N2, SERIAL_8N2, @@ -356,6 +357,16 @@ const SerConfu8 kTasmotaSerialConfig[] PROGMEM = { SERIAL_5O1, SERIAL_6O1, SERIAL_7O1, SERIAL_8O1, SERIAL_5O2, SERIAL_6O2, SERIAL_7O2, SERIAL_8O2 }; +#else // ESP32 +const uint32_t kTasmotaSerialConfig[] PROGMEM = { + SERIAL_5N1, SERIAL_6N1, SERIAL_7N1, SERIAL_8N1, + SERIAL_5N2, SERIAL_6N2, SERIAL_7N2, SERIAL_8N2, + SERIAL_5E1, SERIAL_6E1, SERIAL_7E1, SERIAL_8E1, + SERIAL_5E2, SERIAL_6E2, SERIAL_7E2, SERIAL_8E2, + SERIAL_5O1, SERIAL_6O1, SERIAL_7O1, SERIAL_8O1, + SERIAL_5O2, SERIAL_6O2, SERIAL_7O2, SERIAL_8O2 +}; +#endif enum TuyaSupportedFunctions { TUYA_MCU_FUNC_NONE, TUYA_MCU_FUNC_SWT1 = 1, TUYA_MCU_FUNC_SWT2, TUYA_MCU_FUNC_SWT3, TUYA_MCU_FUNC_SWT4,