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

AIO_Username field always empty in example configonDRD_FS_MQTT_ptr #62

Closed joko2020 closed 3 years ago

joko2020 commented 3 years ago

Describe the bug

Try Using Example= ConfigonDRD_FS_MQTT_ptr , captive portal running well , but the AIO_USERNAME always empty even though i already fill it , At the beginning of the captive portal or using the DRD method

Steps to Reproduce

  1. edit & set default Value for Adafruit IO MQTT // Default configuration values for Adafruit IO MQTT // This actually works
  2. add chipID as Client ID in mqtt = new Adafruit_MQTT_Client(client, custom_AIO_SERVER, atoi(custom_AIO_SERVERPORT),CID, custom_AIO_USERNAME, custom_AIO_KEY);
  3. Adjust SSID & PASSWORD with myown
  4. Erase Flash using esptool.py --chip esp32 --port com19 erase_flash

Expected behavior

I really hope that all the FIELDs for MQTT connections can be filled in. Because my personal MQTT server is configured not to accept Subscribe or Publish if the USERNAME is not filled. When board reset or DRD trigger and new value add .. MQTT connection still able to do.

Actual behavior

Connection to the MQTT server can occur even without a username on the first connection but without being able to subscribe. but if the board is reset and a new connection request occurs, the connection will fail.

Debug and AT-command log (if applicable)

`[WM] WiFi.waitForConnectResult Done [WM] SET AP [WM] Configuring AP SSID = private [WM] AP PWD =private [WM] AP Channel = 8 [WM] AP IP address = 192.168.4.1 [WM] HTTP server started [WM] startConfigPortal : Enter loop [WM] captivePortal: hostHeader = connectivitycheck.gstatic.com [WM] Request redirected to captive portal : 192.168.4.1 [WM] captivePortal: hostHeader = captive.apple.com [WM] Request redirected to captive portal : 192.168.4.1 [WM] captivePortal: hostHeader = clients3.google.com [WM] Request redirected to captive portal : 192.168.4.1 [WM] captivePortal: hostHeader = clients3.google.com [WM] Request redirected to captive portal : 192.168.4.1 [WM] captivePortal: hostHeader = connectivitycheck.gstatic.com [WM] Request redirected to captive portal : 192.168.4.1 [WM] Handle root [WM] captivePortal: hostHeader = 192.168.4.1 [WM] captivePortal: hostHeader = 192.168.4.1 [WM] captivePortal: hostHeader = connectivitycheck.gstatic.com [WM] Request redirected to captive portal : 192.168.4.1 [WM] captivePortal: hostHeader = connectivitycheck.gstatic.com [WM] Request redirected to captive portal : 192.168.4.1 [WM] Handle WiFi [WM] Scanning Network [WM] scanWifiNetworks: Done, Scanned Networks n = 1 [WM] Sorting [WM] Removing Dup [WM] Index = 0 [WM] SSID = ekti452019 [WM] RSSI = -61 [WM] Static IP = 0.0.0.0 [WM] Sent config page [WM] captivePortal: hostHeader = connectivitycheck.gstatic.com [WM] Request redirected to captive portal : 192.168.4.1 [WM] captivePortal: hostHeader = connectivitycheck.gstatic.com [WM] Request redirected to captive portal : 192.168.4.1 [WM] captivePortal: hostHeader = connectivitycheck.gstatic.com [WM] Request redirected to captive portal : 192.168.4.1 Saving Config File { "AIO_SERVER_Label": "private", "AIO_SERVERPORT_Label": "private", "AIO_USERNAME_Label": "", "AIO_KEY_Label": "private" } Config File successfully saved

Creating new WiFi client object : OK Creating new MQTT object : OK AIO_SERVER = private, AIO_SERVERPORT = private AIO_USERNAME = , AIO_KEY = private Creating new MQTT_Pub_Topic, Temperature = /Temperature Creating new Temperature object : OK Temperature MQTT_Pub_Topic = /Temperature [WM] freeing allocated params! Stop doubleResetDetecting Saving config file... Saving config file OK Local Date/Time: Thu Jun 24 19:39:42 2021 Connecting to MQTT (3 attempts)... MQTT connection successful! T`

