-
Notifications
You must be signed in to change notification settings - Fork 146
Add missing WiFi.h #include directive #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix works on ESP32S2, Thanks
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 theWebServer.h
header of the "WiFiServer" library providing an#include
directive for theWiFi.h
header: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
#include
directive for theWiFi.h
header the "EspMQTTClient" library depends on.Fixes #142
Fixes #140
Originally reported at https://forum.arduino.cc/t/broken-dependencies/1266624