Skip to content

Commit

Permalink
WiFiC3 - don't start DHCP in begin, if static IP is configured
Browse files Browse the repository at this point in the history
  • Loading branch information
JAndrassy committed Nov 7, 2023
1 parent 9a838ba commit cb45d1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libraries/WiFi/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -158,6 +159,7 @@ void CWifi::setHostname(const char* name) {
/* -------------------------------------------------------------------------- */
int CWifi::disconnect() {
/* -------------------------------------------------------------------------- */
_useStaticIp = false;
CLwipIf::getInstance().disconnectFromAp();
}

Expand Down
1 change: 1 addition & 0 deletions libraries/WiFi/src/WiFiC3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cb45d1b

Please sign in to comment.