Skip to content

Commit 6fbebb6

Browse files
committed
[airos] added channel width support for radio interfaces, updated tests
1 parent ce25749 commit 6fbebb6

File tree

2 files changed

+104
-7
lines changed

2 files changed

+104
-7
lines changed

netjsonconfig/backends/airos/radio.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,30 @@
5454
}
5555

5656

57+
def channel_to_mode(channel):
58+
"""
59+
Returns the ``ieee_mode`` value from the channel width
60+
"""
61+
mapping = {
62+
10: '11acvht20',
63+
20: '11acvht20',
64+
40: '11acvht40',
65+
60: '11acvht40',
66+
80: '11acvht80',
67+
}
68+
return mapping[channel]
69+
70+
5771
def access_point(radio):
5872
"""
5973
Return the configuration for a radio device whose wireless
6074
interface is in ``access_point`` mode
6175
"""
62-
base = _radio_device_base.copy()
76+
base = radio_device_base.copy()
6377
base.update({
6478
'devname': radio['name'],
65-
'chanbw': 80,
66-
'ieee_mode': '11acvht80',
79+
'chanbw': radio['channel_width'],
80+
'ieee_mode': channel_to_mode(radio['channel_width']),
6781
'mode': 'master',
6882
})
6983
return base
@@ -74,9 +88,10 @@ def station(radio):
7488
Return the configuration for a radio device whose wireless
7589
interface is in ``station`` mode
7690
"""
77-
base = _radio_device_base.copy()
91+
base = radio_device_base.copy()
7892
base.update({
7993
'devname': radio['name'],
94+
'chanbw': radio['channel_width'],
8095
'txpower': radio.get('tx_power', 24),
8196
})
8297
return base
@@ -87,6 +102,7 @@ def station(radio):
87102
'station': station,
88103
}
89104

105+
90106
__all__ = [
91107
radio_available_mode,
92108
radio_configuration,

tests/airos/test_radio.py

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,88 @@ def test_active_radio(self):
6363
'1.atpc.threshold': 36,
6464
'1.cable.loss': 0,
6565
'1.center.1.freq': 0,
66-
'1.chanbw': 0,
66+
'1.chanbw': 20,
67+
'1.cmsbias': 0,
68+
'1.countrycode': 380,
69+
'1.cwm.enable': 0,
70+
'1.cwm.mode': 1,
71+
'1.devname': 'ath0',
72+
'1.dfs.status': 'enabled',
73+
'1.freq': 0,
74+
'1.ieee_mode': 'auto',
75+
'1.low_txpower_mode': 'disabled',
76+
'1.mode': 'managed',
77+
'1.obey': 'enabled',
78+
'1.polling': 'enabled',
79+
'1.polling_11ac_11n_compat': 0,
80+
'1.polling_ff_dl_ratio': 50,
81+
'1.polling_ff_dur': 0,
82+
'1.polling_ff_timing': 0,
83+
'1.pollingnoack': 0,
84+
'1.pollingpri': 2,
85+
'1.ptpmode': 1,
86+
'1.reg_obey': 'enabled',
87+
'1.rx_sensitivity': -96,
88+
'1.scan_list.status': 'disabled',
89+
'1.scanbw.status': 'disabled',
90+
'1.status': 'enabled',
91+
'1.subsystemid': 0xe7f5,
92+
'1.txpower': 24,
93+
},
94+
{
95+
'countrycode': 380,
96+
'status': 'enabled',
97+
}
98+
]
99+
100+
self.assertEqualConfig(o.intermediate_data['radio'], expected)
101+
102+
103+
def test_channel_width(self):
104+
"""
105+
TODO: channel brandwidth tested only on 802.11ac
106+
"""
107+
o = self.backend({
108+
"interfaces": [
109+
{
110+
'type': 'wireless',
111+
'name': 'wlan0',
112+
'wireless': {
113+
'radio': 'ath0',
114+
'mode': 'station',
115+
'ssid': 'ubnt',
116+
'bssid': '00:11:22:33:44:55',
117+
'encryption': {
118+
'protocol': 'none',
119+
},
120+
},
121+
},
122+
],
123+
"radios": [
124+
{
125+
'name': 'ath0',
126+
'channel': 1,
127+
'channel_width': 80,
128+
'protocol': '802.11ac',
129+
}
130+
]
131+
})
132+
o.to_intermediate()
133+
expected = [
134+
{
135+
'1.ack.auto': 'enabled',
136+
'1.ackdistance': 643,
137+
'1.acktimeout': 35,
138+
'1.ampdu.frames': 32,
139+
'1.ampdu.status': 'enabled',
140+
'1.antenna.gain': 3,
141+
'1.antenna.id': 2,
142+
'1.atpc.sta.status': 'enabled',
143+
'1.atpc.status': 'disabled',
144+
'1.atpc.threshold': 36,
145+
'1.cable.loss': 0,
146+
'1.center.1.freq': 0,
147+
'1.chanbw': 80,
67148
'1.cmsbias': 0,
68149
'1.countrycode': 380,
69150
'1.cwm.enable': 0,
@@ -148,15 +229,15 @@ def test_active_radio(self):
148229
'1.atpc.threshold': 36,
149230
'1.cable.loss': 0,
150231
'1.center.1.freq': 0,
151-
'1.chanbw': 80,
232+
'1.chanbw': 20,
152233
'1.cmsbias': 0,
153234
'1.countrycode': 380,
154235
'1.cwm.enable': 0,
155236
'1.cwm.mode': 1,
156237
'1.devname': 'ath0',
157238
'1.dfs.status': 'enabled',
158239
'1.freq': 0,
159-
'1.ieee_mode': '11acvht80',
240+
'1.ieee_mode': '11acvht20',
160241
'1.low_txpower_mode': 'disabled',
161242
'1.mode': 'master',
162243
'1.obey': 'enabled',

0 commit comments

Comments
 (0)