confd: drop wifi-scanner in favor of wpa_supplicant autoscan

The trick to starting the scanner mode is to have a dummy network that
cannot associate with anything.

Fixes #1193

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-01-26 19:54:59 +01:00
parent ff197d9b10
commit c0fd39f069
3 changed files with 23 additions and 24 deletions
@@ -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] <pid/wpa_supplicant:%i> /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
@@ -1,16 +0,0 @@
#!/bin/sh
if [ $# -ne 1 ]; then
echo "usage: $0 <ifname>"
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
+21 -4
View File
@@ -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: