Refactors ntp service

This commit is contained in:
Rune Harlyk
2024-11-07 16:36:15 +01:00
committed by Rune Harlyk
parent 10b0aa3c45
commit 3a3de53752
10 changed files with 185 additions and 272 deletions
+31
View File
@@ -0,0 +1,31 @@
#ifndef NTPService_h
#define NTPService_h
#include <ESPFS.h>
#include <FSPersistence.h>
#include <WiFi.h>
#include <stateful_service_endpoint.h>
#include <domain/ntp_settings.h>
#include <lwip/apps/sntp.h>
#include <time.h>
class NTPService : public StatefulService<NTPSettings> {
public:
NTPService();
void begin();
static esp_err_t getStatus(PsychicRequest *request);
static esp_err_t handleTime(PsychicRequest *request, JsonVariant &json);
StatefulHttpEndpoint<NTPSettings> endpoint;
private:
FSPersistence<NTPSettings> _persistence;
void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
void onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info);
void configureNTP();
};
#endif // end NTPService_h