Fixed RTC and Ethernet drivers, with NTP
This commit is contained in:
46
lib/ETH/ETH_Driver.h
Normal file
46
lib/ETH/ETH_Driver.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#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:
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user