Skip to content

Commit

Permalink
Merge pull request #179 from JAndrassy/wific3_staticip_fix
Browse files Browse the repository at this point in the history
WiFiC3 - don't start DHCP in begin, if static IP is configured
  • Loading branch information
facchinm authored Nov 13, 2023
2 parents 3a1b8a3 + 0a07e2f commit 773fdc0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 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 = local_ip != INADDR_NONE;
if(ni != nullptr) {
ni->DhcpStop();
ni->DhcpNotUsed();
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 773fdc0

Please sign in to comment.