2 # sets up a wifi interface for meshing
3 # Arguments: $1 = network interface
9 ##### wifi-device #####
11 # Get the type before we delete the wifi-device
13 config_get type $net type
15 # Delete old wifi-device for $net
18 if [ "$1" == "$net" -a "$cleanup" == 1 ]; then
19 section_cleanup wireless.${net}
21 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
22 section_rename wireless $1 $net
26 config_foreach handle_wifidevice wifi-device
28 # create new wifi-device for $net
29 uci set wireless.${net}=wifi-device
31 # get and set wifi-device defaults
32 set_defaults "wifi_device_" wireless.${net}
34 channel="$(uci -q get meshwizard.netconfig.$net\_channel)"
35 vap="$(uci -q get meshwizard.netconfig.$net\_vap)"
37 if [ -z "$channel" -o "$channel" == "default" ]; then
38 channel=$wifi_device_channel
42 set wireless.${net}.type="$type"
43 set wireless.${net}.channel="$channel"
46 uci_commitverbose "Setup wifi device for $netrenamed" wireless
50 # Delete old wifi-iface for $net
52 config_get device "$1" device
53 if [ "$device" == "$net" ]; then
54 if [ "$cleanup" == 1 ]; then
55 section_cleanup wireless.${net}_iface
57 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
58 section_rename wireless $1 ${net}_iface
63 config_foreach handle_interface wifi-iface
65 # create new wifi-device for $net
66 uci set wireless.$net\_iface=wifi-iface
68 # create new wifi-iface for $net from defaults
69 set_defaults "wifi_iface_" wireless.$net\_iface
72 bssid="$($dir/helpers/gen_bssid.sh $channel $community)"
74 if [ "$profile_ssid_scheme" == "addchannel" ]; then
75 ssid="$ssid - ch$channel"
79 set wireless.$net\_iface.device="${net}"
80 set wireless.$net\_iface.network="$netrenamed"
81 set wireless.$net\_iface.ssid="$ssid"
82 set wireless.$net\_iface.bssid="$bssid"
85 uci_commitverbose "Setup wifi interface for $netrenamed" wireless
88 ip4addr="$(uci get meshwizard.netconfig.$net\_ip4addr)"
89 if [ "$type" == "atheros" -a "$vap" == 1 ]; then
91 set wireless.$net\_iface_dhcp="wifi-iface"
92 set wireless.$net\_iface_dhcp.device="$net"
93 set wireless.$net\_iface_dhcp.mode="ap"
94 set wireless.$net\_iface_dhcp.encryption="none"
95 set wireless.$net\_iface_dhcp.network="${netrenamed}dhcp"
96 set wireless.$net\_iface_dhcp.ssid="FF-AP-$ip4addr"
98 uci_commitverbose "Setup VAP interface for $netrenamed" wireless