From 4a21d3270da745abf94c121f5b95dd09ecb5b24b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 7 Nov 2018 15:37:06 +0100 Subject: [PATCH] Restrict hardware serial Restrict hardware serial --- lib/TasmotaSerial-2.2.0/src/TasmotaSerial.cpp | 4 ++-- lib/TasmotaSerial-2.2.0/src/TasmotaSerial.h | 2 +- sonoff/xdrv_16_tuyadimmer.ino | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/TasmotaSerial-2.2.0/src/TasmotaSerial.cpp b/lib/TasmotaSerial-2.2.0/src/TasmotaSerial.cpp index 7e6ddf72f..3df42f834 100644 --- a/lib/TasmotaSerial-2.2.0/src/TasmotaSerial.cpp +++ b/lib/TasmotaSerial-2.2.0/src/TasmotaSerial.cpp @@ -76,7 +76,7 @@ static void (*ISRList[16])() = { tms_isr_15 }; -TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, bool hardware_fallback) +TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback) { m_valid = false; m_hardserial = 0; @@ -91,7 +91,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, bool hardware_fa if (hardware_fallback && (((3 == m_rx_pin) && (1 == m_tx_pin)) || ((3 == m_rx_pin) && (-1 == m_tx_pin)) || ((-1 == m_rx_pin) && (1 == m_tx_pin)))) { m_hardserial = 1; } - else if (hardware_fallback && (((13 == m_rx_pin) && (15 == m_tx_pin)) || ((13 == m_rx_pin) && (-1 == m_tx_pin)) || ((-1 == m_rx_pin) && (15 == m_tx_pin)))) { + else if ((2 == hardware_fallback) && (((13 == m_rx_pin) && (15 == m_tx_pin)) || ((13 == m_rx_pin) && (-1 == m_tx_pin)) || ((-1 == m_rx_pin) && (15 == m_tx_pin)))) { m_hardserial = 1; m_hardswap = 1; } diff --git a/lib/TasmotaSerial-2.2.0/src/TasmotaSerial.h b/lib/TasmotaSerial-2.2.0/src/TasmotaSerial.h index 3136a8e46..de991526a 100644 --- a/lib/TasmotaSerial-2.2.0/src/TasmotaSerial.h +++ b/lib/TasmotaSerial-2.2.0/src/TasmotaSerial.h @@ -38,7 +38,7 @@ class TasmotaSerial : public Stream { public: - TasmotaSerial(int receive_pin, int transmit_pin, bool hardware_fallback = false); + TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0); virtual ~TasmotaSerial(); bool begin(long speed, int stop_bits = 1); diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index c8bf04961..71f5374d8 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -284,7 +284,7 @@ void TuyaInit() if (!Settings.param[P_TUYA_DIMMER_ID]) { Settings.param[P_TUYA_DIMMER_ID] = TUYA_DIMMER_ID; } - TuyaSerial = new TasmotaSerial(pin[GPIO_TUYA_RX], pin[GPIO_TUYA_TX], 1); + TuyaSerial = new TasmotaSerial(pin[GPIO_TUYA_RX], pin[GPIO_TUYA_TX], 2); if (TuyaSerial->begin(9600)) { if (TuyaSerial->hardwareSerial()) { ClaimSerial(); } // Get MCU Configuration