adapt esp plattform using KNX_NETIF

This commit is contained in:
Ing-Dom 2024-11-21 07:34:42 +01:00 committed by Dom
parent 2cd5a28d8e
commit 5528888b72
2 changed files with 17 additions and 7 deletions

View File

@ -7,7 +7,16 @@
#include "knx/bits.h" #include "knx/bits.h"
#ifndef KNX_SERIAL #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 <WiFi.h>
#define KNX_NETIF WiFi
#endif #endif
Esp32Platform::Esp32Platform() Esp32Platform::Esp32Platform()
@ -43,17 +52,17 @@ void Esp32Platform::setupUart()
uint32_t Esp32Platform::currentIpAddress() uint32_t Esp32Platform::currentIpAddress()
{ {
return WiFi.localIP(); return KNX_NETIF.localIP();
} }
uint32_t Esp32Platform::currentSubnetMask() uint32_t Esp32Platform::currentSubnetMask()
{ {
return WiFi.subnetMask(); return KNX_NETIF.subnetMask();
} }
uint32_t Esp32Platform::currentDefaultGateway() uint32_t Esp32Platform::currentDefaultGateway()
{ {
return WiFi.gatewayIP(); return KNX_NETIF.gatewayIP();
} }
void Esp32Platform::macAddress(uint8_t * addr) void Esp32Platform::macAddress(uint8_t * addr)
@ -80,7 +89,7 @@ void Esp32Platform::setupMultiCast(uint32_t addr, uint16_t port)
IPAddress mcastaddr(htonl(addr)); IPAddress mcastaddr(htonl(addr));
KNX_DEBUG_SERIAL.printf("setup multicast addr: %s port: %d ip: %s\n", mcastaddr.toString().c_str(), port, 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); uint8_t result = _udp.beginMulticast(mcastaddr, port);
KNX_DEBUG_SERIAL.printf("result %d\n", result); KNX_DEBUG_SERIAL.printf("result %d\n", result);
} }

View File

@ -1,9 +1,10 @@
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
#include "arduino_platform.h" #include "arduino_platform.h"
#include <WiFi.h>
#include <WiFiUdp.h>
#include <WiFiUdp.h>
class Esp32Platform : public ArduinoPlatform class Esp32Platform : public ArduinoPlatform
{ {
public: public: