mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-07-29 01:52:51 +00:00
added application setting 'disable factory' Feature request->Button anti tampering mode
Fixes #3150
This commit is contained in:
@@ -134,6 +134,7 @@
|
|||||||
"modbus_max_clients": 10,
|
"modbus_max_clients": 10,
|
||||||
"modbus_timeout": 300,
|
"modbus_timeout": 300,
|
||||||
"developer_mode": true,
|
"developer_mode": true,
|
||||||
|
"disable_reset": false,
|
||||||
"email_enabled": true,
|
"email_enabled": true,
|
||||||
"email_security": 2,
|
"email_security": 2,
|
||||||
"email_server": "smtp.gmail.com",
|
"email_server": "smtp.gmail.com",
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export interface Settings {
|
|||||||
email_recp: string;
|
email_recp: string;
|
||||||
email_subject: string;
|
email_subject: string;
|
||||||
developer_mode: boolean;
|
developer_mode: boolean;
|
||||||
|
disable_reset: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum busConnectionStatus {
|
export enum busConnectionStatus {
|
||||||
|
|||||||
@@ -903,6 +903,16 @@ const ApplicationSettings = () => {
|
|||||||
}
|
}
|
||||||
label={LL.DEVELOPER_MODE()}
|
label={LL.DEVELOPER_MODE()}
|
||||||
/>
|
/>
|
||||||
|
<BlockFormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={data.disable_reset}
|
||||||
|
onChange={updateFormValue}
|
||||||
|
name="disable_reset"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={LL.DISABLE_RESET()}
|
||||||
|
/>
|
||||||
<BlockFormControlLabel
|
<BlockFormControlLabel
|
||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ interface VersionData {
|
|||||||
partition: string;
|
partition: string;
|
||||||
partitions: PartitionData[];
|
partitions: PartitionData[];
|
||||||
developer_mode: boolean;
|
developer_mode: boolean;
|
||||||
|
disable_reset: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Memoized components for better performance
|
// Memoized components for better performance
|
||||||
@@ -923,7 +924,7 @@ const Version = () => {
|
|||||||
>
|
>
|
||||||
{LL.RESTART()}
|
{LL.RESTART()}
|
||||||
</Button>
|
</Button>
|
||||||
{data.developer_mode && (
|
{!data.disable_reset && (
|
||||||
<Button
|
<Button
|
||||||
startIcon={<SettingsBackupRestoreIcon />}
|
startIcon={<SettingsBackupRestoreIcon />}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const cs: Translation = {
|
|||||||
AUTO_SCROLL: 'Automatické rolování',
|
AUTO_SCROLL: 'Automatické rolování',
|
||||||
DASHBOARD: 'Dashboard',
|
DASHBOARD: 'Dashboard',
|
||||||
DEVELOPER_MODE: 'Režim vývojáře',
|
DEVELOPER_MODE: 'Režim vývojáře',
|
||||||
|
DISABLE_RESET: 'Zakázat obnovení továrního nastavení',
|
||||||
BYTES: 'Bajty',
|
BYTES: 'Bajty',
|
||||||
BITMASK: 'Bit Mask',
|
BITMASK: 'Bit Mask',
|
||||||
DUPLICATE: 'Duplikát',
|
DUPLICATE: 'Duplikát',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const de: Translation = {
|
|||||||
AUTO_SCROLL: 'Automatisches Scrollen',
|
AUTO_SCROLL: 'Automatisches Scrollen',
|
||||||
DASHBOARD: 'Dashboard',
|
DASHBOARD: 'Dashboard',
|
||||||
DEVELOPER_MODE: 'Entwicklermodus',
|
DEVELOPER_MODE: 'Entwicklermodus',
|
||||||
|
DISABLE_RESET: 'Werkseinstellungen deaktivieren',
|
||||||
BYTES: 'Bytes',
|
BYTES: 'Bytes',
|
||||||
BITMASK: 'Bit Maske',
|
BITMASK: 'Bit Maske',
|
||||||
DUPLICATE: 'Kopieren',
|
DUPLICATE: 'Kopieren',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const en: Translation = {
|
|||||||
AUTO_SCROLL: 'Auto Scroll',
|
AUTO_SCROLL: 'Auto Scroll',
|
||||||
DASHBOARD: 'Dashboard',
|
DASHBOARD: 'Dashboard',
|
||||||
DEVELOPER_MODE: 'Developer Mode',
|
DEVELOPER_MODE: 'Developer Mode',
|
||||||
|
DISABLE_RESET: 'Disable Factory Reset',
|
||||||
BYTES: 'Bytes',
|
BYTES: 'Bytes',
|
||||||
BITMASK: 'Bit Mask',
|
BITMASK: 'Bit Mask',
|
||||||
DUPLICATE: 'Duplicate',
|
DUPLICATE: 'Duplicate',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const fr: Translation = {
|
|||||||
AUTO_SCROLL: 'Défilement automatique',
|
AUTO_SCROLL: 'Défilement automatique',
|
||||||
DASHBOARD: 'Tableau de bord',
|
DASHBOARD: 'Tableau de bord',
|
||||||
DEVELOPER_MODE: 'Mode développeur',
|
DEVELOPER_MODE: 'Mode développeur',
|
||||||
|
DISABLE_RESET: 'Désactiver la réinitialisation de fabrique',
|
||||||
BYTES: 'Octets',
|
BYTES: 'Octets',
|
||||||
BITMASK: 'Masque de bits',
|
BITMASK: 'Masque de bits',
|
||||||
DUPLICATE: 'Dupliquer',
|
DUPLICATE: 'Dupliquer',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const it: Translation = {
|
|||||||
AUTO_SCROLL: 'Scorrimento automatico',
|
AUTO_SCROLL: 'Scorrimento automatico',
|
||||||
DASHBOARD: 'Pannello di controllo',
|
DASHBOARD: 'Pannello di controllo',
|
||||||
DEVELOPER_MODE: 'Modalità sviluppatore',
|
DEVELOPER_MODE: 'Modalità sviluppatore',
|
||||||
|
DISABLE_RESET: 'Disabilita la ripristino di fabbrica',
|
||||||
BYTES: 'Byte',
|
BYTES: 'Byte',
|
||||||
BITMASK: 'Bitmask',
|
BITMASK: 'Bitmask',
|
||||||
DUPLICATE: 'Duplicato',
|
DUPLICATE: 'Duplicato',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const nl: Translation = {
|
|||||||
AUTO_SCROLL: 'Automatisch Scrollen',
|
AUTO_SCROLL: 'Automatisch Scrollen',
|
||||||
DASHBOARD: 'Dashboard',
|
DASHBOARD: 'Dashboard',
|
||||||
DEVELOPER_MODE: 'Ontwikkelaarsmodus',
|
DEVELOPER_MODE: 'Ontwikkelaarsmodus',
|
||||||
|
DISABLE_RESET: 'Fabrieksinstellingen uitschakelen',
|
||||||
BYTES: 'Bytes',
|
BYTES: 'Bytes',
|
||||||
BITMASK: 'Bit Mask',
|
BITMASK: 'Bit Mask',
|
||||||
DUPLICATE: 'Duplicaat',
|
DUPLICATE: 'Duplicaat',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const no: Translation = {
|
|||||||
AUTO_SCROLL: 'Automatisk rulling',
|
AUTO_SCROLL: 'Automatisk rulling',
|
||||||
DASHBOARD: 'Dashboard',
|
DASHBOARD: 'Dashboard',
|
||||||
DEVELOPER_MODE: 'Utvikler modus',
|
DEVELOPER_MODE: 'Utvikler modus',
|
||||||
|
DISABLE_RESET: 'Deaktiver fabrikkinnstillinger',
|
||||||
BYTES: 'Bytes',
|
BYTES: 'Bytes',
|
||||||
BITMASK: 'Bitmask',
|
BITMASK: 'Bitmask',
|
||||||
DUPLICATE: 'Duplikat',
|
DUPLICATE: 'Duplikat',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const pl: BaseTranslation = {
|
|||||||
AUTO_SCROLL: 'Auto Scroll',
|
AUTO_SCROLL: 'Auto Scroll',
|
||||||
DASHBOARD: 'Pulpit',
|
DASHBOARD: 'Pulpit',
|
||||||
DEVELOPER_MODE: 'Tryb programisty',
|
DEVELOPER_MODE: 'Tryb programisty',
|
||||||
|
DISABLE_RESET: 'Wyłącz reset fabryczny',
|
||||||
BYTES: 'Bajty',
|
BYTES: 'Bajty',
|
||||||
BITMASK: 'Bit Mask',
|
BITMASK: 'Bit Mask',
|
||||||
DUPLICATE: 'Duplicate',
|
DUPLICATE: 'Duplicate',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const sk: Translation = {
|
|||||||
AUTO_SCROLL: 'Automatické rolovanie',
|
AUTO_SCROLL: 'Automatické rolovanie',
|
||||||
DASHBOARD: 'Panel',
|
DASHBOARD: 'Panel',
|
||||||
DEVELOPER_MODE: 'Režim vývojára',
|
DEVELOPER_MODE: 'Režim vývojára',
|
||||||
|
DISABLE_RESET: 'Zakázať továrenské nastavenia',
|
||||||
BYTES: 'Bytov',
|
BYTES: 'Bytov',
|
||||||
BITMASK: 'Bitová maska',
|
BITMASK: 'Bitová maska',
|
||||||
DUPLICATE: 'Duplicitné',
|
DUPLICATE: 'Duplicitné',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const sv: Translation = {
|
|||||||
AUTO_SCROLL: 'Autoskrolla',
|
AUTO_SCROLL: 'Autoskrolla',
|
||||||
DASHBOARD: 'Kontrollpanel',
|
DASHBOARD: 'Kontrollpanel',
|
||||||
DEVELOPER_MODE: 'Utvecklarläge',
|
DEVELOPER_MODE: 'Utvecklarläge',
|
||||||
|
DISABLE_RESET: 'Inaktivera fabriksåterställning',
|
||||||
BYTES: 'Bytes',
|
BYTES: 'Bytes',
|
||||||
BITMASK: 'Bitmask',
|
BITMASK: 'Bitmask',
|
||||||
DUPLICATE: 'Dublett',
|
DUPLICATE: 'Dublett',
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ const tr: Translation = {
|
|||||||
AUTO_SCROLL: 'Otomatik kaydırma',
|
AUTO_SCROLL: 'Otomatik kaydırma',
|
||||||
DASHBOARD: 'Kontrol Paneli',
|
DASHBOARD: 'Kontrol Paneli',
|
||||||
DEVELOPER_MODE: 'Geliştirici Modu',
|
DEVELOPER_MODE: 'Geliştirici Modu',
|
||||||
|
DISABLE_RESET: 'Fabrika ayarlarını devre dışı bırak',
|
||||||
BYTES: 'Bayt',
|
BYTES: 'Bayt',
|
||||||
BITMASK: 'Bit Maskesi',
|
BITMASK: 'Bit Maskesi',
|
||||||
DUPLICATE: 'Çift',
|
DUPLICATE: 'Çift',
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export interface SystemStatus {
|
|||||||
}[];
|
}[];
|
||||||
status: number; // System Status Codes which matches SYSTEM_STATUS in System.h
|
status: number; // System Status Codes which matches SYSTEM_STATUS in System.h
|
||||||
developer_mode: boolean;
|
developer_mode: boolean;
|
||||||
|
disable_reset: boolean;
|
||||||
temperature?: number;
|
temperature?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ let settings = {
|
|||||||
modbus_port: 502,
|
modbus_port: 502,
|
||||||
modbus_max_clients: 10,
|
modbus_max_clients: 10,
|
||||||
modbus_timeout: 10000,
|
modbus_timeout: 10000,
|
||||||
developer_mode: true
|
developer_mode: true,
|
||||||
|
disable_reset: false
|
||||||
};
|
};
|
||||||
|
|
||||||
// EMS-ESP System Settings
|
// EMS-ESP System Settings
|
||||||
@@ -129,6 +130,7 @@ let system_status = {
|
|||||||
],
|
],
|
||||||
// partitions: [],
|
// partitions: [],
|
||||||
developer_mode: settings.developer_mode,
|
developer_mode: settings.developer_mode,
|
||||||
|
disable_reset: settings.disable_reset,
|
||||||
model: '',
|
model: '',
|
||||||
board: '',
|
board: '',
|
||||||
// model: 'BBQKees Electronics EMS Gateway E32 V2 (E32 V2.0 P3/2024011)',
|
// model: 'BBQKees Electronics EMS Gateway E32 V2 (E32 V2.0 P3/2024011)',
|
||||||
@@ -4721,6 +4723,7 @@ router
|
|||||||
settings = await request.json();
|
settings = await request.json();
|
||||||
console.log('application settings saved', settings);
|
console.log('application settings saved', settings);
|
||||||
system_status.developer_mode = settings.developer_mode;
|
system_status.developer_mode = settings.developer_mode;
|
||||||
|
system_status.disable_reset = settings.disable_reset;
|
||||||
return status(200); // no restart needed
|
return status(200); // no restart needed
|
||||||
// return status(205); // reboot required
|
// return status(205); // reboot required
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ void LED::led_fast_flash() {
|
|||||||
set_led(led_flash_state_ ? Color::YELLOW : Color::OFF); // Yellow
|
set_led(led_flash_state_ ? Color::YELLOW : Color::OFF); // Yellow
|
||||||
}
|
}
|
||||||
|
|
||||||
// after duration, turn off the LED
|
// after duration, turn off the LED, and call the format command
|
||||||
if (current_time - led_flash_start_time_ >= led_flash_duration_) {
|
if (current_time - led_flash_start_time_ >= led_flash_duration_) {
|
||||||
set_led(Color::OFF);
|
set_led(Color::OFF);
|
||||||
led_fast_flash_timer_ = false;
|
led_fast_flash_timer_ = false;
|
||||||
|
|||||||
@@ -677,6 +677,7 @@ void System::store_settings(WebSettings & settings) {
|
|||||||
locale_ = settings.locale;
|
locale_ = settings.locale;
|
||||||
system_name_ = settings.system_name;
|
system_name_ = settings.system_name;
|
||||||
developer_mode_ = settings.developer_mode;
|
developer_mode_ = settings.developer_mode;
|
||||||
|
disable_reset_ = settings.disable_reset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starts up core services
|
// Starts up core services
|
||||||
@@ -761,6 +762,10 @@ void System::button_OnLongPress(PButton & b) {
|
|||||||
|
|
||||||
// button indefinite press
|
// button indefinite press
|
||||||
void System::button_OnVLongPress(PButton & b) {
|
void System::button_OnVLongPress(PButton & b) {
|
||||||
|
if (EMSESP::system_.disable_reset()) {
|
||||||
|
LOG_NOTICE("Factory reset disabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
LOG_NOTICE("Button pressed - very long press - perform factory reset");
|
LOG_NOTICE("Button pressed - very long press - perform factory reset");
|
||||||
EMSESP::led_.start_led_fast_flash(5); // Start LED flash timer for 5 seconds
|
EMSESP::led_.start_led_fast_flash(5); // Start LED flash timer for 5 seconds
|
||||||
}
|
}
|
||||||
@@ -2646,6 +2651,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
|
|||||||
node["modbusEnabled"] = settings.modbus_enabled;
|
node["modbusEnabled"] = settings.modbus_enabled;
|
||||||
node["forceHeatingOff"] = settings.boiler_heatingoff;
|
node["forceHeatingOff"] = settings.boiler_heatingoff;
|
||||||
node["developerMode"] = settings.developer_mode;
|
node["developerMode"] = settings.developer_mode;
|
||||||
|
node["disableReset"] = settings.disable_reset;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Devices - show EMS devices if we have any
|
// Devices - show EMS devices if we have any
|
||||||
@@ -2870,6 +2876,12 @@ bool System::command_txpause(const char * value, const int8_t id) {
|
|||||||
|
|
||||||
// format command - factory reset, removing all config files
|
// format command - factory reset, removing all config files
|
||||||
bool System::command_format(const char * value, const int8_t id) {
|
bool System::command_format(const char * value, const int8_t id) {
|
||||||
|
|
||||||
|
if (EMSESP::system_.disable_reset()) {
|
||||||
|
LOG_NOTICE("Factory reset disabled");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(EMSESP_STANDALONE) && !defined(EMSESP_TEST)
|
#if !defined(EMSESP_STANDALONE) && !defined(EMSESP_TEST)
|
||||||
// don't really format the filesystem in test or standalone mode
|
// don't really format the filesystem in test or standalone mode
|
||||||
if (LittleFS.format()) {
|
if (LittleFS.format()) {
|
||||||
|
|||||||
@@ -199,6 +199,14 @@ class System {
|
|||||||
developer_mode_ = developer_mode;
|
developer_mode_ = developer_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool disable_reset() {
|
||||||
|
return disable_reset_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void disable_reset(bool disable_reset) {
|
||||||
|
disable_reset_ = disable_reset;
|
||||||
|
}
|
||||||
|
|
||||||
// Boolean Format API/MQTT
|
// Boolean Format API/MQTT
|
||||||
uint8_t bool_format() {
|
uint8_t bool_format() {
|
||||||
return bool_format_;
|
return bool_format_;
|
||||||
@@ -438,6 +446,7 @@ class System {
|
|||||||
uint8_t modbus_max_clients_;
|
uint8_t modbus_max_clients_;
|
||||||
uint32_t modbus_timeout_;
|
uint32_t modbus_timeout_;
|
||||||
bool developer_mode_;
|
bool developer_mode_;
|
||||||
|
bool disable_reset_;
|
||||||
uint32_t fstotal_;
|
uint32_t fstotal_;
|
||||||
uint32_t psram_;
|
uint32_t psram_;
|
||||||
uint32_t appused_;
|
uint32_t appused_;
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ void WebSettings::read(WebSettings & settings, JsonObject root) {
|
|||||||
root["modbus_max_clients"] = settings.modbus_max_clients;
|
root["modbus_max_clients"] = settings.modbus_max_clients;
|
||||||
root["modbus_timeout"] = settings.modbus_timeout;
|
root["modbus_timeout"] = settings.modbus_timeout;
|
||||||
root["developer_mode"] = settings.developer_mode;
|
root["developer_mode"] = settings.developer_mode;
|
||||||
|
root["disable_reset"] = settings.disable_reset;
|
||||||
root["email_enabled"] = settings.email_enabled;
|
root["email_enabled"] = settings.email_enabled;
|
||||||
root["email_security"] = settings.email_security;
|
root["email_security"] = settings.email_security;
|
||||||
root["email_server"] = settings.email_server;
|
root["email_server"] = settings.email_server;
|
||||||
@@ -306,6 +307,9 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
|
|||||||
settings.developer_mode = root["developer_mode"];
|
settings.developer_mode = root["developer_mode"];
|
||||||
EMSESP::system_.developer_mode(settings.developer_mode);
|
EMSESP::system_.developer_mode(settings.developer_mode);
|
||||||
|
|
||||||
|
settings.disable_reset = root["disable_reset"];
|
||||||
|
EMSESP::system_.disable_reset(settings.disable_reset);
|
||||||
|
|
||||||
settings.bool_dashboard = root["bool_dashboard"] | EMSESP_DEFAULT_BOOL_FORMAT;
|
settings.bool_dashboard = root["bool_dashboard"] | EMSESP_DEFAULT_BOOL_FORMAT;
|
||||||
EMSESP::system_.bool_dashboard(settings.bool_dashboard);
|
EMSESP::system_.bool_dashboard(settings.bool_dashboard);
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ class WebSettings {
|
|||||||
uint8_t eth_clock_mode;
|
uint8_t eth_clock_mode;
|
||||||
|
|
||||||
bool developer_mode; // developer mode
|
bool developer_mode; // developer mode
|
||||||
|
bool disable_reset; // disable reset
|
||||||
|
|
||||||
static void read(WebSettings & settings, JsonObject root);
|
static void read(WebSettings & settings, JsonObject root);
|
||||||
static StateUpdateResult update(JsonObject root, WebSettings & settings);
|
static StateUpdateResult update(JsonObject root, WebSettings & settings);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -131,6 +131,7 @@
|
|||||||
"modbus_max_clients": 10,
|
"modbus_max_clients": 10,
|
||||||
"modbus_timeout": 300,
|
"modbus_timeout": 300,
|
||||||
"developer_mode": true,
|
"developer_mode": true,
|
||||||
|
"disable_reset": false,
|
||||||
"email_enabled": false,
|
"email_enabled": false,
|
||||||
"email_security": 2,
|
"email_security": 2,
|
||||||
"email_server": "smtp.example.net",
|
"email_server": "smtp.example.net",
|
||||||
|
|||||||
@@ -132,7 +132,8 @@
|
|||||||
"modbus_port": 502,
|
"modbus_port": 502,
|
||||||
"modbus_max_clients": 10,
|
"modbus_max_clients": 10,
|
||||||
"modbus_timeout": 300,
|
"modbus_timeout": 300,
|
||||||
"developer_mode": true
|
"developer_mode": true,
|
||||||
|
"disable_reset": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user