Project

General

Profile

Wireless autoconf » History » Version 14

Pau Escrich, 06/13/2011 06:27 PM

1 1 Pau Escrich
h1. Wireless autoconf
2 1 Pau Escrich
3 13 Pau Escrich
h2. The UCI configuration
4 10 Pau Escrich
5 8 Pau Escrich
This is the wireless configuration for file: /etc/config/qmp
6 1 Pau Escrich
7 1 Pau Escrich
These are the default parameters sharing all wireless interfaces
8 4 Pau Escrich
<pre>
9 4 Pau Escrich
config 'qmp' 'wireless'
10 3 Pau Escrich
 	option 'driver' 'mac80211'
11 3 Pau Escrich
 	option 'country' 'UZ'
12 1 Pau Escrich
 	option 'bssid' '02:CA:FF:EE:BA:BE'
13 4 Pau Escrich
</pre>
14 3 Pau Escrich
 
15 1 Pau Escrich
driver can be `mac80211` for athXk, and `madwifi` for madwifi
16 2 Pau Escrich
17 2 Pau Escrich
And these are the config parameters for each wifi interface.
18 3 Pau Escrich
<pre>
19 3 Pau Escrich
 config 'wireless'
20 3 Pau Escrich
 	option 'channel' '44'
21 3 Pau Escrich
 	option 'mode' 'adhoc'
22 3 Pau Escrich
 	option 'name' 'qmp'
23 3 Pau Escrich
 	option 'mac' '00:80:48:6b:25:b5'
24 3 Pau Escrich
 
25 3 Pau Escrich
 config 'wireless'
26 3 Pau Escrich
 	option 'channel' '10'
27 3 Pau Escrich
 	option 'mode' 'ap'
28 3 Pau Escrich
 	option 'name' 'qmp.cat-AP'
29 3 Pau Escrich
 	option 'mac' '00:80:48:6b:25:b6'
30 3 Pau Escrich
31 3 Pau Escrich
</pre>
32 5 Pau Escrich
33 13 Pau Escrich
h2. qmp_wireless_config
34 9 Pau Escrich
35 5 Pau Escrich
To apply this configuration to device, you must execute this commands: 
36 5 Pau Escrich
<pre>
37 5 Pau Escrich
. /etc/qmp/qmp_wireless.sh
38 5 Pau Escrich
qmp_configure_wifi
39 5 Pau Escrich
</pre>
40 5 Pau Escrich
This function takes the parameters from UCI and using the templates from: /etc/qmp/templates creates the openwrt wireless config
41 5 Pau Escrich
Templates are named like that: wireless.mac80211.adhoc wireless.madwifi.ap
42 5 Pau Escrich
Separed by dots, second name is the driver to use and third one is the mode. 
43 5 Pau Escrich
44 5 Pau Escrich
These templates looks like this:
45 5 Pau Escrich
46 5 Pau Escrich
<pre>
47 5 Pau Escrich
config wifi-device #QMP_DEVICE
48 5 Pau Escrich
	option type     mac80211
49 5 Pau Escrich
	option macaddr	#QMP_MAC
50 5 Pau Escrich
	option channel  #QMP_CHANNEL
51 5 Pau Escrich
        option diversity 0 # 0:off, 1:on
52 5 Pau Escrich
        option txantenna 0 # 0:auto, 1:main, 2:aux
53 5 Pau Escrich
        option rxantenna 0 # 0:auto, 1:main, 2:aux
54 5 Pau Escrich
	option country	#QMP_COUNTRY
55 5 Pau Escrich
	option outdoor	1
56 5 Pau Escrich
#	option txpower  1 
57 5 Pau Escrich
58 5 Pau Escrich
config wifi-iface
59 5 Pau Escrich
	option device	#QMP_DEVICE
60 5 Pau Escrich
	option mode	adhoc
61 5 Pau Escrich
	option ssid	#QMP_SSID
62 5 Pau Escrich
	option bssid	#QMP_BSSID
