🪄 Formats NTP related service

This commit is contained in:
Rune Harlyk
2024-07-09 20:06:21 +02:00
committed by Rune Harlyk
parent 33e1a28223
commit 42eafde631
4 changed files with 34 additions and 70 deletions
+7 -11
View File
@@ -43,24 +43,21 @@
#define TIME_PATH "/api/time"
class NTPSettings
{
public:
class NTPSettings {
public:
bool enabled;
String tzLabel;
String tzFormat;
String server;
static void read(NTPSettings &settings, JsonObject &root)
{
static void read(NTPSettings &settings, JsonObject &root) {
root["enabled"] = settings.enabled;
root["server"] = settings.server;
root["tz_label"] = settings.tzLabel;
root["tz_format"] = settings.tzFormat;
}
static StateUpdateResult update(JsonObject &root, NTPSettings &settings)
{
static StateUpdateResult update(JsonObject &root, NTPSettings &settings) {
settings.enabled = root["enabled"] | FACTORY_NTP_ENABLED;
settings.server = root["server"] | FACTORY_NTP_SERVER;
settings.tzLabel = root["tz_label"] | FACTORY_NTP_TIME_ZONE_LABEL;
@@ -69,14 +66,13 @@ public:
}
};
class NTPSettingsService : public StatefulService<NTPSettings>
{
public:
class NTPSettingsService : public StatefulService<NTPSettings> {
public:
NTPSettingsService(PsychicHttpServer *server, FS *fs, SecurityManager *securityManager);
void begin();
private:
private:
PsychicHttpServer *_server;
SecurityManager *_securityManager;
HttpEndpoint<NTPSettings> _httpEndpoint;