From c7e379aa51fefaadab46220ebad85ccc132f090b Mon Sep 17 00:00:00 2001 From: Bogdan Pilyugin Date: Tue, 20 Sep 2022 12:45:23 +0200 Subject: [PATCH] network connection delay fixed --- Kconfig | 7 +++++++ src/SystemConfiguration.c | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Kconfig b/Kconfig index 6a9d380..8a4b3df 100644 --- a/Kconfig +++ b/Kconfig @@ -23,6 +23,13 @@ menu "webguiapp configuration" help Set the GPIO number for main system button. Mainly needed for settings default reset. If not used set -1 + + config DEBUG_MODE_ENABLE + bool "Enabled JTAG debug" + default n + help + Switch on JTAG debug mode. Otherwise pins 12-15 used as normal GPIO + menu "SPI settings" config WEBGUIAPP_SPI_ENABLE diff --git a/src/SystemConfiguration.c b/src/SystemConfiguration.c index 2f92ee3..3996f54 100644 --- a/src/SystemConfiguration.c +++ b/src/SystemConfiguration.c @@ -50,10 +50,13 @@ static SYS_CONFIG SysConfig; #define SPI_LOCK_TIMEOUT_MS (1000) +#define NETWORK_START_TIMEOUT (60) SemaphoreHandle_t xSemaphoreSPIHandle = NULL; StaticSemaphore_t xSemaphoreSPIBuf; +static int NetworkStartTimeout = 0; + static void InitSysIO(void); static void InitSysSPI(void); static void InitSysI2C(void); @@ -76,7 +79,7 @@ esp_err_t WebGuiAppInit(void) err == ESP_ERR_NVS_NEW_VERSION_FOUND || MANUAL_RESET == 1 #if (CONFIG_MAIN_FUNCTIONAL_BUTTON_GPIO >= 0) - || gpio_get_level(GPIO_NUM_15) == 0 + || gpio_get_level(CONFIG_MAIN_FUNCTIONAL_BUTTON_GPIO) == 0 #endif ) { @@ -125,8 +128,18 @@ if(GetSysConf()->wifiSettings.Flags1.bIsAP) /*Start services depends on client connection*/ #if CONFIG_WEBGUIAPP_GPRS_ENABLE || CONFIG_WEBGUIAPP_ETHERNET_ENABLE || CONFIG_WEBGUIAPP_WIFI_ENABLE { + ESP_ERROR_CHECK(start_file_server()); if (!WiFiApOnly) { + //start all services + /*Wait for interfaces connected*/ + while (!(isPPPConnected() || + isWIFIConnected() || + isETHConnected() || + ++NetworkStartTimeout >= NETWORK_START_TIMEOUT)) + vTaskDelay(pdMS_TO_TICKS(1000)); + + //Start all services needed internet connection StartTimeGet(); #if CONFIG_WEBGUIAPP_MQTT_ENABLE @@ -137,7 +150,7 @@ if(GetSysConf()->wifiSettings.Flags1.bIsAP) } #endif } - ESP_ERROR_CHECK(start_file_server()); + #endif }