Skip to content

Commit

Permalink
adapt esp plattform using KNX_NETIF
Browse files Browse the repository at this point in the history
  • Loading branch information
Ing-Dom committed Nov 25, 2024
1 parent 2cd5a28 commit 5528888
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
19 changes: 14 additions & 5 deletions src/esp32_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <WiFi.h>
#define KNX_NETIF WiFi
#endif

Esp32Platform::Esp32Platform()
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions src/esp32_platform.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifdef ARDUINO_ARCH_ESP32
#include "arduino_platform.h"
#include <WiFi.h>
#include <WiFiUdp.h>



#include <WiFiUdp.h>

class Esp32Platform : public ArduinoPlatform
{
public:
Expand Down

0 comments on commit 5528888

Please sign in to comment.