Error with WIFI.HPP when compiling Painless_Mesh code

Hi,
I am using Windows 11 with Arduino IDE 2.3.2:

I am in need of help with a Mesh Network issue. This is the response I get when I compile:
Painless_Mesh\src/arduino/wifi.hpp:49:14: error: 'class WiFiClass' has no member named 'setAutoConnect'; did you mean 'setAutoReconnect'?
49 | WiFi.setAutoConnect(false)); // Disable autoconnect

I changed the code in "wifi.hpp" to 'setAutoReconnect' but the nodes don't connect. So hopefully someone can point me in the right direction.

Thanks in advance,

This is the error message I get when I compile Examples->Painless Mesh->Basic
The error code comes from wifi.hpp in Painless_Mesh

\Documents\Arduino\basic_Mesh\basic_Mesh.ino:8:
c:\Users\XX\OneDrive\Documents\Arduino\libraries\Painless_Mesh\src/arduino/wifi.hpp: In member function 'void painlessmesh::wifi::Mesh::init(TSTRING, TSTRING, uint16_t, wifi_mode_t, uint8_t, uint8_t, uint8_t)':
c:\Users\XX\OneDrive\Documents\Arduino\libraries\Painless_Mesh\src/arduino/wifi.hpp:49:10: error: 'class WiFiClass' has no member named 'setAutoConnect'; did you mean 'setAutoReconnect'?
49 | WiFi.setAutoConnect(false)); // Disable autoconnect
| ^~~~~~~~~~~~~~
| setAutoReconnect

 * @param ssid The name of your mesh.  All nodes share same AP ssid. They are
   * distinguished by BSSID.
   * @param password Wifi password to your mesh.
   * @param port the TCP port that you want the mesh server to run on. Defaults
   * to 5555 if not specified.
   * @param connectMode Switch between WIFI_AP, WIFI_STA and WIFI_AP_STA
   * (default) mode
   */
  void init(TSTRING ssid, TSTRING password, uint16_t port = 5555,
            WiFiMode_t connectMode = WIFI_AP_STA, uint8_t channel = 1,
            uint8_t hidden = 0, uint8_t maxconn = MAX_CONN) {
    using namespace logger;
    // Init random generator seed to generate delay variance
    randomSeed(millis());

    // Shut Wifi down and start with a blank slage
    if (WiFi.status() != WL_DISCONNECTED) WiFi.disconnect();

    Log(STARTUP, "init(): %d\n",
        WiFi.setAutoConnect(false));  // Disable autoconnect
    WiFi.persistent(false);

    // start configuration
    if (!WiFi.mode(connectMode)) {
      Log(GENERAL, "WiFi.mode() false");
    }

    _meshSSID = ssid;
    _meshPassword = password;
    _meshChannel = channel;
    _meshHidden = hidden;
    _meshMaxConn = maxconn;

I have the same problem after updates.

1 Like

The setAutoConnect function is deprecated. Use the connect parameter in the WiFi.begin() method instead.

I have the same problem, but I am not using the WiFi library at all—only painlessMesh. In the setup, I am using mesh.init() with the parameters of my access point, which is also the mesh. Until today, everything worked for me, but I made updates that Arduino ide recommended, and it messed up the compilatin process

The Mesh using a WiFi, the WiFi is a part of your ESP board package

I have the same issue with the painlessMesh example code. Tried changing setAutoConnect to setAutoReconnect in the wifi.hpp file and it doesn't seem to be connecting :frowning:

see the post #5

I have done as follows:

Change line 48 to 50 in arduino/wifi.hpp to remove the setAutoConnect:

    Log(STARTUP, "init(): %d\n");
        // WiFi.setAutoConnect(false));  // Disable autoconnect
    WiFi.persistent(false);

Change line 140 in painlessMeshSTA.cpp to:

WiFi.begin(ap.ssid.c_str(), password.c_str(), mesh->_meshChannel, ap.bssid, false);

The code compiles but my two nodes still don't communicate with each other when using the example startHere code. I'm unsure if that's related to this problem specifically but I thought I'd share incase this helps anyone else

Hello, have you found a solution that works?
Indeed, with your modifications, the compilation is OK, but the messages do not seem to be received...

Thank you in advance for your information.

Hi, I have a work-around to the problem.

You'll need to install a lower version of board manager esp32 by espressif. I installed version 2.0.17.

Also, you will need to install a lower version of the library ArduinoJson by Benoit Blanchon. I installed version 6.21.5.

Once you've done that, reinstall the Painless Mesh library to undo any changes you made to the source code.

After that, it should work. Obviously going back to lower versions isn't ideal, but it works.

Take care.

3 Likes

This worked great. Thanks heaps luckymatt!

Hi, I have a sketch that was compiling fine, then all of sudden started throwing the

painlessMesh error error: 'class WiFiClass' has no member named 'setAutoConnect'; did you mean 'setAutoReconnect'?
   49 |         WiFi.setAutoConnect(false));  // Disable autoconnect

I have another sketch for the same board that works fine, the only difference is it doesn't include the painlessMesh library, so that pretty well narrows it down. Both are using the official Arduino JSON library.

Any hot tips appreciated!

Arduino IDE v2.3.3
Board: Heltec WiFi LoRa 32(V3) v3.0.2
#include "painlessMesh.h" //v1.5.0
#include <Arduino_JSON.h> //v0.2.0

As mentioned, the sketch that compiles only includes the Arduino_JSON library without painlessMesh. I will post this on the Heltec forum as well and let you know if someone there has any ideas.

Regrards,
Carl

Luca on the painlessMesh forum instructed me to install the develop version from the painlessMesh GIT. The Arduino IDE Library Manager now indicates v1.5.3 and compiles without issue.