From c8d42a282bbf0ad2e763788a5f0c1ba08212c83d Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 24 Sep 2022 10:55:49 +0200 Subject: [PATCH] added reset flag for user application read/write --- include/webguiapp.h | 2 ++ src/SystemConfiguration.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/webguiapp.h b/include/webguiapp.h index d74202b..2accad7 100644 --- a/include/webguiapp.h +++ b/include/webguiapp.h @@ -35,5 +35,7 @@ esp_err_t spi_device_polling_transmit_synchronized(spi_device_handle_t handle, spi_transaction_t *trans_desc); +bool GetUserAppNeedReset(void); +void SetUserAppNeedReset(bool res); #endif /* COMPONENTS_WEBGUIAPPCOMPONENT_INCLUDE_WEBGUIAPP_H_ */ diff --git a/src/SystemConfiguration.c b/src/SystemConfiguration.c index 3996f54..295aa8c 100644 --- a/src/SystemConfiguration.c +++ b/src/SystemConfiguration.c @@ -56,6 +56,7 @@ SemaphoreHandle_t xSemaphoreSPIHandle = NULL; StaticSemaphore_t xSemaphoreSPIBuf; static int NetworkStartTimeout = 0; +static bool isUserAppNeedReset = false; static void InitSysIO(void); static void InitSysSPI(void); @@ -87,6 +88,7 @@ esp_err_t WebGuiAppInit(void) // partition table. This size mismatch may cause NVS initialization to fail. // 2.NVS partition contains data in new format and cannot be recognized by this version of code. // If this happens, we erase NVS partition and initialize NVS again. + isUserAppNeedReset = true; ESP_ERROR_CHECK(nvs_flash_erase()); ESP_ERROR_CHECK(nvs_flash_init()); ESP_ERROR_CHECK(ResetInitSysConfig()); @@ -399,3 +401,13 @@ void DelayedRestart(void) { xTaskCreate(DelayedRestartTask, "RestartTask", 1024 * 4, (void*) 0, 3, NULL); } + +bool GetUserAppNeedReset(void) +{ + return isUserAppNeedReset; +} + +void SetUserAppNeedReset(bool res) +{ + isUserAppNeedReset = res; +}