Feature: Admin AccessPoint Timeout now configurable
Make the administrative accesspoint timeout configurable. The default value is 3 minutes, values from 0-99999 are possible, where 0 means infinite (no timeout). Signed-off-by: Martin Dummer <martin.dummer@gmx.net>
This commit is contained in:
parent
2e25fdcf8f
commit
8bfa7e530c
@ -61,6 +61,7 @@ struct CONFIG_T {
|
|||||||
byte WiFi_Dns2[4];
|
byte WiFi_Dns2[4];
|
||||||
bool WiFi_Dhcp;
|
bool WiFi_Dhcp;
|
||||||
char WiFi_Hostname[WIFI_MAX_HOSTNAME_STRLEN + 1];
|
char WiFi_Hostname[WIFI_MAX_HOSTNAME_STRLEN + 1];
|
||||||
|
uint WiFi_ApTimeout;
|
||||||
|
|
||||||
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];
|
||||||
|
|||||||
@ -64,6 +64,7 @@ private:
|
|||||||
bool adminEnabled = true;
|
bool adminEnabled = true;
|
||||||
bool forceDisconnection = false;
|
bool forceDisconnection = false;
|
||||||
int adminTimeoutCounter = 0;
|
int adminTimeoutCounter = 0;
|
||||||
|
int adminTimeoutCounterMax = 0;
|
||||||
int connectTimeoutTimer = 0;
|
int connectTimeoutTimer = 0;
|
||||||
int connectRedoTimer = 0;
|
int connectRedoTimer = 0;
|
||||||
uint32_t lastTimerCall = 0;
|
uint32_t lastTimerCall = 0;
|
||||||
|
|||||||
@ -63,6 +63,7 @@ enum WebApiError {
|
|||||||
NetworkGatewayInvalid,
|
NetworkGatewayInvalid,
|
||||||
NetworkDns1Invalid,
|
NetworkDns1Invalid,
|
||||||
NetworkDns2Invalid,
|
NetworkDns2Invalid,
|
||||||
|
NetworkApTimeoutInvalid,
|
||||||
|
|
||||||
NtpBase = 9000,
|
NtpBase = 9000,
|
||||||
NtpServerLength,
|
NtpServerLength,
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
#define ACCESS_POINT_NAME "OpenDTU-"
|
#define ACCESS_POINT_NAME "OpenDTU-"
|
||||||
#define ACCESS_POINT_PASSWORD "openDTU42"
|
#define ACCESS_POINT_PASSWORD "openDTU42"
|
||||||
|
#define ACCESS_POINT_TIMEOUT 3;
|
||||||
#define AUTH_USERNAME "admin"
|
#define AUTH_USERNAME "admin"
|
||||||
#define SECURITY_ALLOW_READONLY true
|
#define SECURITY_ALLOW_READONLY true
|
||||||
|
|
||||||
#define ADMIN_TIMEOUT 180
|
|
||||||
#define WIFI_RECONNECT_TIMEOUT 15
|
#define WIFI_RECONNECT_TIMEOUT 15
|
||||||
#define WIFI_RECONNECT_REDO_TIMEOUT 600
|
#define WIFI_RECONNECT_REDO_TIMEOUT 600
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@ bool ConfigurationClass::write()
|
|||||||
wifi["dns2"] = IPAddress(config.WiFi_Dns2).toString();
|
wifi["dns2"] = IPAddress(config.WiFi_Dns2).toString();
|
||||||
wifi["dhcp"] = config.WiFi_Dhcp;
|
wifi["dhcp"] = config.WiFi_Dhcp;
|
||||||
wifi["hostname"] = config.WiFi_Hostname;
|
wifi["hostname"] = config.WiFi_Hostname;
|
||||||
|
wifi["aptimeout"] = config.WiFi_ApTimeout;
|
||||||
|
|
||||||
JsonObject ntp = doc.createNestedObject("ntp");
|
JsonObject ntp = doc.createNestedObject("ntp");
|
||||||
ntp["server"] = config.Ntp_Server;
|
ntp["server"] = config.Ntp_Server;
|
||||||
@ -184,6 +185,7 @@ bool ConfigurationClass::read()
|
|||||||
config.WiFi_Dns2[3] = wifi_dns2[3];
|
config.WiFi_Dns2[3] = wifi_dns2[3];
|
||||||
|
|
||||||
config.WiFi_Dhcp = wifi["dhcp"] | WIFI_DHCP;
|
config.WiFi_Dhcp = wifi["dhcp"] | WIFI_DHCP;
|
||||||
|
config.WiFi_ApTimeout = wifi["aptimeout"] | ACCESS_POINT_TIMEOUT;
|
||||||
|
|
||||||
JsonObject ntp = doc["ntp"];
|
JsonObject ntp = doc["ntp"];
|
||||||
strlcpy(config.Ntp_Server, ntp["server"] | NTP_SERVER, sizeof(config.Ntp_Server));
|
strlcpy(config.Ntp_Server, ntp["server"] | NTP_SERVER, sizeof(config.Ntp_Server));
|
||||||
|
|||||||
@ -140,6 +140,7 @@ void NetworkSettingsClass::enableAdminMode()
|
|||||||
{
|
{
|
||||||
adminEnabled = true;
|
adminEnabled = true;
|
||||||
adminTimeoutCounter = 0;
|
adminTimeoutCounter = 0;
|
||||||
|
adminTimeoutCounterMax = Configuration.get().WiFi_ApTimeout * 60;
|
||||||
setupMode();
|
setupMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +169,12 @@ void NetworkSettingsClass::loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (millis() - lastTimerCall > 1000) {
|
if (millis() - lastTimerCall > 1000) {
|
||||||
|
if (adminEnabled && adminTimeoutCounterMax > 0) {
|
||||||
adminTimeoutCounter++;
|
adminTimeoutCounter++;
|
||||||
|
if (adminTimeoutCounter % 10 == 0) {
|
||||||
|
MessageOutput.printf("Admin AP remaining seconds: %d / %d\r\n", adminTimeoutCounter, adminTimeoutCounterMax);
|
||||||
|
}
|
||||||
|
}
|
||||||
connectTimeoutTimer++;
|
connectTimeoutTimer++;
|
||||||
connectRedoTimer++;
|
connectRedoTimer++;
|
||||||
lastTimerCall = millis();
|
lastTimerCall = millis();
|
||||||
@ -178,9 +184,9 @@ void NetworkSettingsClass::loop()
|
|||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
adminTimeoutCounter = 0;
|
adminTimeoutCounter = 0;
|
||||||
}
|
}
|
||||||
// If WiFi is connected to AP for more than ADMIN_TIMEOUT
|
// If WiFi is connected to AP for more than adminTimeoutCounterMax
|
||||||
// seconds, disable the internal Access Point
|
// seconds, disable the internal Access Point
|
||||||
if (adminTimeoutCounter > ADMIN_TIMEOUT) {
|
if (adminTimeoutCounter > adminTimeoutCounterMax) {
|
||||||
adminEnabled = false;
|
adminEnabled = false;
|
||||||
MessageOutput.println("Admin mode disabled");
|
MessageOutput.println("Admin mode disabled");
|
||||||
setupMode();
|
setupMode();
|
||||||
|
|||||||
@ -75,6 +75,7 @@ void WebApiNetworkClass::onNetworkAdminGet(AsyncWebServerRequest* request)
|
|||||||
root["dns2"] = IPAddress(config.WiFi_Dns2).toString();
|
root["dns2"] = IPAddress(config.WiFi_Dns2).toString();
|
||||||
root["ssid"] = config.WiFi_Ssid;
|
root["ssid"] = config.WiFi_Ssid;
|
||||||
root["password"] = config.WiFi_Password;
|
root["password"] = config.WiFi_Password;
|
||||||
|
root["aptimeout"] = config.WiFi_ApTimeout;
|
||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
@ -127,7 +128,8 @@ void WebApiNetworkClass::onNetworkAdminPost(AsyncWebServerRequest* request)
|
|||||||
&& root.containsKey("netmask")
|
&& root.containsKey("netmask")
|
||||||
&& root.containsKey("gateway")
|
&& root.containsKey("gateway")
|
||||||
&& root.containsKey("dns1")
|
&& root.containsKey("dns1")
|
||||||
&& root.containsKey("dns2"))) {
|
&& root.containsKey("dns2")
|
||||||
|
&& root.containsKey("aptimeout"))) {
|
||||||
retMsg["message"] = "Values are missing!";
|
retMsg["message"] = "Values are missing!";
|
||||||
retMsg["code"] = WebApiError::GenericValueMissing;
|
retMsg["code"] = WebApiError::GenericValueMissing;
|
||||||
response->setLength();
|
response->setLength();
|
||||||
@ -196,6 +198,13 @@ void WebApiNetworkClass::onNetworkAdminPost(AsyncWebServerRequest* request)
|
|||||||
request->send(response);
|
request->send(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (root["aptimeout"].as<uint>() > 99999) {
|
||||||
|
retMsg["message"] = "ApTimeout must be a number between 0 and 99999!";
|
||||||
|
retMsg["code"] = WebApiError::NetworkApTimeoutInvalid;
|
||||||
|
response->setLength();
|
||||||
|
request->send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CONFIG_T& config = Configuration.get();
|
CONFIG_T& config = Configuration.get();
|
||||||
config.WiFi_Ip[0] = ipaddress[0];
|
config.WiFi_Ip[0] = ipaddress[0];
|
||||||
@ -226,6 +235,7 @@ void WebApiNetworkClass::onNetworkAdminPost(AsyncWebServerRequest* request)
|
|||||||
} else {
|
} else {
|
||||||
config.WiFi_Dhcp = false;
|
config.WiFi_Dhcp = false;
|
||||||
}
|
}
|
||||||
|
config.WiFi_ApTimeout = root["aptimeout"].as<uint>();
|
||||||
Configuration.write();
|
Configuration.write();
|
||||||
|
|
||||||
retMsg["type"] = "success";
|
retMsg["type"] = "success";
|
||||||
|
|||||||
@ -78,6 +78,7 @@
|
|||||||
"8003": "Standardgateway ist ungültig!",
|
"8003": "Standardgateway ist ungültig!",
|
||||||
"8004": "DNS-Server-IP 1 ist ungültig!",
|
"8004": "DNS-Server-IP 1 ist ungültig!",
|
||||||
"8005": "DNS-Server-IP 2 ist ungültig!",
|
"8005": "DNS-Server-IP 2 ist ungültig!",
|
||||||
|
"8006": "Administrative AccessPoint Timeout-Wert ist ungültig!",
|
||||||
"9001": "Zeitserver muss zwischen 1 und {max} Zeichen lang sein!",
|
"9001": "Zeitserver muss zwischen 1 und {max} Zeichen lang sein!",
|
||||||
"9002": "Zeitzone muss zwischen 1 und {max} Zeichen lang sein!",
|
"9002": "Zeitzone muss zwischen 1 und {max} Zeichen lang sein!",
|
||||||
"9003": "Zeitzonenbeschreibung muss zwischen 1 und {max} Zeichen lang sein!",
|
"9003": "Zeitzonenbeschreibung muss zwischen 1 und {max} Zeichen lang sein!",
|
||||||
@ -388,6 +389,9 @@
|
|||||||
"Netmask": "Netzmaske:",
|
"Netmask": "Netzmaske:",
|
||||||
"DefaultGateway": "Standardgateway:",
|
"DefaultGateway": "Standardgateway:",
|
||||||
"Dns": "DNS-Server {num}:",
|
"Dns": "DNS-Server {num}:",
|
||||||
|
"AdminAp": "WLAN-Konfiguration (Admin AccessPoint)",
|
||||||
|
"ApTimeout": "AccessPoint Zeitlimit (Minuten)",
|
||||||
|
"ApTimeoutHint": "Wie viele Minuten der AccessPoint offen gehalten wird. Ein Wert von 0 bedeutet unendlich.",
|
||||||
"Save": "@:dtuadmin.Save"
|
"Save": "@:dtuadmin.Save"
|
||||||
},
|
},
|
||||||
"mqttadmin": {
|
"mqttadmin": {
|
||||||
|
|||||||
@ -78,6 +78,7 @@
|
|||||||
"8003": "Gateway is invalid!",
|
"8003": "Gateway is invalid!",
|
||||||
"8004": "DNS Server IP 1 is invalid!",
|
"8004": "DNS Server IP 1 is invalid!",
|
||||||
"8005": "DNS Server IP 2 is invalid!",
|
"8005": "DNS Server IP 2 is invalid!",
|
||||||
|
"8006": "Administrative AccessPoint Timeout value is invalid",
|
||||||
"9001": "NTP Server must between 1 and {max} characters long!",
|
"9001": "NTP Server must between 1 and {max} characters long!",
|
||||||
"9002": "Timezone must between 1 and {max} characters long!",
|
"9002": "Timezone must between 1 and {max} characters long!",
|
||||||
"9003": "Timezone description must between 1 and {max} characters long!",
|
"9003": "Timezone description must between 1 and {max} characters long!",
|
||||||
@ -388,6 +389,9 @@
|
|||||||
"Netmask": "Netmask:",
|
"Netmask": "Netmask:",
|
||||||
"DefaultGateway": "Default Gateway:",
|
"DefaultGateway": "Default Gateway:",
|
||||||
"Dns": "DNS Server {num}:",
|
"Dns": "DNS Server {num}:",
|
||||||
|
"AdminAp": "WiFi Configuration (Admin AccessPoint)",
|
||||||
|
"ApTimeout": "AccessPoint Timeout (minutes)",
|
||||||
|
"ApTimeoutHint": "How many minutes the AccessPoint is kept open. A value of 0 means infinite.",
|
||||||
"Save": "@:dtuadmin.Save"
|
"Save": "@:dtuadmin.Save"
|
||||||
},
|
},
|
||||||
"mqttadmin": {
|
"mqttadmin": {
|
||||||
|
|||||||
@ -78,6 +78,7 @@
|
|||||||
"8003": "La passerelle n'est pas valide !",
|
"8003": "La passerelle n'est pas valide !",
|
||||||
"8004": "L'adresse IP du serveur DNS primaire n'est pas valide !",
|
"8004": "L'adresse IP du serveur DNS primaire n'est pas valide !",
|
||||||
"8005": "L'adresse IP du serveur DNS secondaire n'est pas valide !",
|
"8005": "L'adresse IP du serveur DNS secondaire n'est pas valide !",
|
||||||
|
"8006": "La valeur du délai d'attente du point d'accès administratif n'est pas valide !",
|
||||||
"9001": "Le serveur NTP doit avoir une longueur comprise entre 1 et {max} caractères !",
|
"9001": "Le serveur NTP doit avoir une longueur comprise entre 1 et {max} caractères !",
|
||||||
"9002": "Le fuseau horaire doit comporter entre 1 et {max} caractères !",
|
"9002": "Le fuseau horaire doit comporter entre 1 et {max} caractères !",
|
||||||
"9003": "La description du fuseau horaire doit comporter entre 1 et {max} caractères !",
|
"9003": "La description du fuseau horaire doit comporter entre 1 et {max} caractères !",
|
||||||
@ -388,6 +389,9 @@
|
|||||||
"Netmask": "Masque de réseau",
|
"Netmask": "Masque de réseau",
|
||||||
"DefaultGateway": "Passerelle par défaut",
|
"DefaultGateway": "Passerelle par défaut",
|
||||||
"Dns": "Serveur DNS {num}",
|
"Dns": "Serveur DNS {num}",
|
||||||
|
"AdminAp": "Configuration du réseau WiFi (Point d'accès)",
|
||||||
|
"ApTimeout": "Délai d'attente du point d'accès (minutes)",
|
||||||
|
"ApTimeoutHint": "Nombre de minutes pendant lesquelles le point d'accès reste ouvert. Une valeur de 0 signifie infini.",
|
||||||
"Save": "@:dtuadmin.Save"
|
"Save": "@:dtuadmin.Save"
|
||||||
},
|
},
|
||||||
"mqttadmin": {
|
"mqttadmin": {
|
||||||
|
|||||||
@ -8,4 +8,5 @@ export interface NetworkConfig {
|
|||||||
gateway: string;
|
gateway: string;
|
||||||
dns1: string;
|
dns1: string;
|
||||||
dns2: string;
|
dns2: string;
|
||||||
|
aptimeout: number;
|
||||||
}
|
}
|
||||||
@ -50,6 +50,12 @@
|
|||||||
type="text" maxlength="32"/>
|
type="text" maxlength="32"/>
|
||||||
</CardElement>
|
</CardElement>
|
||||||
|
|
||||||
|
<CardElement :text="$t('networkadmin.AdminAp')" textVariant="text-bg-primary" add-space>
|
||||||
|
<InputElement :label="$t('networkadmin.ApTimeout')"
|
||||||
|
v-model="networkConfigList.aptimeout"
|
||||||
|
type="number" min="0" max="99999"
|
||||||
|
:tooltip="$t('networkadmin.ApTimeoutHint')"/>
|
||||||
|
</CardElement>
|
||||||
<button type="submit" class="btn btn-primary mb-3">{{ $t('networkadmin.Save') }}</button>
|
<button type="submit" class="btn btn-primary mb-3">{{ $t('networkadmin.Save') }}</button>
|
||||||
</form>
|
</form>
|
||||||
</BasePage>
|
</BasePage>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user