🪄 Formats NTP related service
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user