mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
[Factory Reset] Add default flags for factory reset
This commit is contained in:
@@ -60,6 +60,8 @@ build_flags = ${core_esp32_IDF5_1__3_0_0.build_flags}
|
||||
-flto=auto
|
||||
-Wswitch
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
|
||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO
|
||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
||||
-DLWIP_IPV6
|
||||
monitor_filters = esp32_exception_decoder
|
||||
lib_ignore =
|
||||
|
||||
@@ -165,6 +165,14 @@
|
||||
#define DEFAULT_SYNC_UDP_PORT 8266 // Used for ESPEasy p2p. (IANA registered port: 8266)
|
||||
|
||||
|
||||
// Factory Reset defaults
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_UNIT_NAME true
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_WIFI true
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_NETWORK true
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_NTP_DST true
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_CONSOLE_LOG true
|
||||
|
||||
|
||||
#define BUILD_NO_DEBUG
|
||||
|
||||
// Custom built-in url for hosting JavaScript and CSS files.
|
||||
|
||||
@@ -374,6 +374,26 @@
|
||||
#define DEFAULT_SYNC_UDP_PORT 8266 // Used for ESPEasy p2p. (IANA registered port: 8266)
|
||||
#endif
|
||||
|
||||
|
||||
// Factory Reset defaults
|
||||
#ifndef DEFAULT_FACTORY_RESET_KEEP_UNIT_NAME
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_UNIT_NAME true
|
||||
#endif
|
||||
#ifndef DEFAULT_FACTORY_RESET_KEEP_WIFI
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_WIFI true
|
||||
#endif
|
||||
#ifndef DEFAULT_FACTORY_RESET_KEEP_NETWORK
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_NETWORK true
|
||||
#endif
|
||||
#ifndef DEFAULT_FACTORY_RESET_KEEP_NTP_DST
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_NTP_DST true
|
||||
#endif
|
||||
#ifndef DEFAULT_FACTORY_RESET_KEEP_CONSOLE_LOG
|
||||
#define DEFAULT_FACTORY_RESET_KEEP_CONSOLE_LOG true
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// --- Defaults to be used for custom automatic provisioning builds ------------------------------------
|
||||
#if FEATURE_CUSTOM_PROVISIONING
|
||||
#ifndef DEFAULT_FACTORY_DEFAULT_DEVICE_MODEL
|
||||
|
||||
@@ -22,6 +22,23 @@ bool ResetFactoryDefaultPreference_struct::init()
|
||||
{
|
||||
ESPEasy_NVS_Helper nvs_helper;
|
||||
|
||||
// Set bits to default, will be overwritten if there was a different setting stored in NVS
|
||||
#if DEFAULT_FACTORY_RESET_KEEP_UNIT_NAME
|
||||
bits.keepUnitName = 1;
|
||||
#endif
|
||||
#if DEFAULT_FACTORY_RESET_KEEP_WIFI
|
||||
bits.keepWiFi = 1;
|
||||
#endif
|
||||
#if DEFAULT_FACTORY_RESET_KEEP_NETWORK
|
||||
bits.keepNetwork = 1;
|
||||
#endif
|
||||
#if DEFAULT_FACTORY_RESET_KEEP_NTP_DST
|
||||
bits.keepNTP = 1;
|
||||
#endif
|
||||
#if DEFAULT_FACTORY_RESET_KEEP_CONSOLE_LOG
|
||||
bits.keepLogConsoleSettings = 1;
|
||||
#endif
|
||||
|
||||
if (nvs_helper.begin(F(FACTORY_DEFAULT_NVS_NAMESPACE))) {
|
||||
return from_NVS(nvs_helper);
|
||||
}
|
||||
|
||||
@@ -315,6 +315,7 @@ bool WiFiConnected() {
|
||||
if (!WiFiEventData.wifiConnectAttemptNeeded) {
|
||||
addLog(LOG_LEVEL_INFO, F("WiFi : WiFiConnected(), start AP"));
|
||||
WifiScan(false);
|
||||
setSTA(false); // Force reset WiFi + reduce power consumption
|
||||
setAP(true);
|
||||
}
|
||||
}
|
||||
@@ -1217,7 +1218,13 @@ void setAPinternal(bool enable)
|
||||
IPAddress subnet(DEFAULT_AP_SUBNET);
|
||||
|
||||
if (!WiFi.softAPConfig(apIP, apIP, subnet)) {
|
||||
addLog(LOG_LEVEL_ERROR, F("WIFI : [AP] softAPConfig failed!"));
|
||||
addLog(LOG_LEVEL_ERROR, strformat(
|
||||
("WIFI : [AP] softAPConfig failed! IP: %s, GW: %s, SN: %s"),
|
||||
apIP.toString().c_str(),
|
||||
apIP.toString().c_str(),
|
||||
subnet.toString().c_str()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
int channel = 1;
|
||||
|
||||
Reference in New Issue
Block a user