Skip to content
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

esp32 v3.x breaking changes - library doesn't compile for ESP32 boards #140

Open
chrisweather opened this issue Jun 17, 2024 · 4 comments · May be fixed by #138
Open

esp32 v3.x breaking changes - library doesn't compile for ESP32 boards #140

chrisweather opened this issue Jun 17, 2024 · 4 comments · May be fixed by #138
Labels
bug Something isn't working

Comments

@chrisweather
Copy link

Description of the problem

With Espressif esp32 2.0.17 everything works fine.
esp32 3.x includes breaking changes to wifi handling
https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html

When I apply the changes in PR #138 manually this fixes the compiler error.
Didn't check if the library is full functionable.

Added
#include <WiFi.h>
to line 22 in EspMQTTClient.h

Hardware

  • Board type : ESP32
  • Board model : Lolin D32

Logs

Arduino IDE 1.8.19 and 2.x
Espressif esp32 3.01

C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'bool EspMQTTClient::handleWiFi()':
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp:187:5: error: 'WiFi' was not declared in this scope
187 | WiFi.disconnect(true);
| ^~~~
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp:194:27: error: 'WiFi' was not declared in this scope
194 | bool isWifiConnected = (WiFi.status() == WL_CONNECTED);
| ^~~~
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\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:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\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:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'bool EspMQTTClient::handleMQTT()':
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp:325:9: error: 'WiFi' was not declared in this scope
325 | WiFi.disconnect(true);
| ^~~~
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::onWiFiConnectionEstablished()':
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\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:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::onWiFiConnectionLost()':
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp:388:5: error: 'WiFi' was not declared in this scope
388 | WiFi.disconnect(true);
| ^~~~
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::connectToWifi()':
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\libraries\EspMQTTClient\src\EspMQTTClient.cpp:555:3: error: 'WiFi' was not declared in this scope
555 | WiFi.mode(WIFI_STA);
| ^~~~
C:\ProgrammePortable\arduino-1.8.19\portable\sketchbook\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

@chrisweather chrisweather added the bug Something isn't working label Jun 17, 2024
@AdaBill
Copy link

AdaBill commented Jul 4, 2024

Thanks chrisweather, I have been having trouble connecting with my ESP32 with the other libraries, just no response, then I saw this library and tried it and got the same WiFi problem. I should learn to read the Bugs before I spend the time trying to fix something you already fixed. Thanks Again. I also think that there should be an #include "PubSubClient.h" in the header to make sure that tis library is also installed.

@cyijun
Copy link

cyijun commented Jul 8, 2024

Hi, you may try my library with similar interfaces. It works with the latest Arduino core.
https://github.com/cyijun/ESP32MQTTClient

@steros76
Copy link

The solution is on
https://forum.arduino.cc/t/broken-dependencies/1266624/8

In "EspMQTTClient.h" you must add

#include <WiFi.h>

before

#include <WiFiClient.h>

@chrisweather
Copy link
Author

I know, that it can be fixed with this small change. There's also a PR for this fix for this library.
It would be more comfortable to simply install the library without any additional modifications.
Unfortunately this project seems to be orphaned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants