Projecte

General

Perfil

Wireless autoconf » Historial » Versió 10

Pau Escrich, 13-06-2011 18:18

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