Strange errors
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.
The code has at least five problems:
- It defines two instances of the class WiFiManager in lines 6 & 7. This is almost certainly not what you want.
- The instances of WiFiManager are defined inside setup() which means they will cease to exist when setup() returns.
- It uses a type name in line 8 where a variable name is expected (presumably it should be either
wmorwifimanager). - Same as above in line 9.
- 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.