khoih-prog / ESP_WiFiManager

This is an ESP32 / ESP8266 WiFi Connection Manager with fallback web configuration portal. Use this library for configuring ESP32 (including ESP32-S2 and ESP32-C3), ESP8266 modules' WiFi, etc. Credentials at runtime. You can also specify static DNS servers, personalized HostName, fixed or random AP WiFi channel. With examples supporting ArduinoJson
MIT License
371 stars 97 forks source link

Document no-password config portal setup #47

Closed bit4man closed 3 years ago

bit4man commented 3 years ago

First this is a huge improvement over the old WifiManager project. As I start learning all the new and improved features, I have one "why do it this way" request. I like WiFiManager features because it makes creating an IoT device for consumers easy. They power it up, and I can on a small note tell them how to connect to the initial portal (using a static AP name and IP address). From there, it's a simple configuration page and once done, "it just works". You don't even need the note as scanning for WiFi SSIDs with a high signal standing right at the unit should be pretty easy with the smallest of WiFi knowledge. Once you're connected, security is enabled and there's no longer an open SSID for the world to connect to.

My ESP8266s and ESP32 do not have a very long range. I don't fear people standing on the road by the house to be able to pick up the signal. Nor would they know AP or credentials, or credentials for internal services to enter for the internal configuration. It's a very limited and temporary portal.

Another way to handle this is using a phone app which has the password for the AP hard-coded. This is just as bad - it's easy to extract that from the binaries anyway - and would very soon be posted online anyway. So a brief insecure portal seems both easy and secure enough when we're talking about the initial setup.

But it looks like no password or null passwords are no longer allowed for the portal? If they are allowed, an example would be nice.

Again, this looks like something I needed months ago. Really looking forward to using the library for my small form-factor ESP8266ex and perhaps on ESP32s too.

khoih-prog commented 3 years ago

Thanks so much for your encouraging words, which are the rare treat for library writers like us.

I'm so sorry for so-late reply, as I've been so busy recently with so may things to do.

The no or null PWD for Comfig Portal AP is done easily by just declaring the password as NULL in the sketch. For example in ConfigOnDoubleReset example, change from

// SSID and PW for Config Portal
String ssid = "ESP_" + String(ESP_getChipId(), HEX);
const char* password = "your_password";

to

// SSID and PW for Config Portal
String ssid = "ESP_" + String(ESP_getChipId(), HEX);
const char* password = "";

You will get some warnings, but still OK to access the Config Portal. The ConfigPortal AP will be shown as not secured when you access it. It's not advisable to use like this, but it's totally up to you and your use-case so long as you're aware of its risks.

Starting ConfigOnDoubleReset with DoubleResetDetect using LittleFS on ESP8266_NODEMCU
ESP_WiFiManager Version ESP_WiFiManager v1.4.1
ESP_DoubleResetDetector Version ESP_DoubleResetDetector v1.1.1
[WM] RFC925 Hostname = ConfigOnDoubleReset
[WM] setAPStaticIPConfig
[WM] Set CORS Header to :  Your Access-Control-Allow-Origin
Stored: SSID = HueNet1, Pass = 12345678
[WM] * Add SSID =  HueNet1 , PW =  12345678
Got stored Credentials. Timeout 120s for Config Portal
LittleFS Flag read = 0xD0D01234
doubleResetDetected
Saving config file...
Saving config file OK
Open Config Portal without Timeout: Double Reset Detected
Starting configuration portal.
[WM] WiFi.waitForConnectResult Done
[WM] SET AP
[WM] Configuring AP SSID = ESP_702FF3
[WM] Invalid AccessPoint password. Ignoring     <====== This NULL password warning
[WM] AP PWD = 
[WM] Custom AP IP/GW/Subnet =  192.168.100.1 192.168.100.1 255.255.255.0
[WM] AP IP address = 192.168.100.1
[WM] HTTP server started
[WM] ESP_WiFiManager::startConfigPortal : Enter loop