Skip to content

Commit

Permalink
[OpenWrt] Allow overriding htmode option
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Apr 1, 2016
1 parent 361ffe1 commit 45159e8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions netjsonconfig/backends/openwrt/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ def __get_htmode(self, radio):
"""
only for mac80211 driver
"""
# allow overriding htmode
if 'htmode' in radio:
return radio['htmode']
if radio['protocol'] == '802.11n':
return 'HT{0}'.format(radio['channel_width'])
elif radio['protocol'] == '802.11ac':
Expand Down
25 changes: 25 additions & 0 deletions tests/openwrt/test_wireless.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,5 +1441,30 @@ def test_macaddr_override(self):
option mode 'ap'
option network 'wlan0'
option ssid 'open'
""")
self.assertEqual(o.render(), expected)

def test_htmode_override(self):
o = OpenWrt({
"radios": [
{
"name": "radio0",
"phy": "phy0",
"driver": "mac80211",
"protocol": "802.11n",
"channel": 140,
"channel_width": 40,
"htmode": "HT40+"
},
]
})
expected = self._tabs("""package wireless
config wifi-device 'radio0'
option channel '140'
option htmode 'HT40+'
option hwmode '11a'
option phy 'phy0'
option type 'mac80211'
""")
self.assertEqual(o.render(), expected)

0 comments on commit 45159e8

Please sign in to comment.