Update wifi

This commit is contained in:
骷髅头 2023-05-02 20:56:01 +08:00 committed by GitHub
parent 1b03fe2282
commit cfb27e3575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@
usage() { usage() {
cat <<EOF cat <<EOF
Usage: $0 [config|up|down|reconf|reload|status] Usage: $0 [config|up|down|reconf|reload|status|isup]
enables (default), disables or configures devices not yet configured. enables (default), disables or configures devices not yet configured.
EOF EOF
exit 1 exit 1
@ -17,8 +17,24 @@ ubus_wifi_cmd() {
local dev="$2" local dev="$2"
json_init json_init
[ -n "$2" ] && json_add_string device "$2" [ -n "$dev" ] && json_add_string device "$dev"
ubus call network.wireless "$1" "$(json_dump)" ubus call network.wireless "$cmd" "$(json_dump)"
}
wifi_isup() {
local dev="$1"
json_load "$(ubus_wifi_cmd "status" "$dev")"
json_get_keys devices
for device in $devices; do
json_select "$device"
json_get_var up up
[ $up -eq 0 ] && return 1
json_select ..
done
return 0
} }
find_net_config() {( find_net_config() {(
@ -245,6 +261,7 @@ case "$1" in
detect) wifi_detect_notice ;; detect) wifi_detect_notice ;;
config) wifi_config ;; config) wifi_config ;;
status) ubus_wifi_cmd "status" "$2";; status) ubus_wifi_cmd "status" "$2";;
isup) wifi_isup "$2"; exit $?;;
reload) wifi_reload "$2";; reload) wifi_reload "$2";;
reload_legacy) wifi_reload_legacy "$2";; reload_legacy) wifi_reload_legacy "$2";;
--help|help) usage;; --help|help) usage;;