diff --git a/src/esp32_platform.cpp b/src/esp32_platform.cpp index b0d5b03..845ad11 100644 --- a/src/esp32_platform.cpp +++ b/src/esp32_platform.cpp @@ -7,7 +7,16 @@ #include "knx/bits.h" #ifndef KNX_SERIAL -#define KNX_SERIAL Serial1 + #define KNX_SERIAL Serial1 + #pragma warn "KNX_SERIAL not defined, using Serial1" +#endif + +#ifdef KNX_IP_LAN + #include "Eth.h" + #define KNX_NETIF ETH +#else // KNX_IP_WIFI + #include + #define KNX_NETIF WiFi #endif Esp32Platform::Esp32Platform() @@ -43,17 +52,17 @@ void Esp32Platform::setupUart() uint32_t Esp32Platform::currentIpAddress() { - return WiFi.localIP(); + return KNX_NETIF.localIP(); } uint32_t Esp32Platform::currentSubnetMask() { - return WiFi.subnetMask(); + return KNX_NETIF.subnetMask(); } uint32_t Esp32Platform::currentDefaultGateway() { - return WiFi.gatewayIP(); + return KNX_NETIF.gatewayIP(); } void Esp32Platform::macAddress(uint8_t * addr) @@ -80,7 +89,7 @@ void Esp32Platform::setupMultiCast(uint32_t addr, uint16_t port) IPAddress mcastaddr(htonl(addr)); KNX_DEBUG_SERIAL.printf("setup multicast addr: %s port: %d ip: %s\n", mcastaddr.toString().c_str(), port, - WiFi.localIP().toString().c_str()); + KNX_NETIF.localIP().toString().c_str()); uint8_t result = _udp.beginMulticast(mcastaddr, port); KNX_DEBUG_SERIAL.printf("result %d\n", result); } diff --git a/src/esp32_platform.h b/src/esp32_platform.h index 4318fa4..ffd4e30 100644 --- a/src/esp32_platform.h +++ b/src/esp32_platform.h @@ -1,9 +1,10 @@ #ifdef ARDUINO_ARCH_ESP32 #include "arduino_platform.h" -#include -#include + +#include + class Esp32Platform : public ArduinoPlatform { public: