wifi-connect icon indicating copy to clipboard operation
wifi-connect copied to clipboard

Add a refresh networks button

Open sradevski opened this issue 3 years ago • 17 comments

@majorz Is this all that is needed? As far as I could tell /network refetches the networks, unless there is some caching in place that I missed.

Screen Shot 2020-10-01 at 10 20 57

Fixes: #225 Change-type: minor Signed-off-by: Stevche Radevski [email protected]

sradevski avatar Oct 01 '20 08:10 sradevski

Fantastic, just what is needed!

From a UI perspective, perhaps makes more sense to have the refresh button clearly associated with the SSID box, alongside or above-right? And maybe 'refresh' should be something like 'rescan'?

maggie44 avatar Oct 12 '20 09:10 maggie44

@maggie0002 I agree with you on both points, but there are some (intentional) limitations on how we render forms, so adding the button next to the SSID box is not easily achievable without hacking around it. I've updated the text to say "Rescan" though, that's much better.

sradevski avatar Oct 15 '20 09:10 sradevski

Looks great, I think the 'rescan' text provides the clarity that was needed by itself. 👍

maggie44 avatar Oct 15 '20 10:10 maggie44

Thanks @sradevski this is going to be great! Went ahead and merged these changes into the current 4.4.4 release and tested this out today, and I'm not sure it's working properly just yet. I conducted the test by:

  1. starting wifi-connect
  2. viewing the list of found networks in the captive portal (as well as the initial Access Points: array in the logs)
  3. starting up my phone's personal hotspot in an attempt to add a network to the available networks.
  4. pressing the rescan button

In the logs (while connected to our device over a serial connection), each time I press the rescan button in the captive portal, I am seeing the message:

User connected to the captive portal

Any reason that wouldn't work with this test or setup? My initial suspicion is that fetchNetworks may need to also refresh the schema availableNetworks in order for the form to change? I also would have expected that the log would return a list of refreshed Access Points: when that rescan button is pressed, but perhaps there's another reason that's not the case?

Additionally, if there is a potential state change of the Refresh component where we could temporarily display "Rescanning..." either in the button or in the SSID form placeholder, I think that would also help signal to the user that it's working. (happy to help with this as well once this is merged in)

Thanks again for starting to implement this, it's going to be really helpful for the user experience!

gregmihalko avatar Oct 30 '20 17:10 gregmihalko

@gregmihalko Thanks for the thorough test and explanation. Honestly, I just went ahead and implemented the UI changes while I had some free time, and I was hoping @majorz can have a look at what needs to be done on the backend part as I have very little working knowledge of Rust. Once he has the time to check it out he can do the necessary changes, and we can get this merged. Once that's done, it's trivial to improve the UX, which is why I wanted to keep the changes here to the minimum.

sradevski avatar Nov 02 '20 08:11 sradevski

@majorz let me know if there's anything else I might be able to test or try to implement further.

gregmihalko avatar Nov 06 '20 18:11 gregmihalko

This line won't be necessary if the refresh button is implemented:

https://github.com/balena-io/wifi-connect/blob/56f61632f60fd1977112d7fa080fa0268f858e3e/ui/src/components/Notifications.tsx#L29

maggie44 avatar Dec 03 '20 01:12 maggie44

any updates when this PR could be merged?

immiz avatar Mar 30 '21 16:03 immiz

any updates when this PR could be merged?

I too am keeping a close eye on this one, would be great to see it implemented.

That said, when I think about it I realise that it is perhaps not this pull request that I am looking for, but a fix to the reason I need the pull request. On occasion when I load the device all the available networks in the area are not listed properly. Subsequently, I came to want a refresh networks button. Ideally though, the issue of the networks not all being listed would be resolved first and foremost. The circumstances where I would boot the device, then move closer to a network and want to refresh the list is very rare, and a hard reboot there not a major issue. The refresh network button then was only really to resolve a bug for me.

I'm going to have a look at implement this fix: https://github.com/balena-os/wifi-connect/issues/327#issuecomment-577794377

I also hope that that fix is implemented into Wi-Fi connect first and foremost, to reduce the need for a refresh button in the first place.

maggie44 avatar Mar 30 '21 22:03 maggie44

any updates when this PR could be merged?

I too am keeping a close eye on this one, would be great to see it implemented.

That said, when I think about it I realise that it is perhaps not this pull request that I am looking for, but a fix to the reason I need the pull request. On occasion when I load the device all the available networks in the area are not listed properly. Subsequently, I came to want a refresh networks button. Ideally though, the issue of the networks not all being listed would be resolved first and foremost. The circumstances where I would boot the device, then move closer to a network and want to refresh the list is very rare, and a hard reboot there not a major issue. The refresh network button then was only really to resolve a bug for me.

I'm going to have a look at implement this fix: #327 (comment)

I also hope that that fix is implemented into Wi-Fi connect first and foremost, to reduce the need for a refresh button in the first place.

this makes sense - thanks for the update @maggie0002

immiz avatar Mar 31 '21 12:03 immiz

[dtischler] This pull request has attached support thread https://jel.ly.fish/fe776c67-e05f-405d-bcab-0dea56552275

jellyfish-bot avatar Apr 20 '21 00:04 jellyfish-bot

The problem with the PR is that scanning is not allowed by NetworkManager while the WiFi device is in AP mode. I am not sure what the proper solution for this would be, but it definitely needs a much deeper investigation.

majorz avatar Apr 20 '21 13:04 majorz

@majorz would disabling the AP mode, rescanning and starting AP again if needed, solve the issue?

iamsolankiamit avatar May 18 '21 18:05 iamsolankiamit

@majorz would disabling the AP mode, rescanning and starting AP again if needed, solve the issue?

I think the issue would be that the user would be connected via the access point. So you would lose connection to the user interface and the wifi hotspot, would need to reconnect again and refresh the page. May be better than having to restart the whole device, but also not ideal.

maggie44 avatar Jun 11 '21 21:06 maggie44

@maggie0002 i think a refresh option with a warning is better than restarting the device. I presume that switching between WiFi mode would be faster than restarting the device. This also helps people who might get confused as to why their WiFi is not being shown, even after moving the device closer in range/ restating the router etc. not being aware that the WiFi-connections are only scanned once.

iamsolankiamit avatar Sep 03 '21 06:09 iamsolankiamit

@maggie0002 i think a refresh option with a warning is better than restarting the device. I presume that switching between WiFi mode would be faster than restarting the device. This also helps people who might get confused as to why their WiFi is not being shown, even after moving the device closer in range/ restating the router etc. not being aware that the WiFi-connections are only scanned once.

I think so too.

According to this thread (https://forums.balena.io/t/wifi-connect-community-maintainers/331507) @majorz is working on updating some of the dependencies of Wi-Fi connect which with any luck will open up some other options and maybe resolve some issues. I imagine it will be hard to know what they may be until the updates are done but we are eagerly awaiting to see.

maggie44 avatar Sep 03 '21 23:09 maggie44

Quick update on some experiences with refreshing network points. I have been using the IW package (seem to be getting more success with that than nmcli): "iw dev wlan0 scan". Seems like on some devices you can refresh the networks list while the access point is live (tested on Raspberry Pi 4), and on other devices you cannot (tested on Orange Pi Zero LTS). When the refresh fails because the AP is up on the Orange Pi it returns an non-zero exit code.

I ended up implementing an IW call on the page load and if the exit code return non-zero then disable the refresh networks button and prompt the user to restart the device, and if it returns 0 then allow the refresh network button (I'm not using this interface though so haven't added a commit).

maggie44 avatar Sep 28 '21 22:09 maggie44