From 427c83754b51ace0c9993d3d1a62b51ba4f2217c Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 15 Feb 2018 20:29:19 +0100 Subject: [PATCH] gluon-core: 200-wireless: upgrade 11ac radios to VHT20 (#1328) Patch originally authored by @oleeander. Fixes #424 --- package/gluon-core/Makefile | 4 ++-- .../luasrc/lib/gluon/upgrade/200-wireless | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/package/gluon-core/Makefile b/package/gluon-core/Makefile index 4ba21db0..cc8de339 100644 --- a/package/gluon-core/Makefile +++ b/package/gluon-core/Makefile @@ -17,8 +17,8 @@ define Package/gluon-core CATEGORY:=Gluon TITLE:=Base files of Gluon DEPENDS:= \ - +gluon-site +libgluonutil +lua-platform-info +lua-simple-uci +lua-hash +lua-jsonc +luci-lib-nixio \ - +vxlan +odhcp6c +firewall +pretty-hostname + +gluon-site +libgluonutil +libiwinfo-lua +lua-platform-info +lua-simple-uci +lua-hash +lua-jsonc \ + +luci-lib-nixio +vxlan +odhcp6c +firewall +pretty-hostname endef define Package/gluon-core/description diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless index d8b7e1ff..72abfde4 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless @@ -3,6 +3,7 @@ local util = require 'gluon.util' local site = require 'gluon.site' local sysconfig = require 'gluon.sysconfig' +local iwinfo = require 'iwinfo' local uci = require('simple-uci').cursor() @@ -20,6 +21,15 @@ local function get_channel(radio, config) return channel or config.channel() end +local function get_htmode(radio) + local phy = util.find_phy(radio) + if iwinfo.nl80211.hwmodelist(phy).ac then + return 'VHT20' + else + return 'HT20' + end +end + local function is_disabled(name) if uci:get('wireless', name) then return uci:get_bool('wireless', name, 'disabled') @@ -152,11 +162,12 @@ util.foreach_radio(uci, function(radio, index, config) end local channel = get_channel(radio, config) + local htmode = get_htmode(radio) uci:delete('wireless', radio_name, 'disabled') uci:set('wireless', radio_name, 'channel', channel) - uci:set('wireless', radio_name, 'htmode', 'HT20') + uci:set('wireless', radio_name, 'htmode', htmode) uci:set('wireless', radio_name, 'country', site.regdom()) uci:set_list('wireless', radio_name, 'supported_rates', config.supported_rates())