Hi!
When using madwifi, the txpowerlist and freqlist seem to be uninitialized 
unless a vif is created and ifup'ed.

Example for txpowerlist:

root@OpenWrt:~# iwinfo wifi0 txpowerlist
*  0 dBm (   1 mW)
  10 dBm (  10 mW)
  15 dBm (  31 mW)
  20 dBm ( 100 mW)
  25 dBm ( 316 mW)
  30 dBm (1000 mW)
  35 dBm (3162 mW)
  40 dBm (10000 mW)

root@OpenWrt:~# wlanconfig ath0 create wlandev wifi0 mode sta
root@OpenWrt:~# ifconfig ath0 up
root@OpenWrt:~# wlanconfig ath0 destroy
root@OpenWrt:~# iwinfo wifi0 txpowerlist
*  0 dBm (   1 mW)
   8 dBm (   6 mW)
  10 dBm (  10 mW)
  12 dBm (  15 mW)
  14 dBm (  25 mW)
  16 dBm (  39 mW)
  18 dBm (  63 mW)
  20 dBm ( 100 mW)


To work-around this bug, I created a simple way to initialize the wifi driver 
even if the device is disabled and/or there are no vifs, so they there are sane 
values in the webinterface from the first moment on and the users won't get too 
confused.
I guess the right way[tm] to do this would be fixing madwifi, but we all know 
that won't happen...


Signed-off-by: Daniel Golle <dgo...@allnet.de>

Index: package/base-files/files/etc/init.d/network
===================================================================
--- package/base-files/files/etc/init.d/network (revision 27684)
+++ package/base-files/files/etc/init.d/network (working copy)
@@ -16,6 +16,7 @@
        }
        rm -f /tmp/wireless.tmp
        grep -qs config /etc/config/wireless && {
+               /sbin/wifi prepare
                /sbin/wifi up
        }
 
Index: package/base-files/files/sbin/wifi
===================================================================
--- package/base-files/files/sbin/wifi  (revision 27684)
+++ package/base-files/files/sbin/wifi  (working copy)
@@ -122,6 +122,15 @@
        ); done
 }
 
+wifi_prepare() {
+       for device in ${2:-$DEVICES}; do (
+               config_get iftype "$device" type
+               if eval "type prepare_$iftype" 2>/dev/null >/dev/null; then
+                       eval "prepare_$iftype '$device'"
+               fi
+       ); done
+}
+
 start_net() {(
        local iface="$1"
        local config="$2"
@@ -191,6 +200,7 @@
 case "$1" in
        down) wifi_updown "disable" "$2";;
        detect) wifi_detect "$2";;
+       prepare) wifi_prepare "$2";;
        --help|help) usage;;
        *) wifi_updown "enable" "$2";;
 esac
Index: package/madwifi/files/lib/wifi/madwifi.sh
===================================================================
--- package/madwifi/files/lib/wifi/madwifi.sh   (revision 27684)
+++ package/madwifi/files/lib/wifi/madwifi.sh   (working copy)
@@ -94,6 +94,28 @@
        return 0
 )
 
+prepare_atheros() {
+       local device="$1"
+
+       config_get regdomain "$device" regdomain
+       [ -n "$regdomain" ] && echo "$regdomain" > 
/proc/sys/dev/$device/regdomain
+
+       config_get country "$device" country
+       [ -z "$country" ] && country="0"
+       echo "$country" > /proc/sys/dev/$device/countrycode
+
+       config_get_bool outdoor "$device" outdoor "0"
+       echo "$outdoor" > /proc/sys/dev/$device/outdoor
+
+       ifname=$(wlanconfig "${device}-prepare" create wlandev "$device" 
wlanmode ap)
+       [ $? -ne 0 ] && {
+               echo "prepare_atheros($device): Failed to set up temporary vif" 
>&2
+               continue
+       }
+       ifconfig "$ifname" up
+       wlanconfig "$ifname" destroy
+}
+
 enable_atheros() {
        local device="$1"
 
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to