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;
}
void ArduinoPlatform::setUart( HardwareSerial& serial )
{
_knxSerial = serial;
}
HardwareSerial& ArduinoPlatform::getUart()
{
return _knxSerial;
}
void ArduinoPlatform::setupUart()
{
_knxSerial.begin(19200, SERIAL_8E1);

View File

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

View File

@ -6,8 +6,11 @@
#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;
public:
Esp32Platform();
Esp32Platform( HardwareSerial& s);
// ip stuff
uint32_t currentIpAddress() override;

View File

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

View File

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

View File

@ -8,12 +8,13 @@ KnxFacade<SamdPlatform, Bau07B0> knx;
#elif ARDUINO_ARCH_ESP8266
KnxFacade<EspPlatform, Bau57B0> knx;
#elif ARDUINO_ARCH_ESP32
//KnxFacade<Esp32Platform, Bau57B0> knx;
KnxFacade<Esp32Platform, Bau57B0> knx;
#elif __linux__
#define ICACHE_RAM_ATTR
#endif
ICACHE_RAM_ATTR void buttonUp()
ICACHE_RAM_ATTR void buttonUp()
{
#ifndef __linux__
knx._toogleProgMode = true;

View File

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

View File

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