From 39f35c0beec935a894821b239247cde3b79d7b4a Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Mon, 3 Mar 2014 10:42:32 +0100 Subject: Fix rfkill unblocking through rf_enable After 755c8d5, rf_enable did not know the rfkill path anymore. Observed by: Tom --- src/lib/rfkill | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/lib/rfkill b/src/lib/rfkill index 3f841f3..05c1382 100644 --- a/src/lib/rfkill +++ b/src/lib/rfkill @@ -40,34 +40,44 @@ rf_status() { fi } +## Set the soft blocking status of an rfkill device +# $1: blocking status +# $2: interface name +# $3: rfkill name +rf_set() { + local block=$1 path + shift + path=$(rf_get_path "$@") || return 1 + + report_debug "${FUNCNAME[1]}: echo '$block' > '$path/soft'" + echo "$block" > "$path/soft" + timeout_wait 1 '(( $(< "$path/soft") == block ))' +} + +## Block transmission through a wireless device +# $1: interface name +# $2: rfkill name +rf_disable() { + rf_set 1 "$@" +} + ## Unblock transmission through a wireless device # $1: interface name # $2: rfkill name rf_enable() { - case $(rf_status "$@") in + local status + status=$(rf_status "$@") || return 1 + + case $status in hard) report_error "Transmission is hard-blocked on interface '$interface'" return 1 ;; soft) - report_debug "$FUNCNAME: echo 0 > '$path/soft'" - echo 0 > "$path/soft" - timeout_wait 1 '(( ! $(< "$path/soft") ))' + rf_set 0 "$@" ;; esac } -## Block transmission through a wireless device -# $1: interface name -# $2: rfkill name -rf_disable() { - local path - path=$(rf_get_path "$@") || return 1 - - report_debug "$FUNCNAME: echo 1 > '$path/soft'" - echo 1 > "$path/soft" - timeout_wait 1 '(( $(< "$path/soft") ))' -} - # vim: ft=sh ts=4 et sw=4: -- cgit v1.2.3-24-g4f1b