OpenWRT wireless

configure wifi

uci set wireless.radio0.disabled=0
uci set wireless.radio0.channel=5
uci set wireless.@wifi-iface[0].encryption=psk2
uci set wireless.@wifi-iface[0].ssid=$(uci get wireless.radio0.macaddr | tr -d ":" | tr "a-z" "A-Z")
uci set wireless.@wifi-iface[0].key="pass1234"
 
# enable mac filter
uci set wireless.@wifi-iface[0].macfilter=allow
#broken#uci set wireless.@wifi-iface[0].maclist="00:a1:a2:a3:a4:a5 00:b1:b2:b3:b4:b5"
 
# commit changes
uci commit wireless
wifi
 
 
 
# remove all mac addresses
uci del wireless.@wifi-iface[0].maclist
 
# add read allowed mac addresses
for MAC in $(cat /etc/config/wireless-allow | cut -d" " -f1); do
    uci add_list wireless.@wifi-iface[0].maclist="${MAC}"
done
 
# configure wifi
uci commit wireless
wifi

Links
http://wiki.openwrt.org/doc/uci/wireless

#
# timed enable / disable Wifi
#
/etc/init.d/cron enable
 
cat <<EOF>> /etc/crontabs/root
# wifi on (monday to saturday)
30 8 * * 1-6 uci set wireless.radio0.disabled=0; uci commit wireless; wifi
 
# wifi off week (monday - friday)
30 18 * * 1-5 uci set wireless.radio0.disabled=1; uci commit wireless; wifi
 
# wifi off weekend (saturday)                                               
30 13 * * 6 uci set wireless.radio0.disabled=1; uci commit wireless; wifi
EOF
 
/etc/init.d/cron restart
 
 
# Links
https://blog.pinterjann.is/?p=109
 
 
#
# OLD
#
 
 
# install wifi
### opkg update
### opkg install kmod-ath9k wpad-mini
 
# start wifi
wifi
wifi detect
 
<strong>/etc/config/wireless</strong>
uci set wireless.@wifi-iface[0].country=US
uci set wireless.@wifi-iface[0].txpower=27
 
config wifi-device  radio0
        ...
        option country  US
        option txpower  27
 
 
cp /etc/config/wireless /etc/config/wireless.org
sed -i 's|option disabled 1|option disabled 0|g' /etc/config/wireless
sed -i 's|option encryption none|option encryption psk2|g' /etc/config/wireless
 
 
sed -i '/psk2/a\        option key terceS\' /etc/config/wireless
 
# broken ?
sed -i '0,/OpenWrt$/s//wlan1/' /etc/config/wireless
 
 
 
 
sed -i 's|option disabled 1|option disabled 0|g' /etc/config/wireless
sed -i 's|option encryption none|option encryption psk2|g' /etc/config/wireless
echo '        option key terceS00' >> /etc/config/wireless
 
sed -i "s|option 'country' 'DE'|option 'country' 'US'|g" /etc/config/wireless
sed -i "s|option 'txpower' '20'|option 'txpower' '27'|g" /etc/config/wireless
 
 
 
 
 
 
 
config wifi-device  radio0
        option type     mac80211
        option channel  5
        option macaddr  00:25:86:d2:83:44
        option hwmode   11ng
        option htmode   HT20
        list ht_capab   SHORT-GI-40
        list ht_capab   DSSS_CCK-40
        option disabled 0                 
 
config wifi-iface
        option device   radio0
        option network  lan   
        option mode     ap 
        option ssid     OpenWRT
        option 'encryption' 'psk2'
        option 'key' 'terceS'