From 388d264ff05c914296ce94aeb15cc1cc46f1523e Mon Sep 17 00:00:00 2001 From: Kokel Date: Sat, 6 Feb 2016 00:01:40 +0100 Subject: [PATCH] gluon-core: add preserve wifi channels feature This new feature introduces the new uci section 'gluon-core.wireless' with a preserve_channels option: * preserve_channels (boolean) By setting this option to 1 (true) wifi channels will be preserved during upgrades. --- docs/features/wlan-configuration.rst | 8 ++++++++ package/gluon-core/files/etc/config/gluon-core | 1 + .../gluon-core/files/lib/gluon/upgrade/200-wireless | 12 +++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 package/gluon-core/files/etc/config/gluon-core diff --git a/docs/features/wlan-configuration.rst b/docs/features/wlan-configuration.rst index ff280eba..1c1e3e54 100644 --- a/docs/features/wlan-configuration.rst +++ b/docs/features/wlan-configuration.rst @@ -24,3 +24,11 @@ existing configuration will also be set for the new configuration. This allows upgrades to change from IBSS to 11s and vice-versa while retaining the "wireless meshing is enabled/disabled" property configured by the user regardless of the used mode. + +During upgrades the wifi channel of the 2.4GHz and 5GHz radio will be restored to the channel +configured in the site.conf. If you need to preserve a user defined wifi channel during upgrades +you can configure this via the uci section ``gluon-core.wireless``:: + + uci set gluon-core.@wireless[0].preserve_channels='1' + +Keep in mind that nodes running wifi interfaces on custom channels can't mesh with default nodes anymore! diff --git a/package/gluon-core/files/etc/config/gluon-core b/package/gluon-core/files/etc/config/gluon-core new file mode 100644 index 00000000..9787ccc9 --- /dev/null +++ b/package/gluon-core/files/etc/config/gluon-core @@ -0,0 +1 @@ +config wireless diff --git a/package/gluon-core/files/lib/gluon/upgrade/200-wireless b/package/gluon-core/files/lib/gluon/upgrade/200-wireless index b9495d89..2ada9b3c 100755 --- a/package/gluon-core/files/lib/gluon/upgrade/200-wireless +++ b/package/gluon-core/files/lib/gluon/upgrade/200-wireless @@ -10,11 +10,21 @@ if not sysconfig.gluon_version then uci:delete_all('wireless', 'wifi-iface') end +local function get_channel(radio, config) + if uci:get_first('gluon-core', 'wireless', 'preserve_channels') then + return uci:get('wireless', radio, 'channel') or config.channel + else + return config.channel + end +end + local function configure_radio(radio, index, config) if config then + local channel = get_channel(radio, config) + uci:delete('wireless', radio, 'disabled') - uci:set('wireless', radio, 'channel', config.channel) + uci:set('wireless', radio, 'channel', channel) uci:set('wireless', radio, 'htmode', 'HT20') uci:set('wireless', radio, 'country', site.regdom) end