From 540da33248dda5a232c136ab2009c42332f13ff2 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 18 Aug 2022 09:46:03 +0200 Subject: [PATCH] DNS configuration added --- Kconfig | 18 ++++++++++++++++++ src/SystemConfiguration.c | 13 ++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Kconfig b/Kconfig index e1efa0b..8fe443c 100644 --- a/Kconfig +++ b/Kconfig @@ -593,5 +593,23 @@ menu "WebGuiApp configuration" endif endmenu + + if WEBGUIAPP_WIFI_ENABLE || WEBGUIAPP_ETHERNET_ENABLE || WEBGUIAPP_GPRS_ENABLE + menu "DNS settings" + + config WEBGUIAPP_DNS1_ADDRESS_DEFAULT + string "DNS1" + default "8.8.8.8" + + config WEBGUIAPP_DNS2_ADDRESS_DEFAULT + string "DNS2" + default "8.8.4.4" + + config WEBGUIAPP_DNS3_ADDRESS_DEFAULT + string "DNS3" + default "1.1.1.1" + + endmenu + endif endmenu \ No newline at end of file diff --git a/src/SystemConfiguration.c b/src/SystemConfiguration.c index 617b07b..320d2a1 100644 --- a/src/SystemConfiguration.c +++ b/src/SystemConfiguration.c @@ -46,6 +46,10 @@ static void ResetSysConfig(SYS_CONFIG *Conf) memcpy(Conf->wifiSettings.InfSSID, CONFIG_WEBGUIAPP_WIFI_SSID_STA, sizeof(CONFIG_WEBGUIAPP_WIFI_SSID_STA)); memcpy(Conf->wifiSettings.InfSecurityKey, CONFIG_WEBGUIAPP_WIFI_KEY_STA, sizeof(CONFIG_WEBGUIAPP_WIFI_KEY_STA)); Conf->wifiSettings.Flags1.bIsDHCPEnabled = CONFIG_WEBGUIAPP_WIFI_DHCP_ON; + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS1_ADDRESS_DEFAULT, (esp_ip4_addr_t*)&Conf->wifiSettings.DNSAddr1); + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS2_ADDRESS_DEFAULT, (esp_ip4_addr_t*)&Conf->wifiSettings.DNSAddr2); + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS3_ADDRESS_DEFAULT, (esp_ip4_addr_t*)&Conf->wifiSettings.DNSAddr3); + #endif #if CONFIG_WEBGUIAPP_ETHERNET_ENABLE @@ -53,14 +57,21 @@ static void ResetSysConfig(SYS_CONFIG *Conf) esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_ETH_IP_DEFAULT, (esp_ip4_addr_t*) &Conf->ethSettings.IPAddr); esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_ETH_MASK_DEFAULT, (esp_ip4_addr_t*) &Conf->ethSettings.Mask); esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_ETH_GATEWAY_DEFAULT, (esp_ip4_addr_t*) &Conf->ethSettings.Gateway); - Conf->ethSettings.Flags1.bIsDHCPEnabled = CONFIG_WEBGUIAPP_ETHERNET_DHCP_ON ; + //Conf->ethSettings.Flags1.bIsDHCPEnabled = CONFIG_WEBGUIAPP_ETHERNET_DHCP_ON ; + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS1_ADDRESS_DEFAULT, (esp_ip4_addr_t*)&Conf->ethSettings.DNSAddr1); + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS2_ADDRESS_DEFAULT, (esp_ip4_addr_t*)&Conf->ethSettings.DNSAddr2); + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS3_ADDRESS_DEFAULT, (esp_ip4_addr_t*)&Conf->ethSettings.DNSAddr3); #endif #if CONFIG_WEBGUIAPP_GPRS_ENABLE Conf->gsmSettings.Flags1.bIsGSMEnabled = true; + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS1_ADDRESS_DEFAULT, (esp_ip4_addr_t*)&Conf->gsmSettings.DNSAddr1); + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS2_ADDRESS_DEFAULT, (esp_ip4_addr_t*)&Conf->gsmSettings.DNSAddr2); + esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS3_ADDRESS_DEFAULT, (esp_ip4_addr_t*)&Conf->gsmSettings.DNSAddr3); #endif + #if CONFIG_WEBGUIAPP_MQTT_ENABLE Conf->mqttStation[0].Flags1.bIsGlobalEnabled = CONFIG_MQTT_ON; memcpy(Conf->mqttStation[0].ServerAddr, CONFIG_MQTT_SERVER_URL, sizeof(CONFIG_MQTT_SERVER_URL));