From 01f7148f3df8884dc813a30cdbf585e995f33a46 Mon Sep 17 00:00:00 2001 From: Juraj Andrassy Date: Tue, 7 Nov 2023 11:18:40 +0100 Subject: [PATCH] WiFiC3 - don't start DHCP in begin, if static IP is configured --- libraries/WiFi/src/WiFi.cpp | 5 +++-- libraries/WiFi/src/WiFiC3.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/WiFi/src/WiFi.cpp b/libraries/WiFi/src/WiFi.cpp index 98377ddc..35e282dd 100644 --- a/libraries/WiFi/src/WiFi.cpp +++ b/libraries/WiFi/src/WiFi.cpp @@ -25,7 +25,7 @@ int CWifi::begin(const char* ssid) { /* -------------------------------------------------------------------------- */ ni = CLwipIf::getInstance().get(NI_WIFI_STATION); CLwipIf::getInstance().connectToAp(ssid, nullptr); - if(ni != nullptr) { + if(ni != nullptr && !_useStaticIp) { ni->DhcpStart(); } @@ -39,7 +39,7 @@ int CWifi::begin(const char* ssid, const char *passphrase) { ni = CLwipIf::getInstance().get(NI_WIFI_STATION); CLwipIf::getInstance().connectToAp(ssid, passphrase); - if(ni != nullptr) { + if(ni != nullptr && !_useStaticIp) { ni->DhcpStart(); } @@ -96,6 +96,7 @@ extern uint8_t *IpAddress2uint8(IPAddress a); /* -------------------------------------------------------------------------- */ void CWifi::_config(IPAddress local_ip, IPAddress gateway, IPAddress subnet) { /* -------------------------------------------------------------------------- */ + _useStaticIp = true; if(ni != nullptr) { ni->DhcpStop(); ni->DhcpNotUsed(); diff --git a/libraries/WiFi/src/WiFiC3.h b/libraries/WiFi/src/WiFiC3.h index 54510a4e..f2bab286 100644 --- a/libraries/WiFi/src/WiFiC3.h +++ b/libraries/WiFi/src/WiFiC3.h @@ -9,6 +9,7 @@ class CWifi { private: void _config(IPAddress local_ip, IPAddress gateway, IPAddress subnet); unsigned long _timeout; + bool _useStaticIp = false; CNetIf *ni; public: