From dae545a63eab2895f730edc552756c26fa514364 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sun, 3 Dec 2023 02:37:50 +0700 Subject: [PATCH] automatically initialize new device with webui username and password --- src/espmega_iot_core.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index 3d4625d..50e1bd4 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -247,6 +247,14 @@ void eeprom_retrieve_init() #ifdef ENABLE_WEBUI ESPMega_FRAM.read(EEPROM_ADDRESS_WEBUI_USERNAME, (uint8_t *)WEBUI_USERNAME, 32); ESPMega_FRAM.read(EEPROM_ADDRESS_WEBUI_PASSWORD, (uint8_t *)WEBUI_PASSWORD, 32); + if(strlen(WEBUI_USERNAME)==0) { + strcpy(WEBUI_USERNAME,"admin"); + ESPMega_FRAM.write(EEPROM_ADDRESS_WEBUI_USERNAME, (uint8_t *)WEBUI_USERNAME, 32); + } + if(strlen(WEBUI_PASSWORD)==0) { + strcpy(WEBUI_PASSWORD,"admin"); + ESPMega_FRAM.write(EEPROM_ADDRESS_WEBUI_PASSWORD, (uint8_t *)WEBUI_PASSWORD, 32); + } #endif // EEPROM Data Retrival #ifdef ENABLE_CLIMATE_MODULE