mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	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:
		
							parent
							
								
									cdcfbb4e83
								
							
						
					
					
						commit
						8d5dc5bf73
					
				| @ -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); | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
| @ -6,8 +6,11 @@ | ||||
| 
 | ||||
| #include "knx/bits.h" | ||||
| 
 | ||||
| Esp32Platform::Esp32Platform() : ArduinoPlatform(Serial1) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| Esp32Platform::Esp32Platform() : ArduinoPlatform(Serial) | ||||
| Esp32Platform::Esp32Platform( HardwareSerial& s) : ArduinoPlatform(s) | ||||
| { | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -11,6 +11,7 @@ class Esp32Platform : public ArduinoPlatform | ||||
|     using ArduinoPlatform::_mulitcastPort; | ||||
| public: | ||||
|     Esp32Platform(); | ||||
|     Esp32Platform( HardwareSerial& s); | ||||
| 
 | ||||
|     // ip stuff
 | ||||
|     uint32_t currentIpAddress() override; | ||||
|  | ||||
| @ -11,6 +11,10 @@ EspPlatform::EspPlatform() : ArduinoPlatform(Serial) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| EspPlatform::EspPlatform( HardwareSerial& s) : ArduinoPlatform(s) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| uint32_t EspPlatform::currentIpAddress() | ||||
| { | ||||
|     return WiFi.localIP(); | ||||
|  | ||||
| @ -12,6 +12,7 @@ class EspPlatform : public ArduinoPlatform | ||||
| 
 | ||||
|   public: | ||||
|     EspPlatform(); | ||||
|     EspPlatform( HardwareSerial& s); | ||||
| 
 | ||||
|     // ip stuff
 | ||||
|     uint32_t currentIpAddress() override; | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -10,6 +10,10 @@ SamdPlatform::SamdPlatform() : ArduinoPlatform(Serial1) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| SamdPlatform::SamdPlatform( HardwareSerial& s) : ArduinoPlatform(s) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void SamdPlatform::restart() | ||||
| { | ||||
|     SerialDBG.println("restart"); | ||||
|  | ||||
| @ -10,6 +10,7 @@ class SamdPlatform : public ArduinoPlatform | ||||
| { | ||||
| public: | ||||
|     SamdPlatform(); | ||||
|     SamdPlatform( HardwareSerial& s); | ||||
| 
 | ||||
|     void restart(); | ||||
|     uint8_t* getEepromBuffer(uint16_t size); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user