[SYS] User friendly manual network configuration (#1715)

* User friendly manual network configuration

* Add manual network config to the docs

* Add manual network config to the test env

Co-authored-by: DigiH <github@digih.net>
This commit is contained in:
Vitaliy DandDigiH authored and GitHub committed 2023-08-05 13:41:57 -05:00
1 parent fac602e457
commit 2aa4368538
4 files changed
+75 -23

No files matched your search

+11 -5
View File
@@ -68,12 +68,18 @@
//#define NetworkAdvancedSetup true //uncomment if you want to set advanced network parameters, not uncommented you can set the IP and MAC only
#ifdef NetworkAdvancedSetup
# if defined(ESP8266) || defined(ESP32)
const byte ip[] = {192, 168, 1, 99}; //IP address of the gateway, already defined for arduino below
# ifndef NET_IP
# define NET_IP "192.168.1.99"
# endif
# ifndef NET_MASK
# define NET_MASK "255.255.255.0"
# endif
# ifndef NET_GW
# define NET_GW "192.168.1.1"
# endif
# ifndef NET_DNS
# define NET_DNS "192.168.1.1"
# endif
const byte gateway[] = {0, 0, 0, 0};
const byte Dns[] = {0, 0, 0, 0};
const byte subnet[] = {255, 255, 255, 0};
#endif
#if defined(ESP8266) || defined(ESP32) // for nodemcu, weemos and esp8266
+36 -8
View File
@@ -1348,10 +1348,15 @@ void setup_wifi() {
// We start by connecting to a WiFi network
# ifdef NetworkAdvancedSetup
IPAddress ip_adress(ip);
IPAddress gateway_adress(gateway);
IPAddress subnet_adress(subnet);
IPAddress dns_adress(Dns);
IPAddress ip_adress;
IPAddress gateway_adress;
IPAddress subnet_adress;
IPAddress dns_adress;
ip_adress.fromString(NET_IP);
gateway_adress.fromString(NET_GW);
subnet_adress.fromString(NET_MASK);
dns_adress.fromString(NET_DNS);
if (!WiFi.config(ip_adress, gateway_adress, subnet_adress, dns_adress)) {
Log.error(F("Wifi STA Failed to configure" CR));
}
@@ -1589,10 +1594,15 @@ void setup_wifimanager(bool reset_settings) {
//set static IP
# ifdef NetworkAdvancedSetup
Log.trace(F("Adv wifi cfg" CR));
IPAddress gateway_adress(gateway);
IPAddress subnet_adress(subnet);
IPAddress ip_adress(ip);
wifiManager.setSTAStaticIPConfig(ip_adress, gateway_adress, subnet_adress);
IPAddress ip_adress;
IPAddress gateway_adress;
IPAddress subnet_adress;
IPAddress dns_adress;
ip_adress.fromString(NET_IP);
gateway_adress.fromString(NET_GW);
subnet_adress.fromString(NET_MASK);
dns_adress.fromString(NET_DNS);
wifiManager.setSTAStaticIPConfig(ip_adress, gateway_adress, subnet_adress, dns_adress);
# endif
# ifndef WIFIMNG_HIDE_MQTT_CONFIG
@@ -1691,6 +1701,15 @@ void setup_ethernet_esp32() {
bool ethBeginSuccess = false;
WiFi.onEvent(WiFiEvent);
# ifdef NetworkAdvancedSetup
IPAddress ip_adress;
IPAddress gateway_adress;
IPAddress subnet_adress;
IPAddress dns_adress;
ip.fromString(NET_IP);
gateway.fromString(NET_GW);
subnet.fromString(NET_MASK);
Dns.fromString(NET_DNS);
Log.trace(F("Adv eth cfg" CR));
ETH.config(ip, gateway, subnet, Dns);
ethBeginSuccess = ETH.begin();
@@ -1736,6 +1755,15 @@ void WiFiEvent(WiFiEvent_t event) {
#else // Arduino case
void setup_ethernet() {
# ifdef NetworkAdvancedSetup
IPAddress ip_adress;
IPAddress gateway_adress;
IPAddress subnet_adress;
IPAddress dns_adress;
ip.fromString(NET_IP);
gateway.fromString(NET_GW);
subnet.fromString(NET_MASK);
Dns.fromString(NET_DNS);
Log.trace(F("Adv eth cfg" CR));
Ethernet.begin(mac, ip, Dns, gateway, subnet);
# else