Files
ETcontroller_PRO/lib/ETH/ETH_Driver.h
2025-07-14 11:29:16 +02:00

47 lines
881 B
C++

#pragma once
#include <DebugLog.h>
#include <Arduino.h>
#include <Network.h>
#include <NTPClient.h>
#include <ETH.h>
#include <SPI.h>
// PHY defines hardware related
#ifndef ETH_PHY_TYPE
#define ETH_PHY_TYPE ETH_PHY_W5500
#define ETH_PHY_ADDR 1
#define ETH_PHY_CS 16
#define ETH_PHY_IRQ 12
#define ETH_PHY_RST 39
#endif
// SPI pins
#define ETH_SPI_SCK 15
#define ETH_SPI_MISO 14
#define ETH_SPI_MOSI 13
namespace drivers
{
class Ethernet : public ETHClass
{
public:
Ethernet(const std::string hostname);
~Ethernet();
void onEvent(arduino_event_id_t event, arduino_event_info_t info);
const bool isConnected();
const bool getNtpTime(time_t &time);
private:
const std::string m_hostname;
bool m_connected;
NetworkUDP m_udp;
IPAddress m_localIP;
NTPClient m_timeClient;
};
}