Skip to content
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

Some network changes ( missing push event at IP change, Active scan, connect best signal AP ) #17

Merged

Conversation

KipK
Copy link

@KipK KipK commented Feb 22, 2023

Some fixes & improvement:

missing push event at ip change
set wifi scan to active ( solve strange bug )
force wifi to conenct to AP with best signal, fixes OpenEVSE#385

@jeremypoulter
Copy link
Owner

If this is needed you also need to renew the DHCP, some routers expose the hostname via 'normal' DNS, so probably need to restart the whole network stack

@KipK
Copy link
Author

KipK commented Feb 22, 2023

I got this issue during wizard if user set the hostname after setting the wifi network, then at the end of wizard it redirects to the new hostname but mDNS hasn't been updated on the network.
I use hostname ( not optimal it doesn't work on my android phone ) for now, I never receive the new IP while in AP+STA mode, as it fails to connect until AP mode is OFF.
I'lm afraid reloading the whole network stack would disconnect user from AP, wouldn't ?

@KipK
Copy link
Author

KipK commented Feb 23, 2023

This also add missing event_send ip & connection status in wifiOnStationModeGotIP

However most of the time I don't receive it, I'm kicked out of the AP when saving the new WIFI/pass

@KipK
Copy link
Author

KipK commented Feb 23, 2023

added _dnsServer restart too

scan all channels before connecting to AP ( needed for above )
@KipK KipK changed the title restart mDNS when hostname has changed Some network changes ( mDns restart, missing push event at IP change, Active scan, connect best signal AP ) Feb 25, 2023
@jeremypoulter
Copy link
Owner

Thanks @KipK, it is not the DNS server on the ESP that needs restarting, that is only used in AP mode. It is that the ESP needs to renew its IP settings from the router, the host name is contained in the DHCP message and this is then used by some routers to in the router's DNS, eg I can use openevse-xxxx.lan no resolve the OpenEVSE IP, much faster, works on more devices and more reliable than mDNS.

IMHO I think it may just be a case of restarting the networking (both wired and wireless), unless there is a handy method to just enew the IP address.

@jeremypoulter
Copy link
Owner

force wifi to conenct to AP with best signal

How did you do this?

@jeremypoulter
Copy link
Owner

Nevermind, found it.... If I had known it was that simple would have made that change ages ago....

@KipK
Copy link
Author

KipK commented Feb 25, 2023

Nevermind, found it.... If I had known it was that simple would have made that change ages ago....

found that while debugging the wifi issue , was worth trying :)

@KipK
Copy link
Author

KipK commented Feb 25, 2023

what would be the best way to restart this without restartint the AP mode ?

@jeremypoulter
Copy link
Owner

If you are in AP mode, just restarting the mDNS is sufficient. When connected to a proper network (either via WiFi or Wired) that is when you would need to restart the network.

That being said the cases when you would be in AP mode and change the hostname will be slim I would have thought...

@KipK
Copy link
Author

KipK commented Feb 25, 2023

That being said the cases when you would be in AP mode and change the hostname will be slim I would have thought...

on the wizard in AP mode, the Hostname can be set.
I'll add a condition for AP mode only thx.

@KipK
Copy link
Author

KipK commented Feb 25, 2023

this should be good like this.

src/net_manager.cpp Outdated Show resolved Hide resolved
@KipK
Copy link
Author

KipK commented Feb 25, 2023

I've removed the hostanme change triggering dns restart and co.
Dunno how to do it properly for now, i get this out of this PR.

@KipK KipK changed the title Some network changes ( mDns restart, missing push event at IP change, Active scan, connect best signal AP ) Some network changes ( missing push event at IP change, Active scan, connect best signal AP ) Feb 25, 2023
@jeremypoulter
Copy link
Owner

Yeah, maybe a good idea. I can have a look, I think I also need to look at changing WiFi credentials as well

@KipK
Copy link
Author

KipK commented Feb 25, 2023

for captive portal missing in AP+STA, it nows works ok.

src/web_server.cpp Outdated Show resolved Hide resolved
@jeremypoulter jeremypoulter merged commit 7968d38 into jeremypoulter:wifi_connection-issue Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants