knx/src/esp_platform.h
croghostrider 59d1b67d6c
add KNX IP discovery support (#141)
for ESP8266 and ESP32
2021-06-04 17:23:23 +02:00

44 lines
1.1 KiB
C++

#ifdef ARDUINO_ARCH_ESP8266
#include "arduino_platform.h"
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
class EspPlatform : public ArduinoPlatform
{
public:
EspPlatform();
EspPlatform(HardwareSerial* s);
// ip stuff
uint32_t currentIpAddress() override;
uint32_t currentSubnetMask() override;
uint32_t currentDefaultGateway() override;
void macAddress(uint8_t* addr) override;
// unique serial number
uint32_t uniqueSerialNumber() override;
// basic stuff
void restart();
//multicast
void setupMultiCast(uint32_t addr, uint16_t port) override;
void closeMultiCast() override;
bool sendBytesMultiCast(uint8_t* buffer, uint16_t len) override;
int readBytesMultiCast(uint8_t* buffer, uint16_t maxLen) override;
//unicast
bool sendBytesUniCast(uint32_t addr, uint16_t port, uint8_t* buffer, uint16_t len) override;
//memory
uint8_t* getEepromBuffer(uint16_t size);
void commitToEeprom();
private:
WiFiUDP _udp;
uint32_t _multicastAddr;
uint16_t _multicastPort;
};
#endif