diff --git a/board/common/rootfs/etc/finit.d/available/wifi@.conf b/board/common/rootfs/etc/finit.d/available/wifi@.conf index e530b39c..7f7bfcee 100644 --- a/board/common/rootfs/etc/finit.d/available/wifi@.conf +++ b/board/common/rootfs/etc/finit.d/available/wifi@.conf @@ -1,5 +1,3 @@ service name:wpa_supplicant :%i \ - [2345] wpa_supplicant -s -i %i -c /etc/wpa_supplicant-%i.conf -P/var/run/wpa_supplicant-%i.pid \ - -- Wi-Fi Station @%i - -task name:wifi-scanner :%i [2345] /usr/libexec/infix/wifi-scanner %i -- Start scanning for SSID @%i + [2345] wpa_supplicant -s -i %i -c /etc/wpa_supplicant-%i.conf -P/var/run/wpa_supplicant-%i.pid \ + -- Wi-Fi Station @%i diff --git a/board/common/rootfs/usr/libexec/infix/wifi-scanner b/board/common/rootfs/usr/libexec/infix/wifi-scanner deleted file mode 100755 index b34c698b..00000000 --- a/board/common/rootfs/usr/libexec/infix/wifi-scanner +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -if [ $# -ne 1 ]; then - echo "usage: $0 " - exit 1 -fi -ifname=$1 - -TIMEOUT=300 -status=$(wpa_cli -i $ifname scan) -while [ "$status" != "OK" ]; do - status=$(wpa_cli -i $ifname scan) - TIMEOUT=$((TIMEOUT-1)) - [ $TIMEOUT -eq 0 ] && logger -t wifi-scanner "Failed to start scanning $ifname" && exit 1 - sleep 0.5 -done diff --git a/src/confd/src/if-wifi.c b/src/confd/src/if-wifi.c index d6567d6b..43a1e43c 100644 --- a/src/confd/src/if-wifi.c +++ b/src/confd/src/if-wifi.c @@ -103,6 +103,10 @@ static int wifi_gen_station(struct lyd_node *cif) goto out; } + /* + * Background scanning every 10 seconds while not associated, when we + * have an SSID (below), bgscan assumes this task. + */ fprintf(wpa_supplicant, "ctrl_interface=/run/wpa_supplicant\n" "autoscan=periodic:10\n" @@ -121,14 +125,27 @@ static int wifi_gen_station(struct lyd_node *cif) } fprintf(wpa_supplicant, "network={\n" - "bgscan=\"simple: 30:-45:300\"\n" - "ssid=\"%s\"\n" - "%s\n" + " bgscan=\"simple: 30:-45:300\"\n" + " ssid=\"%s\"\n" + " %s\n" "}\n", ssid, security_str); free(security_str); } else { /* Scan-only mode - no station container configured */ - fprintf(wpa_supplicant, "# Scan-only mode - no network configured\n"); + fprintf(wpa_supplicant, "# Scan-only - need dummy network for state machine\n"); + /* + * This prevents the daemon from actually trying to associate and fail, + * 'bssid' with a reserved/impossible MAC address prevents it from ever + * actually \"finding\" and joining a random open AP + */ + fprintf(wpa_supplicant, + "network={\n" + " ssid=\"\"\n" + " key_mgmt=NONE\n" + " disabled=0\n" + " bssid=00:00:00:00:00:01\n" + " scan_ssid=1\n" + "}\n"); } out: