Project

General

Profile

Wireless autoconf » History » Version 10

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

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