Stop scanning if wpa_supplicant state goes INACTIVE.#13
Conversation
This happens after the first set of results and the first CTRL-EVENT-NETWORK-NOT-FOUND if there are no preferred networks configured in wpa_supplicant - i.e. it considers the scan done and stops. Have implemented to call it on every iteration where nothing else happens because calling getStatus() seems more or less instant, and seems possible that some other versions may choose to go inactive at other times. However, AFAIK if a preferred network is configured in wpa_supplicant then it won't go inactive - will keep scanning instead.
|
The (c.f., https://w1.fi/wpa_supplicant/devel/defs_8h.html#a4aeb27c1e4abd046df3064ea9756f0bc). Given that, I tried moving the status check to the closest related event (i.e., the final one), but it's not really any prettier, so, yeah, probably better this way. diff --git a/wpaclient.lua b/wpaclient.lua
index 5582200..e852d97 100644
--- a/wpaclient.lua
+++ b/wpaclient.lua
@@ -220,8 +220,15 @@ function WpaClient.__index:scanThenGetResults()
-- It may take *multiple* scans, and events may be split across multiple reads...
-- Which is why NetworkManager does another pass of waiting in case our heuristics fail...
elseif ev.msg == "CTRL-EVENT-NETWORK-NOT-FOUND" then
- found_result = false
- expected_scans = expected_scans + 1
+ local status
+ status, err = self:getStatus()
+ if status ~= nil and status.wpa_state ~= "INACTIVE" then
+ -- If there are no enabled networks in the configuration, wpa_supplicant won't rescan,
+ -- and switches to the INACTIVE state.
+ -- c.f., https://w1.fi/wpa_supplicant/devel/defs_8h.html#a4aeb27c1e4abd046df3064ea9756f0bc
+ found_result = false
+ expected_scans = expected_scans + 1
+ end
-- Wait for every started scan to finish
-- NOTE: Because everything is terrible, this event isn't sent on older devices... -_-"(Plus, we miiight want to re-use that check in the future anyway). |
NiLuJe
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @projectgus)
Say, abort early on |
Yeah, I actually started out with it in a similar place but thought it was a little cleaner at the bottom of the loop! I also figured that I didn't know 100% what sequence of events every wpa_supplicant version might produce, so adding the check on every loop means it'll always catch it if it goes INACTIVE regardless of what event(s) come first.
😄 |
|
Thanks! |
This happens after the first set of results and the first CTRL-EVENT-NETWORK-NOT-FOUND if there are no preferred networks configured in wpa_supplicant - i.e. it considers the scan done and stops.
Closes #12.
Have implemented to call it on every iteration where nothing else happens because calling getStatus() seems more or less instant, and seems possible that some other versions may choose to go inactive at other times.
However, AFAIK if a preferred network is configured in wpa_supplicant then it won't go inactive - will keep scanning instead.
On my Kobo Aura the tested behaviour of
scanThenGetResults()is:This change is