Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wifischedule: Add ignore_stations parameter. #2

Merged
merged 1 commit into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=wifischedule
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_RELEASE:=3
PKG_LICENSE:=PRPL

PKG_MAINTAINER:=Nils Koenig <openwrt@newk.it>
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ The button "Determine Modules Automatically" tries to make a best guess determin
When un-/loading the modules, there is a certain number of retries (`module_load`) performed.

The option "Force disabling wifi even if stations associated" does what it says - when activated it simply shuts down WiFi.
When unchecked, its checked every `recheck_interval` minutes if there are still stations associated. Once the stations disconnect, WiFi is disabled.
When unchecked, its checked every `recheck_interval` minutes if there are still stations associated. Once the stations disconnect, WiFi is disabled. To ignore associated stations add their MAC to `ignore_stations`.

Please note, that the parameters `module_load` and `recheck_interval` are only accessible through uci.
Please note, that the parameters `module_load`, `recheck_interval` and `ignore_stations` are only accessible through uci.

## UCI Configuration `wifi_schedule`
UCI configuration file: `/etc/config/wifi_schedule`:
Expand All @@ -47,6 +47,7 @@ config global
option enabled '0'
option recheck_interval '10'
option modules_retries '10'
# option ignore_stations 'AA:AA:AA:AA:AA:AA BB:BB:BB:BB:BB:BB'

config entry 'Businesshours'
option enabled '0'
Expand Down
1 change: 1 addition & 0 deletions net/etc/config/wifi_schedule
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ config global
option enabled '0'
option recheck_interval '10'
option modules_retries '10'
# option ignore_stations 'AA:AA:AA:AA:AA:AA BB:BB:BB:BB:BB:BB'

config entry 'Businesshours'
option enabled '0'
Expand Down
15 changes: 10 additions & 5 deletions net/usr/bin/wifi_schedule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,21 @@ soft_disable_wifi()
return 1
fi

local ignore_stations=$(_get_uci_value_raw ${GLOBAL}.ignore_stations)
[ -n "${ignore_stations}" ] && _log "Ignoring station(s) ${ignore_stations}"

# check if no stations are associated
local _if
for _if in $(_get_wireless_interfaces)
do
output=$(${iwinfo} ${_if} assoclist)
if [[ "$output" != "No station connected" ]]
then
local stations=$(${iwinfo} ${_if} assoclist | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}')
if [ -n "${ignore_stations}" ]; then
stations=$(echo "${stations}" | grep -vwi -E "${ignore_stations// /|}")
fi

if [ -n "${stations}" ]; then
_disable_wifi=0
local stations=$(echo ${output}| grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | tr '\n' ' ')
_log "Station(s) ${stations}associated on ${_if}"
_log "Station(s) $(echo ${stations}) associated on ${_if}"
fi
done

Expand Down