setter/getter & overloaded constructor (ArduinoPlatform) for HardwareSerial-object (#31)

* added overload to platform constructors for custom HardwareSerial-object

* added setter/getter setUart & getUart

* set Serial1 as default UART for ESP32
This commit is contained in:
Fabian Schmieder 2019-09-01 20:49:28 +02:00 committed by thelsing
parent cdcfbb4e83
commit 8d5dc5bf73
9 changed files with 29 additions and 2 deletions

View File

@ -68,6 +68,16 @@ int ArduinoPlatform::readBytes(uint8_t * buffer, uint16_t maxLen)
return 0; return 0;
} }
void ArduinoPlatform::setUart( HardwareSerial& serial )
{
_knxSerial = serial;
}
HardwareSerial& ArduinoPlatform::getUart()
{
return _knxSerial;
}
void ArduinoPlatform::setupUart() void ArduinoPlatform::setupUart()
{ {
_knxSerial.begin(19200, SERIAL_8E1); _knxSerial.begin(19200, SERIAL_8E1);

View File

@ -25,6 +25,8 @@ class ArduinoPlatform : public Platform
int readBytes(uint8_t* buffer, uint16_t maxLen); int readBytes(uint8_t* buffer, uint16_t maxLen);
//uart //uart
virtual void setUart( HardwareSerial& serial );
virtual HardwareSerial& getUart();
virtual void setupUart(); virtual void setupUart();
virtual void closeUart(); virtual void closeUart();
virtual int uartAvailable(); virtual int uartAvailable();

View File

@ -6,8 +6,11 @@
#include "knx/bits.h" #include "knx/bits.h"
Esp32Platform::Esp32Platform() : ArduinoPlatform(Serial1)
{
}
Esp32Platform::Esp32Platform() : ArduinoPlatform(Serial) Esp32Platform::Esp32Platform( HardwareSerial& s) : ArduinoPlatform(s)
{ {
} }

View File

@ -11,6 +11,7 @@ class Esp32Platform : public ArduinoPlatform
using ArduinoPlatform::_mulitcastPort; using ArduinoPlatform::_mulitcastPort;
public: public:
Esp32Platform(); Esp32Platform();
Esp32Platform( HardwareSerial& s);
// ip stuff // ip stuff
uint32_t currentIpAddress() override; uint32_t currentIpAddress() override;

View File

@ -11,6 +11,10 @@ EspPlatform::EspPlatform() : ArduinoPlatform(Serial)
{ {
} }
EspPlatform::EspPlatform( HardwareSerial& s) : ArduinoPlatform(s)
{
}
uint32_t EspPlatform::currentIpAddress() uint32_t EspPlatform::currentIpAddress()
{ {
return WiFi.localIP(); return WiFi.localIP();

View File

@ -12,6 +12,7 @@ class EspPlatform : public ArduinoPlatform
public: public:
EspPlatform(); EspPlatform();
EspPlatform( HardwareSerial& s);
// ip stuff // ip stuff
uint32_t currentIpAddress() override; uint32_t currentIpAddress() override;

View File

@ -8,6 +8,7 @@ KnxFacade<SamdPlatform, Bau07B0> knx;
#elif ARDUINO_ARCH_ESP8266 #elif ARDUINO_ARCH_ESP8266
KnxFacade<EspPlatform, Bau57B0> knx; KnxFacade<EspPlatform, Bau57B0> knx;
#elif ARDUINO_ARCH_ESP32 #elif ARDUINO_ARCH_ESP32
//KnxFacade<Esp32Platform, Bau57B0> knx;
KnxFacade<Esp32Platform, Bau57B0> knx; KnxFacade<Esp32Platform, Bau57B0> knx;
#elif __linux__ #elif __linux__
#define ICACHE_RAM_ATTR #define ICACHE_RAM_ATTR

View File

@ -10,6 +10,10 @@ SamdPlatform::SamdPlatform() : ArduinoPlatform(Serial1)
{ {
} }
SamdPlatform::SamdPlatform( HardwareSerial& s) : ArduinoPlatform(s)
{
}
void SamdPlatform::restart() void SamdPlatform::restart()
{ {
SerialDBG.println("restart"); SerialDBG.println("restart");

View File

@ -10,6 +10,7 @@ class SamdPlatform : public ArduinoPlatform
{ {
public: public:
SamdPlatform(); SamdPlatform();
SamdPlatform( HardwareSerial& s);
void restart(); void restart();
uint8_t* getEepromBuffer(uint16_t size); uint8_t* getEepromBuffer(uint16_t size);