diff --git a/src/arduino_platform.cpp b/src/arduino_platform.cpp index 169e653..e561a22 100644 --- a/src/arduino_platform.cpp +++ b/src/arduino_platform.cpp @@ -6,9 +6,11 @@ #include #endif +#ifndef KNX_NO_PRINT Stream* ArduinoPlatform::SerialDebug = &Serial; +#endif -ArduinoPlatform::ArduinoPlatform(HardwareSerial* knxSerial) : _knxSerial(knxSerial) +ArduinoPlatform::ArduinoPlatform() : _knxSerial(nullptr) { } @@ -29,7 +31,8 @@ void ArduinoPlatform::fatalError() void ArduinoPlatform::knxUart( HardwareSerial* serial ) { - closeUart(); + if (_knxSerial) + closeUart(); _knxSerial = serial; setupUart(); } diff --git a/src/arduino_platform.h b/src/arduino_platform.h index 33929da..ddf89b0 100644 --- a/src/arduino_platform.h +++ b/src/arduino_platform.h @@ -2,12 +2,10 @@ #include "Arduino.h" -extern Stream& _serialDBG; - class ArduinoPlatform : public Platform { public: - ArduinoPlatform(HardwareSerial* knxSerial); + ArduinoPlatform(); // basic stuff void fatalError(); @@ -29,7 +27,9 @@ class ArduinoPlatform : public Platform void closeSpi() override; int readWriteSpi (uint8_t *data, size_t len) override; #endif +#ifndef KNX_NO_PRINT static Stream* SerialDebug; +#endif protected: HardwareSerial* _knxSerial; diff --git a/src/esp32_platform.cpp b/src/esp32_platform.cpp index cc902dd..535597c 100644 --- a/src/esp32_platform.cpp +++ b/src/esp32_platform.cpp @@ -6,12 +6,11 @@ #include "knx/bits.h" -Esp32Platform::Esp32Platform() : ArduinoPlatform(&Serial1) -{ -} - -Esp32Platform::Esp32Platform(HardwareSerial* s) : ArduinoPlatform(s) +Esp32Platform::Esp32Platform() { +#ifndef KNX_NO_DEFAULT_UART + _knxSerial = &Serial1; +#endif } uint32_t Esp32Platform::currentIpAddress() diff --git a/src/esp32_platform.h b/src/esp32_platform.h index 3c006ba..7faf1c7 100644 --- a/src/esp32_platform.h +++ b/src/esp32_platform.h @@ -8,7 +8,6 @@ class Esp32Platform : public ArduinoPlatform { public: Esp32Platform(); - Esp32Platform(HardwareSerial* s); // ip stuff uint32_t currentIpAddress() override; diff --git a/src/esp_platform.cpp b/src/esp_platform.cpp index f453fea..337ce4e 100644 --- a/src/esp_platform.cpp +++ b/src/esp_platform.cpp @@ -7,12 +7,11 @@ #include "knx/bits.h" -EspPlatform::EspPlatform() : ArduinoPlatform(&Serial) -{ -} - -EspPlatform::EspPlatform( HardwareSerial* s) : ArduinoPlatform(s) +EspPlatform::EspPlatform() { +#ifndef KNX_NO_DEFAULT_UART + _knxSerial = &Serial; +#endif } uint32_t EspPlatform::currentIpAddress() diff --git a/src/esp_platform.h b/src/esp_platform.h index cd026d8..7aa3383 100644 --- a/src/esp_platform.h +++ b/src/esp_platform.h @@ -8,7 +8,6 @@ class EspPlatform : public ArduinoPlatform { public: EspPlatform(); - EspPlatform(HardwareSerial* s); // ip stuff uint32_t currentIpAddress() override; diff --git a/src/samd_platform.cpp b/src/samd_platform.cpp index db94c61..2073fd6 100644 --- a/src/samd_platform.cpp +++ b/src/samd_platform.cpp @@ -6,12 +6,11 @@ #include #include -SamdPlatform::SamdPlatform() : ArduinoPlatform(&Serial1) -{ -} - -SamdPlatform::SamdPlatform( HardwareSerial* s) : ArduinoPlatform(s) +SamdPlatform::SamdPlatform() { +#ifndef KNX_NO_DEFAULT_UART + _knxSerial = &Serial1; +#endif } void SamdPlatform::restart() diff --git a/src/samd_platform.h b/src/samd_platform.h index 6b45c83..ea4d437 100644 --- a/src/samd_platform.h +++ b/src/samd_platform.h @@ -8,7 +8,6 @@ class SamdPlatform : public ArduinoPlatform { public: SamdPlatform(); - SamdPlatform( HardwareSerial* s); void restart(); uint8_t* getEepromBuffer(uint16_t size); diff --git a/src/stm32_platform.cpp b/src/stm32_platform.cpp index e05ab34..ecd3320 100644 --- a/src/stm32_platform.cpp +++ b/src/stm32_platform.cpp @@ -4,12 +4,11 @@ #include #include "knx/bits.h" -Stm32Platform::Stm32Platform() : ArduinoPlatform(&Serial2) -{ -} - -Stm32Platform::Stm32Platform( HardwareSerial* s) : ArduinoPlatform(s) +Stm32Platform::Stm32Platform() { +#ifndef KNX_NO_DEFAULT_UART + _knxSerial = &Serial2; +#endif } Stm32Platform::~Stm32Platform() diff --git a/src/stm32_platform.h b/src/stm32_platform.h index 04870ec..c47a1e1 100644 --- a/src/stm32_platform.h +++ b/src/stm32_platform.h @@ -5,7 +5,6 @@ class Stm32Platform : public ArduinoPlatform { public: Stm32Platform(); - Stm32Platform( HardwareSerial* s); ~Stm32Platform(); // basic stuff