mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-03-14 21:10:11 +01:00
wifimngr: use ruleng for WPS LED handling instead of script
This commit is contained in:
parent
262e346eb4
commit
2f51c4fc69
4 changed files with 86 additions and 49 deletions
|
|
@ -13,8 +13,6 @@ start_service() {
|
|||
# procd_set_param stderr 1 #for debugging only
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
wps-monitor
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
|
|
|
|||
84
wifimngr/files/etc/ruleng/wps.json
Normal file
84
wifimngr/files/etc/ruleng/wps.json
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
{
|
||||
"wps_active": {
|
||||
"if_operator" : "OR",
|
||||
"if" : [
|
||||
{
|
||||
"event": "wifi.ap",
|
||||
"match": {
|
||||
"event":"wps-pbc-active"
|
||||
}
|
||||
},
|
||||
{
|
||||
"event": "wifi.bsta",
|
||||
"match": {
|
||||
"event":"wps-pbc-active"
|
||||
}
|
||||
}
|
||||
],
|
||||
"then" : [
|
||||
{
|
||||
"object": "led.wps",
|
||||
"method":"set",
|
||||
"args" : {
|
||||
"state": "notice"
|
||||
},
|
||||
"timeout": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"wps_success": {
|
||||
"if_operator" : "OR",
|
||||
"if" : [
|
||||
{
|
||||
"event": "wifi.ap",
|
||||
"match": {
|
||||
"event":"wps-reg-success"
|
||||
}
|
||||
},
|
||||
{
|
||||
"event": "wifi.bsta",
|
||||
"match": {
|
||||
"event":"wps-success"
|
||||
}
|
||||
}
|
||||
],
|
||||
"then" : [
|
||||
{
|
||||
"object": "led.wps",
|
||||
"method":"set",
|
||||
"args" : {
|
||||
"state": "ok",
|
||||
"timeout": 30
|
||||
},
|
||||
"timeout": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"wps_timeout": {
|
||||
"if_operator" : "OR",
|
||||
"if" : [
|
||||
{
|
||||
"event": "wifi.ap",
|
||||
"match": {
|
||||
"event":"wps-timeout"
|
||||
}
|
||||
},
|
||||
{
|
||||
"event": "wifi.bsta",
|
||||
"match": {
|
||||
"event":"wps-timeout"
|
||||
}
|
||||
}
|
||||
],
|
||||
"then" : [
|
||||
{
|
||||
"object": "led.wps",
|
||||
"method":"set",
|
||||
"args" : {
|
||||
"state": "off"
|
||||
},
|
||||
"timeout": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
2
wifimngr/files/etc/uci-defaults/ruleng.wps
Normal file
2
wifimngr/files/etc/uci-defaults/ruleng.wps
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
uci -q set ruleng.wps=rule
|
||||
uci -q set ruleng.wps.recipe='/etc/ruleng/wps.json'
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
if [ -f /tmp/wps-monitor.pid ]; then
|
||||
kill -9 $(cat /tmp/wps-monitor.pid) 2>/dev/null
|
||||
rm -f /tmp/wps-monitor.pid
|
||||
fi
|
||||
|
||||
[ "$1" == "stop" ] && exit
|
||||
|
||||
WPSENABLED=0
|
||||
for vif in $(uci show wireless | grep wifi-iface | awk -F[.,=] '{print$2}'); do
|
||||
[ "$(uci -q get wireless.$vif.wps_pushbutton)" == "1" ] && WPSENABLED=1
|
||||
done
|
||||
|
||||
if [ $WPSENABLED -eq 0 ]; then
|
||||
ubus call led.wps set '{"state":"off"}'
|
||||
exit
|
||||
fi
|
||||
|
||||
ubus listen wifi.ap wifi.bsta | \
|
||||
while read wpsevent ; do
|
||||
#echo "wps-monitor got event: $event" >/dev/console
|
||||
json_load "$wpsevent"
|
||||
if json_select wifi.ap >/dev/null; then
|
||||
json_get_var event event
|
||||
if [ "$event" == "wps-pbc-active" ]; then
|
||||
ubus call led.wps set '{"state":"notice"}'
|
||||
elif [ "$event" == "wps-reg-success" ]; then
|
||||
ubus call led.wps set '{"state":"ok","timeout":30}'
|
||||
elif [ "$event" == "wps-timeout" ]; then
|
||||
ubus call led.wps set '{"state":"off"}'
|
||||
fi
|
||||
elif json_select wifi.bsta >/dev/null; then
|
||||
json_get_var event event
|
||||
if [ "$event" == "wps-pbc-active" ]; then
|
||||
ubus call led.wps set '{"state":"notice"}'
|
||||
elif [ "$event" == "wps-success" ]; then
|
||||
ubus call led.wps set '{"state":"ok","timeout":30}'
|
||||
elif [ "$event" == "wps-timeout" ]; then
|
||||
ubus call led.wps set '{"state":"off"}'
|
||||
fi
|
||||
fi
|
||||
done &
|
||||
|
||||
echo $(($!-1)) $! >/tmp/wps-monitor.pid
|
||||
Loading…
Add table
Reference in a new issue