Open ddweber456 opened 4 years ago
Make sure your esp is still in sta mode after wm exits. Not sure what else it could be
What am I missing. At the very end of the degug it looks to me like it's in STA mode.
14:57:28.217 -> bcn 0
14:57:28.217 -> del if1
14:57:28.217 -> pm open,type:2 0
14:57:28.217 -> mode : sta(98:f4:ab:da:62:f0)
14:57:28.217 -> *WM: [2] wifi status: WL_CONNECTED
14:57:28.217 -> *WM: [2] wifi mode: STA
14:57:28.217 -> *WM: [1] config portal exiting
14:57:28.217 -> WiFi Connected. yepee!!
Where do I put the WiFi.mode(WIFI_STA); if not at the beginning of setup() ?
Yeah that should be good,
where in this log is the problem? How are you checking that your connectivity is working etc
I really appreciate your help and time on this, Thanks.
OK I'm back on 0.15.0, I had this problem from the very start, so it's not anything new with the alpha release. I added a couple of WiFi.printDiag(Serial); commands after the autoConnect to check the status. Is there something else I should do?
Here are the serial print logs from the autoConnect and then from the hard reset.
autoConnect:
22:37:29.519 -> *WM: AP IP address:
22:37:29.519 -> *WM: 192.168.4.1
22:37:29.519 -> *WM: HTTP server started
22:38:32.462 -> *WM: Request redirected to captive portal
22:38:35.367 -> *WM: Request redirected to captive portal
22:38:35.367 -> *WM: Handle root
22:38:36.446 -> *WM: Request redirected to captive portal
22:38:36.493 -> *WM: Request redirected to captive portal
22:38:40.571 -> *WM: Scan done
22:38:40.571 -> *WM: DUP AP: Roosevelt
22:38:40.571 -> *WM: NachoLINK
22:38:40.571 -> *WM: -43
22:38:40.571 -> *WM: iConnect
22:38:40.571 -> *WM: -63
22:38:40.571 -> *WM: iConnect Guest
22:38:40.571 -> *WM: -63
22:38:40.571 -> *WM: DIRECT-02MFC-L8610CDW_BRbb03
22:38:40.571 -> *WM: -64
22:38:40.571 -> *WM: Dattebayo
22:38:40.571 -> *WM: -64
22:38:40.571 -> *WM: HOME-CAD2
22:38:40.618 -> *WM: -76
22:38:40.849 -> *WM: Sent config page
22:38:41.926 -> *WM: Request redirected to captive portal
22:38:41.973 -> *WM: Request redirected to captive portal
22:38:45.026 -> *WM: Request redirected to captive portal
22:39:20.201 -> *WM: WiFi save
22:39:20.201 -> *WM: Parameter
22:39:20.201 -> *WM:
22:39:20.201 -> *WM:
22:39:20.201 -> *WM: Parameter
22:39:20.201 -> *WM:
22:39:20.201 -> *WM:
22:39:20.201 -> *WM: Parameter
22:39:20.201 -> *WM: smart_home_phrase
22:39:20.201 -> *WM: Silver
22:39:20.201 -> *WM: Parameter
22:39:20.201 -> *WM:
22:39:20.201 -> *WM:
22:39:20.201 -> *WM: Parameter
22:39:20.201 -> *WM: double_press
22:39:20.201 -> *WM: Gold
22:39:20.201 -> *WM: Parameter
22:39:20.201 -> *WM:
22:39:20.201 -> *WM:
22:39:20.201 -> *WM: Sent wifi save page
22:39:21.186 -> *WM: Connecting to new AP
22:39:21.186 -> *WM: Connecting as wifi client...
22:39:21.233 -> *WM: Status:
22:39:21.233 -> *WM: 0
22:39:21.279 -> *WM: [ERROR] WiFi.begin res:
22:39:21.279 -> *WM: 6
22:39:36.979 -> *WM: Connection result:
22:39:36.979 -> *WM: 4
22:39:38.995 -> *WM: Failed to connect.
22:39:38.995 -> *WM: Request redirected to captive portal
22:39:38.995 -> *WM: Request redirected to captive portal
22:39:48.801 -> *WM: Request redirected to captive portal
22:39:48.801 -> *WM: Request redirected to captive portal
22:40:02.969 -> *WM: WiFi save
22:40:02.969 -> *WM: Parameter
22:40:02.969 -> *WM:
22:40:02.969 -> *WM:
22:40:02.969 -> *WM: Parameter
22:40:02.969 -> *WM:
22:40:02.969 -> *WM:
22:40:02.969 -> *WM: Parameter
22:40:02.969 -> *WM: smart_home_phrase
22:40:02.969 -> *WM: Silver
22:40:02.969 -> *WM: Parameter
22:40:02.969 -> *WM:
22:40:02.969 -> *WM:
22:40:02.969 -> *WM: Parameter
22:40:02.969 -> *WM: double_press
22:40:02.969 -> *WM: Gold
22:40:02.969 -> *WM: Parameter
22:40:02.969 -> *WM:
22:40:02.969 -> *WM:
22:40:02.969 -> *WM: Sent wifi save page
22:40:03.989 -> *WM: Connecting to new AP
22:40:03.989 -> *WM: Connecting as wifi client...
22:40:03.989 -> *WM: Status:
22:40:03.989 -> *WM: 6
22:40:04.036 -> *WM: [ERROR] WiFi.begin res:
22:40:04.036 -> *WM: 6
22:40:10.181 -> *WM: Connection result:
22:40:10.181 -> *WM: 3
22:40:10.272 -> Should save config
22:40:10.272 ->
22:40:10.272 -> After autoConnect and before Fauxmo.createServer
22:40:10.272 ->
22:40:10.272 -> Mode: STA
22:40:10.272 -> PHY mode: N
22:40:10.272 -> Channel: 9
22:40:10.272 -> AP id: 0
22:40:10.272 -> Status: 5
22:40:10.272 -> Auto connect: 1
22:40:10.272 -> SSID (9): NachoLINK
22:40:10.272 -> Passphrase (12): xxxxx
22:40:10.272 -> BSSID set: 0
22:40:10.272 ->
22:40:10.272 ->
22:40:10.272 -> After Fauxmo.createServer
22:40:10.272 ->
22:40:10.272 -> Mode: STA
22:40:10.272 -> PHY mode: N
22:40:10.272 -> Channel: 9
22:40:10.272 -> AP id: 0
22:40:10.272 -> Status: 5
22:40:10.272 -> Auto connect: 1
22:40:10.272 -> SSID (9): NachoLINK
22:40:10.272 -> Passphrase (12): xxxxx
22:40:10.272 -> BSSID set: 0
22:40:10.272 ->
22:40:10.272 -> WiFi Connected. yepee!!
22:40:10.272 ->
22:40:10.272 -> Saving JSON Config
22:40:10.272 -> Here is the SAVED JSON File:
22:40:10.272 -> {"smart_home_phrase":"Silver ","double_press":"Gold "}
22:40:10.319 -> Smart Home Phrases:
22:40:10.319 -> Silver Gold
And here is the serial log with the hard reset:
22:47:58.913 -> Mounted LittleFS file system
22:47:58.913 -> Reading config file
22:47:58.913 -> Opened config file
22:47:58.913 -> {"smart_home_phrase":"Silver ","double_press":"Gold "}
22:47:58.913 -> parsed json
22:47:58.913 -> *WM: Adding parameter
22:47:58.913 -> *WM:
22:47:58.913 -> *WM: Adding parameter
22:47:58.913 -> *WM:
22:47:58.913 -> *WM: Adding parameter
22:47:58.959 -> *WM: smart_home_phrase
22:47:58.959 -> *WM: Adding parameter
22:47:58.959 -> *WM:
22:47:58.959 -> *WM: Adding parameter
22:47:58.959 -> *WM: double_press
22:47:58.959 -> *WM: Adding parameter
22:47:58.959 -> *WM:
22:47:58.959 -> *WM:
22:47:58.959 -> *WM: AutoConnect
22:47:58.959 -> *WM: Connecting as wifi client...
22:47:58.959 -> *WM: Status:
22:47:58.959 -> *WM: 6
22:47:58.959 -> *WM: Using last saved values, should be faster
22:48:03.413 -> *WM: Connection result:
22:48:03.413 -> *WM: 3
22:48:03.413 -> *WM: IP Address:
22:48:03.413 -> *WM: 192.168.0.119
22:48:03.413 ->
22:48:03.413 -> After autoConnect and before Fauxmo.createServer
22:48:03.413 ->
22:48:03.413 -> Mode: STA
22:48:03.413 -> PHY mode: N
22:48:03.413 -> Channel: 9
22:48:03.413 -> AP id: 0
22:48:03.413 -> Status: 5
22:48:03.413 -> Auto connect: 1
22:48:03.413 -> SSID (9): NachoLINK
22:48:03.413 -> Passphrase (12): xxxxx
22:48:03.413 -> BSSID set: 0
22:48:03.413 ->
22:48:03.413 ->
22:48:03.413 -> After Fauxmo.createServer
22:48:03.413 ->
22:48:03.413 -> Mode: STA
22:48:03.413 -> PHY mode: N
22:48:03.413 -> Channel: 9
22:48:03.413 -> AP id: 0
22:48:03.413 -> Status: 5
22:48:03.413 -> Auto connect: 1
22:48:03.413 -> SSID (9): NachoLINK
22:48:03.413 -> Passphrase (12): xxxxx
22:48:03.413 ->
22:48:03.413 -> WiFi Connected. yepee!!
22:48:03.413 ->
22:48:03.413 -> Smart Home Phrases:
22:48:03.413 -> Silver Gold
In the autoConnect serial print log I'm getting " 22:40:04.036 -> *WM: [ERROR] WiFi.begin res: " Let me know what you think.
Thats odd, the first log says it connected, this one says it doesnt.
I wonder why, definitely a connection issue, which esp lib version are you using ?
ESP 2.5.0 ESP8266 board mgr 2.7.4
Not a fritzbox router is it ?
Tp-Link. Actually just install a new Tp-Link. Haven't done anything with ESP yet.
Try a full flash erase yet?
I have. The reset is needed on all the devices. About 30 or 40 8266 so far. It's become standard operating procedure to do a hard reset, but I know that's not right.
It must have something to do with fauxmo, maybe mdns interferes with the udp ?
Have you tried a basic ping example ? Or some other network check ? is it pingable ?
Which fauxmo library are you using ?
I'm using the current 3.1.1
Let me see if I can Ping it after the autoConnect.....
No I can not ping it, before or after the reset
I mean which one, there seems to be a bunch xoseperez/fauxmoESP ?
I'm sorry. Support for the fauxmoESP and been transferred to Paul, @pvint https://github.com/vintlabs/fauxmoESP
ok they should fix that in platform io
I will see if I can install it
Agreed. Maybe someone with the expertise could assist @pvint in making the platform io happen.
Agreed. Maybe someone with the expertise could assist @pvint in making the platform io happen.
I hadn't thought of the lib in platformio, thanks for mentioning it. I took a look and I see how it works now. I'll try to get it and Arduino updated later today.
I think the old one would have to be removed first to avoid confusion, unless the name changes. i assume you are maintaining a fork, and the source is abandoned?
Xose, the original author, has handed it over to me to maintain. I've updated the library.json file on the original repo, which I believe should update it.
I've looked at this a bit more and took some packet captures when it fails and when it works. For some reason the ESP8266 is sending a RST, ACK packet back to the Amazon echo . Everything seems the same up until that packet, and in the "good" scenario, it sens a SYN ACK and everything continues.
I have a bit more info here: https://github.com/vintlabs/fauxmoESP/issues/123#issuecomment-731847618
Just curious if anyone has had a chance to investigate the findings that Paul, FauxmoESP, was able to see with the packet capture. I'm still having the issue of the required hard reset and would really like to get that resolved if possible. Let me know if there is anything I can do to help.
you would have to eliminate WM and see if it can be reproduced with just esp examples, and then reach out to espressif, does sound like sdk issue.
What happens if you just do a esp.reset() ? or wdt reset ?
It seems like I would have to do the esp.reset() as part of the autoConnect? Unless I can conditionally esp.reset() coming out of autoConnect. Ideas?
You only have this issue when saving new wifi ? You can use the saveconfig callback to flag a reset maybe?
The only time I have seen reset issues with wifi saving is when the flash is corrupt and a full erase via esptool/arduino fixes it
Yes, the only time I see the issue is when saving new WiFi credentials.
Several months back, I did see the comments regarding the corrupt flash, I was hopeful, but that didn't help.
It hardly ever does anything but maybe try adding a WiFi.reconnect() after ?
The WiFi.reconnect() did not do the trick. I think we maybe lookin in the wrong place.
Shawn, I'm not the most experienced coder, but it look like to me that autoConnect() call to connectWiFi() when saving credentials it does not return to the calling function cleanly. Otherwise, I think I should be seeing the *WM: IP Address ... in the first serial print log below:
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.0.102
WiFi Connected. yepee!!
Serial print log when saving wifi credentials via autoConnect():
17:31:33.854 -> *WM: Sent wifi save page
17:31:34.839 -> *WM: Connecting to new AP
17:31:34.839 -> *WM: Connecting as wifi client...
17:31:34.839 -> *WM: Status:
17:31:34.884 -> *WM: 0
17:31:34.931 -> *WM: [ERROR] WiFi.begin res:
17:31:34.931 -> *WM: 6
17:31:39.284 -> *WM: Connection result:
17:31:39.284 -> *WM: 3
17:31:39.331 -> Should save config
17:31:42.271 -> WiFi Connected. yepee!!
17:31:42.271 ->
17:31:42.271 -> Saving JSON Config
17:31:42.271 -> Here is the SAVED JSON File:
17:31:42.271 -> {"smart_home_phrase":"Black","double_press":"White "}
17:31:42.271 -> Smart Home Phrases:
17:31:42.271 -> Black White
Serial print log after doing the hard reset:
17:33:51.497 -> *WM: AutoConnect
17:33:51.543 -> *WM: Connecting as wifi client...
17:33:51.543 -> *WM: Status:
17:33:51.543 -> *WM: 6
17:33:51.543 -> *WM: Using last saved values, should be faster
17:33:55.091 -> *WM: Connection result:
17:33:55.091 -> *WM: 3
17:33:55.091 -> *WM: IP Address:
17:33:55.091 -> *WM: 192.168.0.102
17:33:58.695 -> WiFi Connected. yepee!!
17:33:58.695 ->
17:33:58.695 -> Smart Home Phrases:
17:33:58.695 -> Black White
Yes your saves are failing, your code is checking the return true? Not sure what is failing or if begin is failing, not sure why, have you tried a different esp a different lib version?
I have only tried this on the 8266. But on many 8266s. All have the same issue and want a hard reset before they will communicate with Alexa. After that they are very, very stable. Multiple power re-boots, power outages, wifi going away for period of time. No Issues.
What lib version would you recommend?
I don't know if it makes a difference but FauxmoESP runs as a UDP.
I just modified the example AutoConnect sketch from the 0.15.0 WiFiManager lib. Modified it just enough to blink the on-board LED and I'm getting the same serial print log as before:
Serial print log from autoConnect() saving wifi credentials:
21:50:11.333 -> *WM: WiFi save
21:50:11.333 -> *WM: Sent wifi save page
21:50:12.359 -> *WM: Connecting to new AP
21:50:12.359 -> *WM: Connecting as wifi client...
21:50:12.359 -> *WM: Status:
21:50:12.359 -> *WM: 0
21:50:12.405 -> *WM: [ERROR] WiFi.begin res:
21:50:12.405 -> *WM: 6
21:50:16.704 -> *WM: Connection result:
21:50:16.704 -> *WM: 3
21:50:16.752 -> connected...yeey :)
21:50:16.752 -> IP Address: 192.168.0.102
21:50:16.752 -> *WM: freeing allocated params!
After ESP8266 hard reset:
21:55:19.368 -> *WM: AutoConnect
21:55:19.368 -> *WM: Connecting as wifi client...
21:55:19.368 -> *WM: Status:
21:55:19.368 -> *WM: 6
21:55:19.368 -> *WM: Using last saved values, should be faster
21:55:22.958 -> *WM: Connection result:
21:55:22.958 -> *WM: 3
21:55:22.958 -> *WM: IP Address:
21:55:22.958 -> *WM: 192.168.0.102
21:55:23.004 -> connected...yeey :)
21:55:23.004 -> IP Address: 192.168.0.102
21:55:23.004 -> *WM: freeing allocated params!
Here is the code:
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
unsigned long lastLEDMillis = 0; // will store the last time the LED was updated
unsigned long interval = 3000; // place holder, will be updated in the LED blink
int ledState=HIGH;
int blinkTime = 1; // blink on duration
void setup() {
// put your setup code here, to run once:
// LEDs and PINs used for logic
pinMode(2, OUTPUT); // on-board LED
digitalWrite(2, LOW); // LOW = LED on
Serial.begin(115200);
IPAddress(255,255,255,0));
wifiManager.autoConnect("AutoConnectAP", "gaslights");
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
// put your main code here, to run repeatedly:
unsigned long currentMillis = millis();
// >>> Simple code to flash the on-board LED every 3 seconds, no delay
if (currentMillis - lastLEDMillis > interval) {
lastLEDMillis = currentMillis;
ledState = !ledState;
// if the LED is off, turn it on and vice-versa:
if (ledState == HIGH)
{
digitalWrite(2, LOW);
interval = blinkTime;
}
else
{
digitalWrite(2, HIGH);
interval = 3000;
}
}
}
The {ERROR} *WM : WiFi.begin res: that we're seeing in the first Serial print log is un-expected, I'm starting to think this is NOT the problem. If everyone else is able to use the 8266 as a STA right after the autoConnect() without doing a hard reset, then something else is going on. I'm going to share this with @pvint - vintlabs/FauxmoESP. See if he can shed his intelligence on the subject. Thanks Paul for your help.
David
Ok so I am going to say use the dev/alpha version, there was some fixes for this kind of stuff added and better logging. I cannot say for sure but there was some clean connect stuff I worked out to fix odd issues like this
There is a clean connect, let me find it
These are new might only be in the github version, development branch
// set wifi connect retries // wm.setConnectRetries(2);
// This is sometimes necessary, it is still unknown when and why this is needed but it may solve some race condition or bug in esp SDK/lib // wm.setCleanConnect(true); // disconnect before connect, clean connect
Some other things you can try, set proper country set channel, shrug
// set country // setting wifi country seems to improve OSX soft ap connectivity, // may help others as well, default is CN which has different channels wm.setCountry("US");
Finally, make sure you are using a good power supply!
I just tested with the development branch, both with and without .setCleanConnect(true)
and the issue remains. I'll try to look a bit more later on.
@pvint were you able to do any additional testing? Could this be because FauxmoESP is using UDP?
Even though we are seeing an ERROR from WM: connectWiFi() returning to the calling WM: autoConnect() (see comment of 5 days ago https://github.com/tzapu/WiFiManager/issues/1142#issuecomment-733396464 ) it appears most everyone else is able use the ESP as a STA without doing a hard reset. It not just my code that is producing this WM: ERROR, it is also happening in the example sketches WM 0.15.0. https://github.com/tzapu/WiFiManager/issues/1142#issuecomment-733456344
It could be router specific. I will test this on some of my boards when I have time.
If you have a bin? I can try that too. Otherwise I will use latest stable of all and wm /dev latest
It could be router specific. I will test this on some of my boards when I have time.
I've taken the unit to 8 to 10 client locations, there's no difference. I've always had to do a hard reset.
Any progress in finding a fix? Is there anything I can help you with? david
@tablatronix Hey, just checking in to see if you had made any progress. I hope the silence is not an indication of bad news.
Sorry I will try to test here tomorrow
It would be interesting to try to reproduce the issue in a simpler manner - get rid of all the fauxmo stuff and just insert a sendUDPPacket(data, dst, port)
sort of thing and see if we can narrow it down. (I made up that function name...)
I'll try to have a look in the morning (in 12 hours or so)
I am not sure what to expect here, it seems to work, not sure how I test it, alexa needs wemo skill ? My homeassistant isnt finding a new device but I do have these [FAUXMO] Responding to M-SEARCH request
and
[FAUXMO] Handling devicetype request
[FAUXMO] Client #0 disconnected
[FAUXMO] Client #0 connected
[FAUXMO] Handling list request
[FAUXMO] Sending device info for "yellow lamp", uniqueID = "1a6083b4d603"
[FAUXMO] Sending device info for "green lamp", uniqueID = "ea4c8bf1b2e4"
fauxmo runs a webserver, I would suspect that before anything, make sure wm is destroyed before starting the fauxmo one
That sounds good...sooo how do you stop a server?
I have seen issues with running another webserver even though wm stops it Maybe since we are using a shared pointer for the webserver now, or maybe stop() is not enough, I have not really had a look at it
bool WiFiManager::shutdownConfigPortal(){
if(webPortalActive) return false;
//DNS handler
dnsServer->processNextRequest();
//HTTP handler
server->handleClient();
// @todo what is the proper way to shutdown and free the server up
server->stop();
server.reset();
dnsServer->stop(); // free heap ?
dnsServer.reset();
What if I did all the WiFiManager stuff, including the WiFiManager MW; in it own function, called from Setup(). When focus is lost, that should destroy WM and the Server. Right?
It should, if you take it out of global scope.
The ESP SDK is very persistent in keeping the server, once established, connected and running. Moving the creation of the server out of global scope in its own separate function did not work. Server remained regardless of scope.
@tablatronix Could it be that somehow WM is effecting Port 80, blocking FauxmoESP from being able to use 80 to receive UDP messages?
Yes, that is what I think, if you use an alt port to test it will be evident. I meant to say that the other day, using 2 web servers on the same port seems to be impossible, not sure how to properly destruct the webserver
// set port of webserver, 80
void setHttpPort(uint16_t port);
Can you be a little more specific how and where to implement is for testing? thanks
Question: I thought this issue had been address or did I just miss something?
Hardware
WiFimanager Branch/Release:
Esp8266/Esp32:
Hardware: ESP-12e, esp01, esp25
ESP Core Version: 2.4.0, staging
[ ] staging (master/dev)
LittleFS at version 0.1.0 ArduinoJson at version 5.13.5 ESP8266WiFi at version 1.0 WiFiManager at version 2.0.3-alpha ESP8266WebServer at version 1.0 DNSServer at version 1.1.1 fauxmoESP at version 3.1.1 ESPAsyncTCP at version 1.2.2
Description
After successful autoConnect and the saving of the parameters, I have to do a hard reset before the ESP is in the correct configuration Alexa can discover devices with fauxmoESP. I have WiFi.mode(WIFI_STA); in the setup().
Settings in IDE
Module: Wemos D1, v1.4 Higher Bandwidth
Additional libraries:
Sketch
Debug Messages