diff --git a/src/hal/bl602/hal_flashConfig_bl602.c b/src/hal/bl602/hal_flashConfig_bl602.c index fcb80e8f9..fe6a5ef30 100644 --- a/src/hal/bl602/hal_flashConfig_bl602.c +++ b/src/hal/bl602/hal_flashConfig_bl602.c @@ -25,6 +25,7 @@ int HAL_Configuration_ReadConfigMemory(void *target, int dataLen){ ADDLOG_DEBUG(LOG_FEATURE_CFG, "HAL_Configuration_ReadConfigMemory: will read %d bytes", dataLen); readLen = ef_get_env_blob(EASYFLASH_MY_OBK_CONF, target, dataLen , NULL); + ADDLOG_DEBUG(LOG_FEATURE_CFG, "HAL_Configuration_ReadConfigMemory: really loaded %d bytes", readLen); return dataLen; } diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 1cc52d977..ba55b3a4f 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -303,6 +303,8 @@ int http_fn_cfg_mqtt_set(http_request_t *request) { CFG_SetMQTTBrokerName(tmpA); } + CFG_Save_IfThereArePendingChanges(); + poststr(request,"Please wait for module to connect... if there is problem, restart it from Index html page..."); poststr(request,"
"); diff --git a/src/new_cfg.c b/src/new_cfg.c index b80bdafb8..b3c00f8da 100644 --- a/src/new_cfg.c +++ b/src/new_cfg.c @@ -10,7 +10,7 @@ mainConfig_t g_cfg; -static int g_cfg_pendingChanges = 0; +int g_cfg_pendingChanges = 0; #define CFG_IDENT_0 'C' #define CFG_IDENT_1 'F' @@ -194,6 +194,18 @@ void CFG_Save_IfThereArePendingChanges() { g_cfg_pendingChanges = 0; } } +void PIN_SetPinChannelForPinIndex(int index, int ch) { + if(g_cfg.pins.channels[index] != ch) { + g_cfg_pendingChanges++; + g_cfg.pins.channels[index] = ch; + } +} +void PIN_SetPinChannel2ForPinIndex(int index, int ch) { + if(g_cfg.pins.channels2[index] != ch) { + g_cfg_pendingChanges++; + g_cfg.pins.channels2[index] = ch; + } +} void CFG_InitAndLoad() { byte chkSum; diff --git a/src/new_cfg.h b/src/new_cfg.h index 5748e44fd..a91e754df 100644 --- a/src/new_cfg.h +++ b/src/new_cfg.h @@ -1,6 +1,7 @@ - + +extern int g_cfg_pendingChanges; const char *CFG_GetDeviceName(); const char *CFG_GetShortDeviceName(); diff --git a/src/new_pins.c b/src/new_pins.c index bcf44f960..7b2f22102 100644 --- a/src/new_pins.c +++ b/src/new_pins.c @@ -3,6 +3,7 @@ #include "new_common.h" #include "new_pins.h" +#include "new_cfg.h" #include "httpserver/new_http.h" #include "logging/logging.h" // Commands register, execution API and cmd tokenizer @@ -293,7 +294,10 @@ void PIN_SetPinRoleForPinIndex(int index, int role) { } } // set new role - g_cfg.pins.roles[index] = role; + if(g_cfg.pins.roles[index] != role) { + g_cfg.pins.roles[index] = role; + g_cfg_pendingChanges++; + } if (g_enable_pins) { // init new role @@ -346,12 +350,6 @@ void PIN_SetPinRoleForPinIndex(int index, int role) { } } -void PIN_SetPinChannelForPinIndex(int index, int ch) { - g_cfg.pins.channels[index] = ch; -} -void PIN_SetPinChannel2ForPinIndex(int index, int ch) { - g_cfg.pins.channels2[index] = ch; -} void PIN_SetGenericDoubleClickCallback(void (*cb)(int pinIndex)) { g_doubleClickCallback = cb; }