diff --git a/include/Configuration.h b/include/Configuration.h index 15c037ae..449cf518 100644 --- a/include/Configuration.h +++ b/include/Configuration.h @@ -60,6 +60,8 @@ struct CONFIG_T { char Ntp_Server[NTP_MAX_SERVER_STRLEN + 1]; char Ntp_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1]; char Ntp_TimezoneDescr[NTP_MAX_TIMEZONEDESCR_STRLEN + 1]; + double Ntp_Longitude; + double Ntp_Latitude; bool Mqtt_Enabled; uint Mqtt_Port; diff --git a/include/defaults.h b/include/defaults.h index 69ec960b..2a86d47a 100644 --- a/include/defaults.h +++ b/include/defaults.h @@ -23,6 +23,8 @@ #define NTP_SERVER "pool.ntp.org" #define NTP_TIMEZONE "CET-1CEST,M3.5.0,M10.5.0/3" #define NTP_TIMEZONEDESCR "Europe/Berlin" +#define NTP_LONGITUDE 10.4515f +#define NTP_LATITUDE 51.1657f #define MQTT_ENABLED false #define MQTT_HOST "" diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 8ec7a9e8..eda2dc44 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -44,6 +44,8 @@ bool ConfigurationClass::write() ntp["server"] = config.Ntp_Server; ntp["timezone"] = config.Ntp_Timezone; ntp["timezone_descr"] = config.Ntp_TimezoneDescr; + ntp["latitude"] = config.Ntp_Latitude; + ntp["longitude"] = config.Ntp_Longitude; JsonObject mqtt = doc.createNestedObject("mqtt"); mqtt["enabled"] = config.Mqtt_Enabled; @@ -175,6 +177,8 @@ bool ConfigurationClass::read() strlcpy(config.Ntp_Server, ntp["server"] | NTP_SERVER, sizeof(config.Ntp_Server)); strlcpy(config.Ntp_Timezone, ntp["timezone"] | NTP_TIMEZONE, sizeof(config.Ntp_Timezone)); strlcpy(config.Ntp_TimezoneDescr, ntp["timezone_descr"] | NTP_TIMEZONEDESCR, sizeof(config.Ntp_TimezoneDescr)); + config.Ntp_Latitude = ntp["latitude"] | NTP_LATITUDE; + config.Ntp_Longitude = ntp["longitude"] | NTP_LONGITUDE; JsonObject mqtt = doc["mqtt"]; config.Mqtt_Enabled = mqtt["enabled"] | MQTT_ENABLED; diff --git a/src/WebApi_ntp.cpp b/src/WebApi_ntp.cpp index 53a92e87..12ea4eb6 100644 --- a/src/WebApi_ntp.cpp +++ b/src/WebApi_ntp.cpp @@ -68,6 +68,8 @@ void WebApiNtpClass::onNtpAdminGet(AsyncWebServerRequest* request) root[F("ntp_server")] = config.Ntp_Server; root[F("ntp_timezone")] = config.Ntp_Timezone; root[F("ntp_timezone_descr")] = config.Ntp_TimezoneDescr; + root[F("longitude")] = config.Ntp_Longitude; + root[F("latitude")] = config.Ntp_Latitude; response->setLength(); request->send(response); @@ -112,7 +114,7 @@ void WebApiNtpClass::onNtpAdminPost(AsyncWebServerRequest* request) return; } - if (!(root.containsKey("ntp_server") && root.containsKey("ntp_timezone"))) { + if (!(root.containsKey("ntp_server") && root.containsKey("ntp_timezone") && root.containsKey("longitude") && root.containsKey("latitude"))) { retMsg[F("message")] = F("Values are missing!"); retMsg[F("code")] = WebApiError::GenericValueMissing; response->setLength(); @@ -151,6 +153,8 @@ void WebApiNtpClass::onNtpAdminPost(AsyncWebServerRequest* request) strlcpy(config.Ntp_Server, root[F("ntp_server")].as().c_str(), sizeof(config.Ntp_Server)); strlcpy(config.Ntp_Timezone, root[F("ntp_timezone")].as().c_str(), sizeof(config.Ntp_Timezone)); strlcpy(config.Ntp_TimezoneDescr, root[F("ntp_timezone_descr")].as().c_str(), sizeof(config.Ntp_TimezoneDescr)); + config.Ntp_Latitude = root[F("latitude")].as(); + config.Ntp_Longitude = root[F("longitude")].as(); Configuration.write(); retMsg[F("type")] = F("success"); diff --git a/webapp/src/components/InputElement.vue b/webapp/src/components/InputElement.vue index c2ab2b43..eff8e9f6 100644 --- a/webapp/src/components/InputElement.vue +++ b/webapp/src/components/InputElement.vue @@ -27,6 +27,7 @@ :maxlength="maxlength" :min="min" :max="max" + :step="step" :disabled="disabled" :aria-describedby="descriptionId" /> @@ -69,6 +70,7 @@ export default defineComponent({ 'maxlength': String, 'min': String, 'max': String, + 'step': String, 'rows': String, 'disabled': Boolean, 'postfix': String, diff --git a/webapp/src/locales/de.json b/webapp/src/locales/de.json index 711ffedd..a6682bca 100644 --- a/webapp/src/locales/de.json +++ b/webapp/src/locales/de.json @@ -328,6 +328,9 @@ "TimeServerHint": "Der Standardwert ist in Ordnung, solange OpenDTU direkten Zugang zum Internet hat.", "Timezone": "Zeitzone:", "TimezoneConfig": "Zeitzonenkonfiguration:", + "LocationConfiguration": "Standortkonfiguration", + "Longitude": "Längengrad:", + "Latitude": "Breitengrad:", "Save": "@:dtuadmin.Save", "ManualTimeSynchronization": "Manuelle Zeitsynchronization", "CurrentOpenDtuTime": "Aktuelle OpenDTU Zeit:", diff --git a/webapp/src/locales/en.json b/webapp/src/locales/en.json index cd8bb553..2308b7c4 100644 --- a/webapp/src/locales/en.json +++ b/webapp/src/locales/en.json @@ -328,6 +328,9 @@ "TimeServerHint": "The default value is fine as long as OpenDTU has direct access to the internet.", "Timezone": "Timezone:", "TimezoneConfig": "Timezone Config:", + "LocationConfiguration": "Location Configuration", + "Longitude": "Longitude", + "Latitude": "Latitude", "Save": "@:dtuadmin.Save", "ManualTimeSynchronization": "Manual Time Synchronization", "CurrentOpenDtuTime": "Current OpenDTU Time:", diff --git a/webapp/src/locales/fr.json b/webapp/src/locales/fr.json index f9764a57..51c74b54 100644 --- a/webapp/src/locales/fr.json +++ b/webapp/src/locales/fr.json @@ -328,6 +328,9 @@ "TimeServerHint": "La valeur par défaut convient tant que OpenDTU a un accès direct à Internet.", "Timezone": "Fuseau horaire", "TimezoneConfig": "Configuration du fuseau horaire", + "LocationConfiguration": "Location Configuration", + "Longitude": "Longitude", + "Latitude": "Latitude", "Save": "@:dtuadmin.Save", "ManualTimeSynchronization": "Synchronisation manuelle de l'heure", "CurrentOpenDtuTime": "Heure actuelle de l'OpenDTU", diff --git a/webapp/src/types/NtpConfig.ts b/webapp/src/types/NtpConfig.ts index 38fd55c6..172ffa09 100644 --- a/webapp/src/types/NtpConfig.ts +++ b/webapp/src/types/NtpConfig.ts @@ -2,4 +2,6 @@ export interface NtpConfig { ntp_server: string; ntp_timezone: string; ntp_timezone_descr: string; + latitude: number; + longitude: number; } \ No newline at end of file diff --git a/webapp/src/views/NtpAdminView.vue b/webapp/src/views/NtpAdminView.vue index 174ec1e4..dc1ccd23 100644 --- a/webapp/src/views/NtpAdminView.vue +++ b/webapp/src/views/NtpAdminView.vue @@ -27,6 +27,16 @@ v-model="ntpConfigList.ntp_timezone" type="text" maxlength="32" disabled/> + + + + + +