Skip to content

Commit

Permalink
[fix] Removed option of 2.4GHz radio for 802.11ac #190
Browse files Browse the repository at this point in the history
Closes #190
  • Loading branch information
pandafy committed Feb 24, 2022
1 parent a90813c commit 47b4435
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 50 deletions.
9 changes: 5 additions & 4 deletions docs/source/backends/openwrt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1417,9 +1417,8 @@ Automatic channel selection example
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you need to use the "automatic channel selection" feature of OpenWRT, you must set
the channel to ``0`` and, unless you are using neither **802.11n** nor **802.11ac** nor **802.11ax**,
you must set the ``hwmode`` property to tell OpenWRT which band to use
(11g for 2.4 Ghz, 11a for 5 GHz).
the channel to ``0``. You must also set the ``hwmode`` property to tell OpenWRT which
band to use (11g for 2.4 Ghz, 11a for 5 GHz).

The following example sets "automatic channel selection" for two radios, the first radio uses
**802.11n** in the 2.4 GHz band, while the second uses **802.11ac** in the 5 GHz band.
Expand All @@ -1443,7 +1442,9 @@ The following example sets "automatic channel selection" for two radios, the fir
"driver": "mac80211",
"protocol": "802.11ac",
"channel": 0, # 0 stands for auto
"hwmode": "11a", # must set this explicitly, 11a means 5 GHz band
"hwmode": "11a", # must set this explicitly, 11a means 5 GHz band,
# but this is optional for "802.11ac" because it only
# support 5 GHz band.
"channel_width": 80
}
]
Expand Down
2 changes: 2 additions & 0 deletions netjsonconfig/backends/openwrt/converters/radios.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def __intermediate_hwmode(self, radio):
if protocol in ['802.11a', '802.11b', '802.11g']:
# return 11a, 11b or 11g
return protocol[4:]
if protocol == '802.11ac':
return '11a'
# determine hwmode depending on channel used
if radio['channel'] == 0:
# when using automatic channel selection, we need an
Expand Down
3 changes: 0 additions & 3 deletions netjsonconfig/backends/openwrt/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,6 @@
"radio_80211an_settings": {
"allOf": [{"$ref": "#/definitions/radio_hwmode_11a"}]
},
"radio_80211ac_2ghz_settings": {
"allOf": [{"$ref": "#/definitions/radio_hwmode_11g"}]
},
"radio_80211ac_5ghz_settings": {
"allOf": [{"$ref": "#/definitions/radio_hwmode_11a"}]
},
Expand Down
10 changes: 0 additions & 10 deletions netjsonconfig/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,15 +783,6 @@
{"$ref": "#/definitions/radio_n_channel_width"},
],
},
"radio_80211ac_2ghz_settings": {
"title": "802.11ac (2.4 GHz AC)",
"allOf": [
{"properties": {"protocol": {"enum": ["802.11ac"]}}},
{"$ref": "#/definitions/base_radio_settings"},
{"$ref": "#/definitions/radio_2ghz_channels"},
{"$ref": "#/definitions/radio_ac_channel_width"},
],
},
"radio_80211ac_5ghz_settings": {
"title": "802.11ac (5 GHz AC)",
"allOf": [
Expand Down Expand Up @@ -875,7 +866,6 @@
"oneOf": [
{"$ref": "#/definitions/radio_80211gn_settings"},
{"$ref": "#/definitions/radio_80211an_settings"},
{"$ref": "#/definitions/radio_80211ac_2ghz_settings"},
{"$ref": "#/definitions/radio_80211ac_5ghz_settings"},
{"$ref": "#/definitions/radio_80211ax_2ghz_settings"},
{"$ref": "#/definitions/radio_80211ax_5ghz_settings"},
Expand Down
2 changes: 1 addition & 1 deletion tests/openwrt/test_netjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"name": "radio0",
"protocol": "802.11ac",
"channel": 1,
"channel": 132,
"channel_width": 80,
"phy": "phy0",
"country": "US",
Expand Down
35 changes: 3 additions & 32 deletions tests/openwrt/test_radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,35 +472,6 @@ def test_parse_auto_80211n_5ghz_channel(self):
o = OpenWrt(native=native)
self.assertEqual(o.config, expected)

def test_auto_80211ac_2ghz_channel(self):
o = OpenWrt(
{
"radios": [
{
"name": "radio0",
"phy": "phy0",
"driver": "mac80211",
"protocol": "802.11ac",
"channel": 0,
"channel_width": 80,
"hwmode": "11g",
}
]
}
)
expected = self._tabs(
"""package wireless
config wifi-device 'radio0'
option channel 'auto'
option htmode 'VHT80'
option hwmode '11g'
option phy 'phy0'
option type 'mac80211'
"""
)
self.assertEqual(o.render(), expected)

def test_auto_80211ac_5ghz_channel(self):
o = OpenWrt(
{
Expand Down Expand Up @@ -827,7 +798,7 @@ def test_default_driver(self):
{
"name": "radio0",
"protocol": "802.11ac",
"channel": 1,
"channel": 132,
"channel_width": 80,
"phy": "phy0",
"country": "US",
Expand All @@ -841,11 +812,11 @@ def test_default_driver(self):
"""package wireless
config wifi-device 'radio0'
option channel '1'
option channel '132'
option country 'US'
option disabled '0'
option htmode 'VHT80'
option hwmode '11g'
option hwmode '11a'
option phy 'phy0'
option txpower '10'
option type 'mac80211'
Expand Down

0 comments on commit 47b4435

Please sign in to comment.