WiFiManager icon indicating copy to clipboard operation
WiFiManager copied to clipboard

Strange errors

Open sds5111 opened this issue 8 months ago • 1 comments

Can someone please tell me why the following code will not work? It is an issue with c++, not WiFiManager itself, but I can't find an answer anywhere.

1#include <Arduino.h> 2#include <FS.h> //this needs to be first, or it all crashes and burns... 3#include <WiFiManager.h> 4void setup() 5{ 6WiFiManager wifimanager; 7WiFiManager wm; 8WiFiManager.resetSettings(); //reset settings 9if (!WiFiManager.autoConnect("AutoConnectAP", "password")) 10} Line 8 which has a red squiglly line under the "," after WiFiManager. If I place the cursor over it,, the error is "expected an identifier" Line 9 which has a red squiglly line under WiFiManager. If I place the cursor over it,, the error is "type name is not allowed",

This code used to work, now it doesn't. I don't know what I'm doing wrong, but would greatly appreciate some help.

sds5111 avatar Apr 09 '25 00:04 sds5111

The code has at least five problems:

  1. It defines two instances of the class WiFiManager in lines 6 & 7. This is almost certainly not what you want.
  2. The instances of WiFiManager are defined inside setup() which means they will cease to exist when setup() returns.
  3. It uses a type name in line 8 where a variable name is expected (presumably it should be either wm or wifimanager).
  4. Same as above in line 9.
  5. There is no statement after the "if" in line 9, not even a semi-colon.

As you said, this is all about C++ and not about WiFiManager, so you might be better off finding an appropriate forum.

timr49 avatar Apr 17 '25 02:04 timr49