Skip to content

Commit 1080f99

Browse files
committed
adapt esp plattform using KNX_NETIF
1 parent 2cd5a28 commit 1080f99

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/esp32_platform.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@
77
#include "knx/bits.h"
88

99
#ifndef KNX_SERIAL
10-
#define KNX_SERIAL Serial1
10+
#define KNX_SERIAL Serial1
11+
#pragma warn "KNX_SERIAL not defined, using Serial1"
12+
#endif
13+
14+
#ifdef KNX_IP_LAN
15+
#include "Eth.h"
16+
#define KNX_NETIF ETH
17+
#else // KNX_IP_WIFI
18+
#include <WiFi.h>
19+
#define KNX_NETIF WiFi
1120
#endif
1221

1322
Esp32Platform::Esp32Platform()
@@ -43,17 +52,17 @@ void Esp32Platform::setupUart()
4352

4453
uint32_t Esp32Platform::currentIpAddress()
4554
{
46-
return WiFi.localIP();
55+
return KNX_NETIF.localIP();
4756
}
4857

4958
uint32_t Esp32Platform::currentSubnetMask()
5059
{
51-
return WiFi.subnetMask();
60+
return KNX_NETIF.subnetMask();
5261
}
5362

5463
uint32_t Esp32Platform::currentDefaultGateway()
5564
{
56-
return WiFi.gatewayIP();
65+
return KNX_NETIF.gatewayIP();
5766
}
5867

5968
void Esp32Platform::macAddress(uint8_t * addr)
@@ -80,7 +89,7 @@ void Esp32Platform::setupMultiCast(uint32_t addr, uint16_t port)
8089
IPAddress mcastaddr(htonl(addr));
8190

8291
KNX_DEBUG_SERIAL.printf("setup multicast addr: %s port: %d ip: %s\n", mcastaddr.toString().c_str(), port,
83-
WiFi.localIP().toString().c_str());
92+
KNX_NETIF.localIP().toString().c_str());
8493
uint8_t result = _udp.beginMulticast(mcastaddr, port);
8594
KNX_DEBUG_SERIAL.printf("result %d\n", result);
8695
}

src/esp32_platform.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#ifdef ARDUINO_ARCH_ESP32
22
#include "arduino_platform.h"
3-
#include <WiFi.h>
4-
#include <WiFiUdp.h>
53

64

5+
6+
#include <WiFiUdp.h>
7+
78
class Esp32Platform : public ArduinoPlatform
89
{
910
public:

0 commit comments

Comments
 (0)