knxdisplay/main/Hardware/Eth.hpp
2026-02-11 14:21:43 +01:00

39 lines
945 B
C++

#pragma once
#include <string>
#include <vector>
#include <functional>
#include "esp_event.h"
#include "esp_netif.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
struct StaticIpConfig {
uint8_t ip[4];
uint8_t subnet[4];
uint8_t gateway[4];
uint8_t dns[4];
};
class Eth {
public:
static Eth& instance();
void init();
void applyStaticIp(const StaticIpConfig& cfg);
std::string getIPAddress();
private:
Eth() = default;
Eth(const Eth&) = delete;
Eth& operator=(const Eth&) = delete;
static void eventHandler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data);
static void got_ip_event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data);
bool initialized_ = false;
EventGroupHandle_t ethEventGroup_ = nullptr;
esp_netif_t* netif_ = nullptr;
};