mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
Merge pull request #3646 from TD-er/feature/Disallow_AP_start
[WiFi AP] Add flag to prevent starting WiFi AP.
This commit is contained in:
@@ -111,6 +111,28 @@ This is often used to perform the initial configuration like connecting to the l
|
||||
Can also be set via the command ``WiFiAPKey``.
|
||||
|
||||
|
||||
Don't force /setup in AP-Mode
|
||||
-----------------------------
|
||||
|
||||
Allow optional usage of ESPEasy without WIFI avaiable.
|
||||
|
||||
When checked you can use ESPEasy in AP-Mode without beeing forced to ``/setup``.
|
||||
|
||||
|
||||
Do Not Start AP
|
||||
---------------
|
||||
|
||||
Usually the AP will be started when no WiFi is defined, or the defined one cannot be found.
|
||||
This flag may prevent to start an AP.
|
||||
|
||||
Since this flag can lock out a user, there is a restricted command to uncheck this.
|
||||
|
||||
``WifiAllowAP`` will uncheck this flag in the settings until a reboot.
|
||||
If the settings are saved, this flag will remain unchecked.
|
||||
|
||||
N.B. Restricted means, not accepted from a remote source, only local or via serial.
|
||||
|
||||
|
||||
Custom Build WiFi credentials
|
||||
-----------------------------
|
||||
|
||||
|
||||
@@ -486,6 +486,12 @@
|
||||
|
||||
``WifiAPKey,<WPA key>``"
|
||||
"
|
||||
WifiAllowAP","
|
||||
:red:`Internal`","
|
||||
Uncheck the setting to prevent starting AP when unable to connect to a network.
|
||||
|
||||
``WifiAllowAP``"
|
||||
"
|
||||
WifiAPMode","
|
||||
:red:`Internal`","
|
||||
Force the unit into AP mode.
|
||||
|
||||
+2
-1
@@ -67,7 +67,8 @@
|
||||
// See: https://github.com/letscontrolit/ESPEasy/issues/2724
|
||||
#define DEFAULT_SEND_TO_HTTP_ACK false // Wait for ack with SendToHttp command.
|
||||
|
||||
#define DEFAULT_AP_DONT_FORCE_SETUP false // Allow optional usage of Sensor without WIFI avaiable // When set you can use the Sensor in AP-Mode without beeing forced to /setup
|
||||
#define DEFAULT_AP_DONT_FORCE_SETUP false // Allow optional usage of Sensor without WIFI avaiable // When set you can use the Sensor in AP-Mode without beeing forced to /setup
|
||||
#define DEFAULT_DONT_ALLOW_START_AP false // Usually the AP will be started when no WiFi is defined, or the defined one cannot be found. This flag may prevent it.
|
||||
|
||||
// --- Default Controller ------------------------------------------------------------------------------
|
||||
#define DEFAULT_CONTROLLER false // true or false enabled or disabled, set 1st controller
|
||||
|
||||
@@ -396,6 +396,7 @@ bool executeInternalCommand(command_case_data & data)
|
||||
#endif
|
||||
|
||||
if (data.cmd_lc[1] == 'i') {
|
||||
COMMAND_CASE_R( "wifiallowap", Command_Wifi_AllowAP, 0); // WiFi.h
|
||||
COMMAND_CASE_R( "wifiapmode", Command_Wifi_APMode, 0); // WiFi.h
|
||||
COMMAND_CASE_A( "wificonnect", Command_Wifi_Connect, 0); // WiFi.h
|
||||
COMMAND_CASE_A("wifidisconnect", Command_Wifi_Disconnect, 0); // WiFi.h
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "../Helpers/Misc.h"
|
||||
#include "../Helpers/Rules_calculate.h"
|
||||
#include "../Helpers/StringConverter.h"
|
||||
#include "../Helpers/StringParser.h"
|
||||
|
||||
// taskIndex = (event->Par1 - 1); Par1 is here for 1 ... TASKS_MAX
|
||||
// varNr = event->Par2 - 1;
|
||||
|
||||
@@ -118,6 +118,12 @@ String Command_Wifi_Mode(struct EventStruct *event, const char *Line)
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
String Command_Wifi_AllowAP(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
Settings.DoNotStartAP(false);
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
// FIXME: TD-er This is not an erase, but actually storing the current settings
|
||||
// in the wifi settings of the core library
|
||||
String Command_WiFi_Erase(struct EventStruct *event, const char *Line)
|
||||
|
||||
@@ -15,6 +15,7 @@ String Command_Wifi_Disconnect(struct EventStruct *event, const char* Line);
|
||||
String Command_Wifi_APMode(struct EventStruct *event, const char* Line);
|
||||
String Command_Wifi_STAMode(struct EventStruct *event, const char* Line);
|
||||
String Command_Wifi_Mode(struct EventStruct *event, const char* Line);
|
||||
String Command_Wifi_AllowAP(struct EventStruct *event, const char* Line);
|
||||
|
||||
// FIXME: TD-er This is not an erase, but actually storing the current settings
|
||||
// in the wifi settings of the core library
|
||||
|
||||
@@ -109,7 +109,11 @@
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_AP_DONT_FORCE_SETUP
|
||||
#define DEFAULT_AP_DONT_FORCE_SETUP false // Allow optional usage of Sensor without WIFI avaiable // When set you can use the Sensor in AP-Mode without beeing forced to /setup
|
||||
#define DEFAULT_AP_DONT_FORCE_SETUP false // Allow optional usage of Sensor without WIFI avaiable // When set you can use the Sensor in AP-Mode without beeing forced to /setup
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_DONT_ALLOW_START_AP
|
||||
#define DEFAULT_DONT_ALLOW_START_AP false // Usually the AP will be started when no WiFi is defined, or the defined one cannot be found. This flag may prevent it.
|
||||
#endif
|
||||
|
||||
// --- Default Controller ------------------------------------------------------------------------------
|
||||
|
||||
@@ -195,6 +195,16 @@ void SettingsStruct_tmpl<N_TASKS>::CombineTaskValues_SingleEvent(taskIndex_t tas
|
||||
}
|
||||
}
|
||||
|
||||
template<unsigned int N_TASKS>
|
||||
bool SettingsStruct_tmpl<N_TASKS>::DoNotStartAP() const {
|
||||
return bitRead(VariousBits1, 17);
|
||||
}
|
||||
|
||||
template<unsigned int N_TASKS>
|
||||
void SettingsStruct_tmpl<N_TASKS>::DoNotStartAP(bool value) {
|
||||
bitWrite(VariousBits1, 17, value);
|
||||
}
|
||||
|
||||
template<unsigned int N_TASKS>
|
||||
void SettingsStruct_tmpl<N_TASKS>::validate() {
|
||||
if (UDPPort > 65535) { UDPPort = 0; }
|
||||
@@ -360,6 +370,7 @@ void SettingsStruct_tmpl<N_TASKS>::clearMisc() {
|
||||
TolerantLastArgParse(DEFAULT_TOLERANT_LAST_ARG_PARSE);
|
||||
SendToHttp_ack(DEFAULT_SEND_TO_HTTP_ACK);
|
||||
ApDontForceSetup(DEFAULT_AP_DONT_FORCE_SETUP);
|
||||
DoNotStartAP(DEFAULT_DONT_ALLOW_START_AP);
|
||||
}
|
||||
|
||||
template<unsigned int N_TASKS>
|
||||
|
||||
@@ -115,6 +115,8 @@ class SettingsStruct_tmpl
|
||||
bool CombineTaskValues_SingleEvent(taskIndex_t taskIndex) const;
|
||||
void CombineTaskValues_SingleEvent(taskIndex_t taskIndex, bool value);
|
||||
|
||||
bool DoNotStartAP() const;
|
||||
void DoNotStartAP(bool value);
|
||||
|
||||
void validate();
|
||||
|
||||
|
||||
@@ -165,7 +165,9 @@ bool WiFiConnected() {
|
||||
if ((WiFiEventData.timerAPstart.isSet()) && WiFiEventData.timerAPstart.timeReached()) {
|
||||
// Timer reached, so enable AP mode.
|
||||
if (!WifiIsAP(WiFi.getMode())) {
|
||||
setAP(true);
|
||||
if (!Settings.DoNotStartAP()) {
|
||||
setAP(true);
|
||||
}
|
||||
}
|
||||
WiFiEventData.timerAPstart.clear();
|
||||
}
|
||||
@@ -288,7 +290,9 @@ bool prepareWiFi() {
|
||||
WiFiEventData.wifiConnectAttemptNeeded = false;
|
||||
|
||||
// No need to wait longer to start AP mode.
|
||||
setAP(true);
|
||||
if (!Settings.DoNotStartAP()) {
|
||||
setAP(true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
WiFiEventData.warnedNoValidWiFiSettings = false;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../Globals/RTC.h"
|
||||
#include "../Globals/SecuritySettings.h"
|
||||
#include "../Globals/Settings.h"
|
||||
#include "../Helpers/Misc.h"
|
||||
|
||||
#include "../../ESPEasy_common.h"
|
||||
|
||||
|
||||
@@ -82,6 +82,9 @@ void handle_config() {
|
||||
// When set you can use the Sensor in AP-Mode without being forced to /setup
|
||||
Settings.ApDontForceSetup(isFormItemChecked(F("ApDontForceSetup")));
|
||||
|
||||
// Usually the AP will be started when no WiFi is defined, or the defined one cannot be found. This flag may prevent it.
|
||||
Settings.DoNotStartAP(isFormItemChecked(F("DoNotStartAP")));
|
||||
|
||||
|
||||
// TD-er Read access control from form.
|
||||
SecuritySettings.IPblockLevel = getFormItemInt(F("ipblocklevel"));
|
||||
@@ -148,6 +151,14 @@ void handle_config() {
|
||||
addFormCheckBox(F("Don't force /setup in AP-Mode"), F("ApDontForceSetup"), Settings.ApDontForceSetup());
|
||||
addFormNote(F("When set you can use the Sensor in AP-Mode without being forced to /setup. /setup can still be called."));
|
||||
|
||||
addFormCheckBox(F("Do Not Start AP"), F("DoNotStartAP"), Settings.DoNotStartAP());
|
||||
#ifdef HAS_ETHERNET
|
||||
addFormNote(F("Do not allow to start an AP when unable to connect to configured LAN/WiFi"));
|
||||
#else
|
||||
addFormNote(F("Do not allow to start an AP when configured WiFi cannot be found"));
|
||||
#endif
|
||||
|
||||
|
||||
// TD-er add IP access box F("ipblocklevel")
|
||||
addFormSubHeader(F("Client IP filtering"));
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user