Projecte

General

Perfil

Wireless autoconf » Historial » Versió 11

Pau Escrich, 13-06-2011 18:18

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