Added config parameters to set longitude and latitude
This commit is contained in:
parent
7da782c4ef
commit
19a1c0aa54
@ -60,6 +60,8 @@ struct CONFIG_T {
|
|||||||
char Ntp_Server[NTP_MAX_SERVER_STRLEN + 1];
|
char Ntp_Server[NTP_MAX_SERVER_STRLEN + 1];
|
||||||
char Ntp_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1];
|
char Ntp_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1];
|
||||||
char Ntp_TimezoneDescr[NTP_MAX_TIMEZONEDESCR_STRLEN + 1];
|
char Ntp_TimezoneDescr[NTP_MAX_TIMEZONEDESCR_STRLEN + 1];
|
||||||
|
double Ntp_Longitude;
|
||||||
|
double Ntp_Latitude;
|
||||||
|
|
||||||
bool Mqtt_Enabled;
|
bool Mqtt_Enabled;
|
||||||
uint Mqtt_Port;
|
uint Mqtt_Port;
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
#define NTP_SERVER "pool.ntp.org"
|
#define NTP_SERVER "pool.ntp.org"
|
||||||
#define NTP_TIMEZONE "CET-1CEST,M3.5.0,M10.5.0/3"
|
#define NTP_TIMEZONE "CET-1CEST,M3.5.0,M10.5.0/3"
|
||||||
#define NTP_TIMEZONEDESCR "Europe/Berlin"
|
#define NTP_TIMEZONEDESCR "Europe/Berlin"
|
||||||
|
#define NTP_LONGITUDE 10.4515f
|
||||||
|
#define NTP_LATITUDE 51.1657f
|
||||||
|
|
||||||
#define MQTT_ENABLED false
|
#define MQTT_ENABLED false
|
||||||
#define MQTT_HOST ""
|
#define MQTT_HOST ""
|
||||||
|
|||||||
@ -44,6 +44,8 @@ bool ConfigurationClass::write()
|
|||||||
ntp["server"] = config.Ntp_Server;
|
ntp["server"] = config.Ntp_Server;
|
||||||
ntp["timezone"] = config.Ntp_Timezone;
|
ntp["timezone"] = config.Ntp_Timezone;
|
||||||
ntp["timezone_descr"] = config.Ntp_TimezoneDescr;
|
ntp["timezone_descr"] = config.Ntp_TimezoneDescr;
|
||||||
|
ntp["latitude"] = config.Ntp_Latitude;
|
||||||
|
ntp["longitude"] = config.Ntp_Longitude;
|
||||||
|
|
||||||
JsonObject mqtt = doc.createNestedObject("mqtt");
|
JsonObject mqtt = doc.createNestedObject("mqtt");
|
||||||
mqtt["enabled"] = config.Mqtt_Enabled;
|
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_Server, ntp["server"] | NTP_SERVER, sizeof(config.Ntp_Server));
|
||||||
strlcpy(config.Ntp_Timezone, ntp["timezone"] | NTP_TIMEZONE, sizeof(config.Ntp_Timezone));
|
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));
|
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"];
|
JsonObject mqtt = doc["mqtt"];
|
||||||
config.Mqtt_Enabled = mqtt["enabled"] | MQTT_ENABLED;
|
config.Mqtt_Enabled = mqtt["enabled"] | MQTT_ENABLED;
|
||||||
|
|||||||
@ -68,6 +68,8 @@ void WebApiNtpClass::onNtpAdminGet(AsyncWebServerRequest* request)
|
|||||||
root[F("ntp_server")] = config.Ntp_Server;
|
root[F("ntp_server")] = config.Ntp_Server;
|
||||||
root[F("ntp_timezone")] = config.Ntp_Timezone;
|
root[F("ntp_timezone")] = config.Ntp_Timezone;
|
||||||
root[F("ntp_timezone_descr")] = config.Ntp_TimezoneDescr;
|
root[F("ntp_timezone_descr")] = config.Ntp_TimezoneDescr;
|
||||||
|
root[F("longitude")] = config.Ntp_Longitude;
|
||||||
|
root[F("latitude")] = config.Ntp_Latitude;
|
||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
@ -112,7 +114,7 @@ void WebApiNtpClass::onNtpAdminPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
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("message")] = F("Values are missing!");
|
||||||
retMsg[F("code")] = WebApiError::GenericValueMissing;
|
retMsg[F("code")] = WebApiError::GenericValueMissing;
|
||||||
response->setLength();
|
response->setLength();
|
||||||
@ -151,6 +153,8 @@ void WebApiNtpClass::onNtpAdminPost(AsyncWebServerRequest* request)
|
|||||||
strlcpy(config.Ntp_Server, root[F("ntp_server")].as<String>().c_str(), sizeof(config.Ntp_Server));
|
strlcpy(config.Ntp_Server, root[F("ntp_server")].as<String>().c_str(), sizeof(config.Ntp_Server));
|
||||||
strlcpy(config.Ntp_Timezone, root[F("ntp_timezone")].as<String>().c_str(), sizeof(config.Ntp_Timezone));
|
strlcpy(config.Ntp_Timezone, root[F("ntp_timezone")].as<String>().c_str(), sizeof(config.Ntp_Timezone));
|
||||||
strlcpy(config.Ntp_TimezoneDescr, root[F("ntp_timezone_descr")].as<String>().c_str(), sizeof(config.Ntp_TimezoneDescr));
|
strlcpy(config.Ntp_TimezoneDescr, root[F("ntp_timezone_descr")].as<String>().c_str(), sizeof(config.Ntp_TimezoneDescr));
|
||||||
|
config.Ntp_Latitude = root[F("latitude")].as<double>();
|
||||||
|
config.Ntp_Longitude = root[F("longitude")].as<double>();
|
||||||
Configuration.write();
|
Configuration.write();
|
||||||
|
|
||||||
retMsg[F("type")] = F("success");
|
retMsg[F("type")] = F("success");
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
:maxlength="maxlength"
|
:maxlength="maxlength"
|
||||||
:min="min"
|
:min="min"
|
||||||
:max="max"
|
:max="max"
|
||||||
|
:step="step"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:aria-describedby="descriptionId"
|
:aria-describedby="descriptionId"
|
||||||
/>
|
/>
|
||||||
@ -69,6 +70,7 @@ export default defineComponent({
|
|||||||
'maxlength': String,
|
'maxlength': String,
|
||||||
'min': String,
|
'min': String,
|
||||||
'max': String,
|
'max': String,
|
||||||
|
'step': String,
|
||||||
'rows': String,
|
'rows': String,
|
||||||
'disabled': Boolean,
|
'disabled': Boolean,
|
||||||
'postfix': String,
|
'postfix': String,
|
||||||
|
|||||||
@ -328,6 +328,9 @@
|
|||||||
"TimeServerHint": "Der Standardwert ist in Ordnung, solange OpenDTU direkten Zugang zum Internet hat.",
|
"TimeServerHint": "Der Standardwert ist in Ordnung, solange OpenDTU direkten Zugang zum Internet hat.",
|
||||||
"Timezone": "Zeitzone:",
|
"Timezone": "Zeitzone:",
|
||||||
"TimezoneConfig": "Zeitzonenkonfiguration:",
|
"TimezoneConfig": "Zeitzonenkonfiguration:",
|
||||||
|
"LocationConfiguration": "Standortkonfiguration",
|
||||||
|
"Longitude": "Längengrad:",
|
||||||
|
"Latitude": "Breitengrad:",
|
||||||
"Save": "@:dtuadmin.Save",
|
"Save": "@:dtuadmin.Save",
|
||||||
"ManualTimeSynchronization": "Manuelle Zeitsynchronization",
|
"ManualTimeSynchronization": "Manuelle Zeitsynchronization",
|
||||||
"CurrentOpenDtuTime": "Aktuelle OpenDTU Zeit:",
|
"CurrentOpenDtuTime": "Aktuelle OpenDTU Zeit:",
|
||||||
|
|||||||
@ -328,6 +328,9 @@
|
|||||||
"TimeServerHint": "The default value is fine as long as OpenDTU has direct access to the internet.",
|
"TimeServerHint": "The default value is fine as long as OpenDTU has direct access to the internet.",
|
||||||
"Timezone": "Timezone:",
|
"Timezone": "Timezone:",
|
||||||
"TimezoneConfig": "Timezone Config:",
|
"TimezoneConfig": "Timezone Config:",
|
||||||
|
"LocationConfiguration": "Location Configuration",
|
||||||
|
"Longitude": "Longitude",
|
||||||
|
"Latitude": "Latitude",
|
||||||
"Save": "@:dtuadmin.Save",
|
"Save": "@:dtuadmin.Save",
|
||||||
"ManualTimeSynchronization": "Manual Time Synchronization",
|
"ManualTimeSynchronization": "Manual Time Synchronization",
|
||||||
"CurrentOpenDtuTime": "Current OpenDTU Time:",
|
"CurrentOpenDtuTime": "Current OpenDTU Time:",
|
||||||
|
|||||||
@ -328,6 +328,9 @@
|
|||||||
"TimeServerHint": "La valeur par défaut convient tant que OpenDTU a un accès direct à Internet.",
|
"TimeServerHint": "La valeur par défaut convient tant que OpenDTU a un accès direct à Internet.",
|
||||||
"Timezone": "Fuseau horaire",
|
"Timezone": "Fuseau horaire",
|
||||||
"TimezoneConfig": "Configuration du fuseau horaire",
|
"TimezoneConfig": "Configuration du fuseau horaire",
|
||||||
|
"LocationConfiguration": "Location Configuration",
|
||||||
|
"Longitude": "Longitude",
|
||||||
|
"Latitude": "Latitude",
|
||||||
"Save": "@:dtuadmin.Save",
|
"Save": "@:dtuadmin.Save",
|
||||||
"ManualTimeSynchronization": "Synchronisation manuelle de l'heure",
|
"ManualTimeSynchronization": "Synchronisation manuelle de l'heure",
|
||||||
"CurrentOpenDtuTime": "Heure actuelle de l'OpenDTU",
|
"CurrentOpenDtuTime": "Heure actuelle de l'OpenDTU",
|
||||||
|
|||||||
@ -2,4 +2,6 @@ export interface NtpConfig {
|
|||||||
ntp_server: string;
|
ntp_server: string;
|
||||||
ntp_timezone: string;
|
ntp_timezone: string;
|
||||||
ntp_timezone_descr: string;
|
ntp_timezone_descr: string;
|
||||||
|
latitude: number;
|
||||||
|
longitude: number;
|
||||||
}
|
}
|
||||||
@ -27,6 +27,16 @@
|
|||||||
v-model="ntpConfigList.ntp_timezone"
|
v-model="ntpConfigList.ntp_timezone"
|
||||||
type="text" maxlength="32" disabled/>
|
type="text" maxlength="32" disabled/>
|
||||||
</CardElement>
|
</CardElement>
|
||||||
|
|
||||||
|
<CardElement :text="$t('ntpadmin.LocationConfiguration')" textVariant="text-bg-primary" add-space>
|
||||||
|
<InputElement :label="$t('ntpadmin.Longitude')"
|
||||||
|
v-model="ntpConfigList.longitude"
|
||||||
|
type="number" min="-180" max="180" step="any"/>
|
||||||
|
|
||||||
|
<InputElement :label="$t('ntpadmin.Latitude')"
|
||||||
|
v-model="ntpConfigList.latitude"
|
||||||
|
type="number" min="-90" max="90" step="any"/>
|
||||||
|
</CardElement>
|
||||||
<button type="submit" class="btn btn-primary mb-3">{{ $t('ntpadmin.Save') }}</button>
|
<button type="submit" class="btn btn-primary mb-3">{{ $t('ntpadmin.Save') }}</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user