63 5 Pau Escrich
	option encryption none
64 5 Pau Escrich
</pre>
65 12 Pau Escrich
As you can see, the special words starting with #QMP will be replaced by UCI parameters. 
66 5 Pau Escrich
So you can play a little with templates. For example, there is a template named: `wireless.mac80211.adhoc-n`
67 9 Pau Escrich
68 9 Pau Escrich
But the function qmp_wireless_config requires a complete configuration from UCI. So there is another function to generate the UCI config.
69 9 Pau Escrich
70 13 Pau Escrich
h2. qmp_wireless_config_initial
71 9 Pau Escrich
72 9 Pau Escrich
To execute this function:
73 9 Pau Escrich
<pre>
74 9 Pau Escrich
. /etc/qmp/qmp_wireless.sh
75 9 Pau Escrich
qmp_configure_wifi_initial
76 9 Pau Escrich
</pre>
77 9 Pau Escrich
78 9 Pau Escrich
This generates de UCI qmp configuration, but not allways from zero. You can have some parameters configured and the function will configure the rest for you. 
79 9 Pau Escrich
80 9 Pau Escrich
For example, you can have a configuration like this:
81 9 Pau Escrich
<pre>
82 9 Pau Escrich
config 'wireless'
83 9 Pau Escrich
 	option 'channel' '132'
84 9 Pau Escrich
 	option 'mode' 'adhoc'
85 9 Pau Escrich
</pre>
86 9 Pau Escrich
87 9 Pau Escrich
And after execute qmp_configure_wifi_initial you will have the rest of needed parameters 
88 9 Pau Escrich
<pre>
89 9 Pau Escrich
config 'wireless'
90 9 Pau Escrich
 	option 'channel' '132'
91 9 Pau Escrich
 	option 'mode' 'adhoc'
92 9 Pau Escrich
        option 'name' 'qmp'
93 9 Pau Escrich
 	option 'mac' '00:80:48:6b:25:b5'
94 9 Pau Escrich
</pre>
95 9 Pau Escrich
96 9 Pau Escrich
So, if you want to use the first device for meshing and the second one for access point, you can build the openwrt image with this kind of configuration:
97 9 Pau Escrich
98 9 Pau Escrich
<pre>
99 9 Pau Escrich
config 'wireless'
100 9 Pau Escrich
 	option 'mode' 'adhoc'
101 9 Pau Escrich
102 9 Pau Escrich
config 'wireless'
103 9 Pau Escrich
 	option 'mode' 'ap'
104 9 Pau Escrich
</pre>
105 9 Pau Escrich
106 9 Pau Escrich
And after the first startup qmp_configure_wifi_initial will be executed putting the rest of parameters.
107 9 Pau Escrich
108 9 Pau Escrich
The default configuration is read from file: /etc/qmp/templates/wireless.default.config looks like that:
109 9 Pau Escrich
<pre>
110 9 Pau Escrich
driver mac80211
111 9 Pau Escrich
country UZ
112 9 Pau Escrich
bssid 02:CA:FF:EE:BA:BE
113 9 Pau Escrich
channel 44
114 9 Pau Escrich
mode adhoc
115 9 Pau Escrich
name qmp.cat
116 1 Pau Escrich
</pre>
117 1 Pau Escrich
118 1 Pau Escrich
Also if the `mac` option is specified, the function will find this device that has this mac-address and use it. If not, it will use the first one free
119 13 Pau Escrich
120 13 Pau Escrich
h2. /etc/init.d/qmp_autoconf
121 14 Pau Escrich
122 13 Pau Escrich
This file is executed during first boot. It uses qmp_configure_wifi_initial and qmp_configure_wifi to leave wireless system ready.
123 13 Pau Escrich
124 13 Pau Escrich
If you want to reconfigure wireless system after first boot, you have to remove a control file named `/qmp_configured`
125 13 Pau Escrich
126 13 Pau Escrich
This script also executes the networking autoconfiguration (bmx6, olsr6...)