Add TasmotaSerial valid pin chk

This commit is contained in:
Theo Arends 2021-03-05 14:36:39 +01:00
parent 5b0b06e1d2
commit 919058ebfd
1 changed files with 2 additions and 0 deletions

View File

@ -68,6 +68,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal
m_hardswap = true;
}
else {
if ((m_rx_pin < 0) && (m_tx_pin < 0)) { return; }
if (m_rx_pin > -1) {
m_buffer = (uint8_t*)malloc(serial_buffer_size);
if (m_buffer == NULL) return;
@ -110,6 +111,7 @@ bool TasmotaSerial::isValidGPIOpin(int pin) {
}
bool TasmotaSerial::begin(uint32_t speed, uint32_t config) {
if (!m_valid) { return false; }
if (config > 2) {
// Legacy support where software serial fakes two stop bits if either stop bits is 2 or parity is not None
m_stop_bits = ((config &0x30) >> 5) +1;