diff options
author | Jouke Witteveen <j.witteveen@gmail.com> | 2012-06-12 22:44:10 +0200 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2012-06-12 22:44:10 +0200 |
commit | 2e15ac5e029f1ef43dc38b33eb0f2dc9b8f5a4ba (patch) | |
tree | e7db2aeaa653bc26e690198e34363cd1f8b4f3c7 /src/8021x | |
parent | eeb82be0eb59a680309858fe9a42261451bc2897 (diff) | |
download | netctl-2e15ac5e029f1ef43dc38b33eb0f2dc9b8f5a4ba.tar.gz netctl-2e15ac5e029f1ef43dc38b33eb0f2dc9b8f5a4ba.tar.xz |
Wait for wifi scan results (FS#29946)
We hardcode a timeout of 10 seconds. In case of a timeout, we use whatever results we have. It is unlikely that a timeout is hit.
For fast scans, we are done half a second earlier than before.
Diffstat (limited to 'src/8021x')
-rw-r--r-- | src/8021x | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -130,7 +130,7 @@ list_networks() { } wpa_supplicant_scan_info() { - local INTERFACE="$1" fields="$2" essids spawned_wpa=0 + local INTERFACE="$1" fields="$2" spawned_wpa=0 essids scan_wait # temp file used, as keeping ESSID's with spaces in their name in arrays # is hard, obscure and kinda nasty. This is simpler and clearer. @@ -138,12 +138,18 @@ wpa_supplicant_scan_info() { essids=$(mktemp --tmpdir essid.XXXXXXXX) if [[ "$(wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" ping 2> /dev/null)" != "PONG" ]]; then - start_wpa "$INTERFACE" "" nl80211,wext || return 1 + start_wpa "$INTERFACE" "" "${WPA_DRIVER:-nl80211,wext}" || return 1 spawned_wpa=1 fi wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" scan &> /dev/null - sleep 2.5 + # Wait at least 2 seconds for scan results + sleep 2 + # Sometimes, that is not enough (FS#29946) + for (( scan_wait = 2; scan_wait < 10; scan_wait++ )); do + wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" status | grep -q "wpa_state=SCANNING" || break + sleep 1 + done wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" scan_results | grep -v "^Selected" | grep -v "^bssid" | |