Add missing WiFi.h #include directive#138
Open
per1234 wants to merge 1 commit into
Open
Conversation
The "EspMQTTClient" library references objects declared by the `WiFi.h` header in the "esp32" boards platform's bundled
"WiFi" library.
Previously, the "EspMQTTClient" library relied on its `#include` directive for the `WebServer.h` header of the
"WiFiServer" library providing an `#include` directive for the `WiFi.h` header. This fragile code was broken by changes
made in the version of the "WiFiServer" library bundled with the 3.0.0 release of the "esp32" boards platform, causing
the library to no longer compile for ESP32-based boards:
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'bool EspMQTTClient::handleWiFi()':
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:187:5: error: 'WiFi' was not declared in this scope
187 | WiFi.disconnect(true);
| ^~~~
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:194:27: error: 'WiFi' was not declared in this scope
194 | bool isWifiConnected = (WiFi.status() == WL_CONNECTED);
| ^~~~
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:194:44: error: 'WL_CONNECTED' was not declared in this scope; did you mean 'MQTT_CONNECTED'?
194 | bool isWifiConnected = (WiFi.status() == WL_CONNECTED);
| ^~~~~~~~~~~~
| MQTT_CONNECTED
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:215:27: error: 'WL_CONNECT_FAILED' was not declared in this scope; did you mean 'MQTT_CONNECT_FAILED'?
215 | if(WiFi.status() == WL_CONNECT_FAILED || millis() - _lastWifiConnectiomAttemptMillis >= _wifiReconnectionAttemptDelay)
| ^~~~~~~~~~~~~~~~~
| MQTT_CONNECT_FAILED
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'bool EspMQTTClient::handleMQTT()':
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:325:9: error: 'WiFi' was not declared in this scope
325 | WiFi.disconnect(true);
| ^~~~
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::onWiFiConnectionEstablished()':
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:362:75: error: 'WiFi' was not declared in this scope
362 | Serial.printf("WiFi: Connected (%fs), ip : %s \n", millis()/1000.0, WiFi.localIP().toString().c_str());
| ^~~~
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::onWiFiConnectionLost()':
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:388:5: error: 'WiFi' was not declared in this scope
388 | WiFi.disconnect(true);
| ^~~~
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::connectToWifi()':
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:555:3: error: 'WiFi' was not declared in this scope
555 | WiFi.mode(WIFI_STA);
| ^~~~
c:\Users\per\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:555:13: error: 'WIFI_STA' was not declared in this scope; did you mean 'WIFI_IF_STA'?
555 | WiFi.mode(WIFI_STA);
| ^~~~~~~~
| WIFI_IF_STA
The bug is solved by adding an `#include` directive for the `WiFi.h` header the "EspMQTTClient" library depends on.
|
Thanks for posting this! |
|
This issue, also if fixed by adding the WiFi.h library, couse the impossibility to set static IP Address by adding WiFi.config(local_IP, gateway, subnet, primaryDNS) in the setup of the program. It worked for sure until the 3.0.0 release of the "esp32" boards platform. Can you check and fix the library to manage static IP Address in some way? Thanks |
|
any update on this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The "EspMQTTClient" library references objects declared by the
WiFi.hheader in the "esp32" boards platform's bundled "WiFi" library.Previously, the "EspMQTTClient" library relied on its
#includedirective for theWebServer.hheader of the "WiFiServer" library providing an#includedirective for theWiFi.hheader:https://github.com/espressif/arduino-esp32/blob/2.0.17/libraries/WebServer/src/WebServer.h#L29
This fragile code was broken by changes (espressif/arduino-esp32@f2026f1) made in the version of the "WiFiServer" library bundled with the 3.0.0 release of the "esp32" boards platform:
causing the library to no longer compile for ESP32-based boards:
The bug is solved by adding an
#includedirective for theWiFi.hheader the "EspMQTTClient" library depends on.Fixes #142
Fixes #140
Originally reported at https://forum.arduino.cc/t/broken-dependencies/1266624