. /lib/functions.sh

handle_interface() {
  local config="${1}"
  config_get ifname "${config}" ifname
  config_get mode ${config} mode

  [ "$mode" != "sta" ] && continue

  echo "Get wpa_cli status"
  wpa_cli -i "${ifname}" status

  echo "Get scan results"
  wpa_cli -i "${ifname}" scan_res

  echo "Get current networks"
  wpa_cli -i "${ifname}" list_n

  echo "Get supplicant file"
  cat /var/run/wpa_supplicant-"${ifname}".conf
}

config_load wireless
config_foreach handle_interface wifi-iface
config_foreach handle_interface wifi-mld