Screenshots

N/A

Information

Please ensure to specify the following:

Thanks

khoih-prog commented 3 years ago

Thanks for using the library.

I've just retested and verified and everything is OK with the example. In order to change the AIO Credentials, you have to enter the Config Portal to modify the AIO Credentials there, you can't just modify in the example's sketch only.

Starting ConfigOnDRD_FS_MQTT_Ptr using LittleFS on ESP32_DEV
ESP_WiFiManager v1.7.2
ESP_DoubleResetDetector v1.1.1
{"AIO_SERVER_Label":"io.adafruit.com","AIO_SERVERPORT_Label":"1883","AIO_USERNAME_Label":"user_name_new","AIO_KEY_Label":"aio_key"}
Config File successfully parsed
LittleFS Flag read = 0xD0D01234
doubleResetDetected
Saving config file...
Saving config file OK
Open Config Portal without Timeout: Double Reset Detected

Config Portal requested.
[WM] RFC925 Hostname = ConfigOnDRDFS-MQTT
Opening Configuration Portal. No timeout : DRD or No stored Credentials..
[WM] Adding parameter AIO_SERVER_Label
[WM] Adding parameter AIO_SERVERPORT_Label
[WM] Adding parameter AIO_USERNAME_Label
[WM] Adding parameter AIO_KEY_Label
[WM] setSTAStaticIPConfig
[WM] Set CORS Header to :  Your Access-Control-Allow-Origin
Starting configuration portal @ 192.168.4.1, SSID = ESP_9ABF498, PWD = MyESP_9ABF498
[WM] WiFi.waitForConnectResult Done
[WM] SET AP
[WM] Configuring AP SSID = ESP_9ABF498
[WM] AP PWD = MyESP_9ABF498
[WM] AP Channel = 11
[WM] AP IP address = 192.168.4.1
[WM] HTTP server started
[WM] startConfigPortal : Enter loop
[WM] Connecting to new AP
[WM] Previous settings invalidated
[WM] Custom STA IP/GW/Subnet
[WM] DNS1 and DNS2 set
[WM] setWifiStaticIP IP = 192.168.2.232
[WM] Connect to new WiFi using new IP parameters
[WM] Connected after waiting (s) : 6.00
[WM] Local ip = 192.168.2.232
[WM] Connection result:  WL_CONNECTED
Connected...yeey :)
Local IP: 192.168.2.232
[WM] * Add SSID =  HueNet1 , PW =  password
[WM] * Add SSID =  HueNet2 , PW =  password
[WM] Saving current TZ_Name = America/New_York , TZ =  EST5EDT,M3.2.0,M11.1.0
[WM] getSTAStaticIPConfig
[WM] SaveWiFiCfgFile 
[WM] stationIP = 192.168.2.232 , gatewayIP = 192.168.2.1
[WM] netMask = 255.255.255.0
[WM] dns1IP = 192.168.2.1 , dns2IP = 8.8.8.8
[WM] OK
Saving Config File
{
  "AIO_SERVER_Label": "io.adafruit.com",
  "AIO_SERVERPORT_Label": "1883",
  "AIO_USERNAME_Label": "user_name",         <======== changing from user_name to user_name_new, then back to user_name OK
  "AIO_KEY_Label": "aio_key"
}
Config File successfully saved

Creating new WiFi client object : OK
Creating new MQTT object : OK
AIO_SERVER = io.adafruit.com, AIO_SERVERPORT = 1883
AIO_USERNAME = user_name, AIO_KEY = aio_key
Creating new MQTT_Pub_Topic,  Temperature = user_name/feeds/Temperature
Creating new Temperature object : OK
Temperature MQTT_Pub_Topic = user_name/feeds/Temperature
[WM] freeing allocated params!
Local Date/Time: Thu Jun 24 10:26:29 2021
Connecting to MQTT (3 attempts)...
MQTT connection successful!

Because this is not the issue of the library, I'll close the issue and won't spend time on it.