-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-work of the network manager #533
Re-work of the network manager #533
Conversation
All network changes are now handled in the main network loop and also added in some state management. For Wired boards we try to connect only on wired for a period of time before bringing up the WiFi. In AP mode, if we have client credentials continuosly try to connect the client. Auto stop the AP after a successful client connection
Evaluate the state on startup to make sure the IP subsystems are initialised. Only restart the WiFi on disconnect if we are not connected via a wired connection. Fixes to the random seed to work on ESP32 (kind of, not really needed)
Hopefully will help with MQTT connections
Does the wifi module switch now to AP + STA when wifi has been configured and previous mode was AP ? |
Going to do some work cleaning up the endpoints based on this and I will work on that area then |
Hi @jeremypoulter I've just done some testing and noticed that when a long press on the front push button is used to force the module to create a WiFi AP captive portal is not active. To clarify: when the push button is pressed and help for about 5s the WiFi AP gets created, but the module remains connected to the existing Wifi network and the Wifi AP does not activate a captive portal when a user connects. |
Will take a look |
I'm testing this now, and making change to UI wizard ( moving to /config endpoint ) Connecting to SSID: WifiNetwrk I think it keep the softAP channel when connecting as STA instead of changing channel. |
Other thing I have here, when scanning for network while in AP mode, It gives one time a result, then scanning again always return empty array. |
@glynhudson I think I have resolved that issue, please can you check again @KipK I think the connection issue you are seeing is expected behaviour. The configured SSID is not found ( I also can not reproduce the AP scanning issue, looks to work for me. |
@jeremypoulter the esp is 3 meters from the AP. signal is strong. It found it at first scan in AP mode then all the other results return the same ( either empty or a network in the lower band channel ). Scan works ok in STA mode. I've tried to debug that yesterday without success. Also tryied using WiFiManager lib on the same dev ESP and had no such problem. |
more info on this, first scan takes few seconds to answer and gives full result. Second scan and all following ones instantaneously ( doesn't seem to scan really ) and always gives the same result thereafter ( can be empty or few networks around the same channel ) |
I have submitted a PR on your branch allowing to restart mDNS at hostname change jeremypoulter#17 |
so has discussed in pv, seems scanning in passive mode solve the scan issue. I now see another problem now since I've moved to passive scan, wonder if I'm alone. When in AP mode, wifi not configured yet, when saving the wifi / pass on /config endpoint, I'm kicked out of the AP, AP seems disabled then and the ESP module don't connect to the WiFi network until I powercycle. edit: If I comment the second scan at the end of the function: Other thing, when esp is in STA+AP and connected correctly to the wifi router, the IP adress from the /status endpoint is still AP one (192.168.4.1) |
Hi @jeremypoulter, I've just tested this PR again and this issue remains the same. When the push button is held for 10s to force the module to create a WiFi AP this WiFi AP does not have a captive portal. When I connect to the AP, my phone just says "no internet' and doest not give a captive portal option to sign in: |
Oh I see, I fixed an issue with the AP not starting at all... |
…n completes Uses the scan complete event so not to block the firmware
…ter/ESP32_WiFi_V4.x into wifi_connection-issue
…net cable connected
scan all channels before connecting to AP ( needed for above )
@glynhudson , beware, 10sec is for factory resetting the esp not just set in ap mode. It's 2 sec for AP only @jeremypoulter , got one little issue left, if I throw AP mode with the button, while already connected to STA ( switchting to AP+STA) the ipaddress in /status takes 192.168.4.1 instead of STA one. |
@KipK I think, that is correct, the user has explicitly changed to AP mode, so they would want to know the IP to then connect to. Technically the ESP has two IPs, maybe we could return both, but I think that can be done separately. |
then other apps/ui/home automation connected to the api will also receive this new ip , but the evse is still connected to the network and works normally. As it's more a process of maintenance, I don't think there's need to override the current ip by the AP one. Not sure there's a real use in redirecting UI to AP ip in this case |
this jeremypoulter@f7b1009 fix @glynhudson captive portal not showing problem |
Some network changes ( missing push event at IP change, Active scan, connect best signal AP )
…ter/ESP32_WiFi_V4.x into wifi_connection-issue
I've submitted you the compile fix, sorry for that. |
fix compile
Thanks, I knew I should have waited for those builds to finish ;-) |
@glynhudson can you test this again? |
Are we good for mergin it ? |
Great, just tested. Working now, thanks a lot 👍 |
This is a rework of the code to manage connecting to the network, WiFi or Wired. This code better manages the state we are in so hopefully there are less issues and is also more agressive at staying connected to the WiFi access point.
Fixes #420, fixes #460