wifimngr: uci-defaults: generate wifi.json

This commit is contained in:
Jakob Olsson 2023-10-26 12:39:34 +02:00
parent 8711c64ff6
commit 5c83a98cb3

View file

@ -0,0 +1,52 @@
#!/bin/sh
[ -f /etc/wifi.json ] && exit 0
. /usr/share/libubox/jshn.sh
is_broadcom() {
[ -e /dev/bcm ] && return 0
return 1
}
is_qualcomm() {
[ -f /proc/device-tree/compatible ] || return
strings /proc/device-tree/compatible | grep -qE '^(qcom,|ipq,)'; return
}
if is_broadcom; then
ifname="wl*"
family="bcmwl nl80211"
group="scan"
else
ifname="wlan*"
family="nl80211"
if is_qualcomm; then
group="scan"
else
group="scan config mlme vendor"
fi
fi
json_init
json_add_array "events"
for fm in $family; do
echo fm=$fm
json_add_object ""
json_add_string "type" "wifi-event"
json_add_string "name" "$fm"
json_add_string "ifname" "$ifname"
json_add_string "family" "$fm"
json_add_array "group"
if [ "$fm" == "bcmwl" ]; then
json_add_string "" "notify"
else
for gr in $group; do
json_add_string "" "$gr"
done
fi
json_select ..
json_select ..
done
json_select ..
json_dump | jq >/etc/wifi.json