From 3849e161e52887bacc3e1dddbafd82d343a5550d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Fri, 22 Sep 2017 00:30:16 +0200 Subject: [PATCH] add pwlock settings to sysconf --- user/syscfg.c | 12 +++++++++++- user/syscfg.h | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/user/syscfg.c b/user/syscfg.c index df27de7..d4b262f 100644 --- a/user/syscfg.c +++ b/user/syscfg.c @@ -12,7 +12,17 @@ SystemConfigBundle * const sysconf = &persist.current.sysconf; void ICACHE_FLASH_ATTR sysconf_apply_settings(void) { - // !!! Update to current version !!! + bool changed = false; + if (sysconf->config_version < 1) { + dbg("Upgrading syscfg to v 1"); + changed = true; + sysconf->access_pw[0] = 0; + sysconf->pwlock = PWLOCK_NONE; + } + + if (changed) { + persist_store(); + } serialInit(); } diff --git a/user/syscfg.h b/user/syscfg.h index 92997c9..624dfe3 100644 --- a/user/syscfg.h +++ b/user/syscfg.h @@ -10,13 +10,23 @@ // Size designed for the wifi config structure // Must be constant to avoid corrupting user config after upgrade #define SYSCONF_SIZE 200 -#define SYSCONF_VERSION 0 +#define SYSCONF_VERSION 1 + +enum pwlock { + PWLOCK_NONE = 0, + PWLOCK_SETTINGS_NOTERM = 1, + PWLOCK_SETTINGS_ALL = 2, + PWLOCK_MENUS = 3, + PWLOCK_ALL = 4, +}; typedef struct { u32 uart_baudrate; u8 uart_parity; u8 uart_stopbits; u8 config_version; + enum pwlock pwlock : 8; // page access lock + char access_pw[64]; // access password } SystemConfigBundle; extern SystemConfigBundle * const sysconf;