From ee13ac5774373ba488453fba569f257ae4c3f0ee Mon Sep 17 00:00:00 2001 From: Filip Matusiak Date: Wed, 20 Aug 2025 15:12:51 +0000 Subject: [PATCH] self-diagnostics: update wifi data collection --- .../self-diagnostics/helper/wifi_assoclist.sh | 37 ++++++++++++++----- .../share/self-diagnostics/helper/wifi_sta.sh | 0 .../self-diagnostics/helper/wifi_status.sh | 36 ++++++++++++++++++ .../usr/share/self-diagnostics/spec/wifi.json | 3 +- 4 files changed, 66 insertions(+), 10 deletions(-) mode change 100644 => 100755 self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_sta.sh create mode 100755 self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_status.sh diff --git a/self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_assoclist.sh b/self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_assoclist.sh index 34f54e385..7b4e341dd 100755 --- a/self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_assoclist.sh +++ b/self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_assoclist.sh @@ -1,11 +1,30 @@ -interfaces=$(uci show wireless | grep "ifname=" | awk -F'[.,=]' '{print$2}') -for int in $interfaces; do - mode=$(uci get "wireless.${int}.mode") +. /lib/functions.sh + +handle_interface() { + local config="${1}" + local prefix="${2}" + + config_get ifname "${config}" ifname + config_get mode ${config} mode + if [ "$mode" = "ap" ] ; then - ap_int=$(uci get "wireless.${int}.ifname") - echo "Get assoc list for ${ap_int}" - ubus call "wifi.ap.${ap_int}" assoclist - echo "Get station info for ${ap_int}" - ubus call "wifi.ap.${ap_int}" stations + echo "Get assoc list for ${ifname}" + ubus call "${prefix}.${ifname}" assoclist + echo "Get station info for ${ifname}" + ubus call "${prefix}.${ifname}" stations fi -done +} + +handle_wifi_interface() { + handle_interface "$1" "wifi.ap" +} + +handle_mld_interface() { + handle_interface "$1" "wifi.apmld" +} + +config_load wireless +echo "Get associated stations information for non-MLD interfaces" +config_foreach handle_wifi_interface wifi-iface +echo "Get associated stations information for MLD interfaces" +config_foreach handle_mld_interface wifi-mld diff --git a/self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_sta.sh b/self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_sta.sh old mode 100644 new mode 100755 diff --git a/self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_status.sh b/self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_status.sh new file mode 100755 index 000000000..f124675bd --- /dev/null +++ b/self-diagnostics/files/usr/share/self-diagnostics/helper/wifi_status.sh @@ -0,0 +1,36 @@ +. /lib/functions.sh + +handle_interface() { + local config="${1}" + local prefix="${2}" + + config_get ifname "${config}" ifname + config_get mode ${config} mode + + if [ "$mode" = "ap" ] ; then + echo "Get status for ${ifname}" + ubus call "${prefix}.${ifname}" status + elif [ "$mode" = "sta" ] ; then + echo "Get status for bSTA ${ifname}" + ubus call "wifi.bsta.${ifname}" status + fi +} + +handle_wifi_interface() { + handle_interface "$1" "wifi.ap" +} + +handle_mld_interface() { + handle_interface "$1" "wifi.apmld" +} + +config_load wireless +echo "Get wifi status" +ubus call wifi status + +echo "Get wifi status for ap & bsta interfaces" +config_foreach handle_wifi_interface wifi-iface + +echo "Get wifi status for apmld interfaces" +config_foreach handle_mld_interface wifi-mld + diff --git a/self-diagnostics/files/usr/share/self-diagnostics/spec/wifi.json b/self-diagnostics/files/usr/share/self-diagnostics/spec/wifi.json index 2e4050bd0..0ed90aca8 100644 --- a/self-diagnostics/files/usr/share/self-diagnostics/spec/wifi.json +++ b/self-diagnostics/files/usr/share/self-diagnostics/spec/wifi.json @@ -13,7 +13,8 @@ }, { "description": "WiFi Status", - "cmd": "ubus call wifi status" + "cmd": "sh /usr/share/self-diagnostics/helper/wifi_status.sh", + "timeout": 10 }, { "description": "WiFi Radio Status",