From 86773d762829f0b8e8ac8d07559e78962c7f1f5b Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Fri, 7 Aug 2015 18:36:13 +0200
Subject: [PATCH] gluon-luci-wifi-config: add support for new WLAN
 configuration

---
 .../lua/luci/model/cbi/admin/wifi-config.lua  | 52 +++++++++++++------
 package/gluon-luci-wifi-config/i18n/de.po     | 25 +++++----
 .../i18n/gluon-luci-wifi-config.pot           | 10 +++-
 3 files changed, 59 insertions(+), 28 deletions(-)

diff --git a/package/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua b/package/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua
index 66393961e..060fb22b4 100644
--- a/package/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua
+++ b/package/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua
@@ -75,15 +75,23 @@ for _, radio in ipairs(radios) do
   if p then
     local o
 
-    --box for the client network
-    o = p:option(Flag, radio .. '_client_enabled', translate("Enable client network"))
-    o.default = uci:get_bool('wireless', 'client_' .. radio, "disabled") and o.disabled or o.enabled
-    o.rmempty = false
+    if uci:get('wireless', 'client_' .. radio) then
+      o = p:option(Flag, radio .. '_client_enabled', translate("Enable client network (access point)"))
+      o.default = uci:get_bool('wireless', 'client_' .. radio, "disabled") and o.disabled or o.enabled
+      o.rmempty = false
+    end
+
+    if uci:get('wireless', 'mesh_' .. radio) then
+      o = p:option(Flag, radio .. '_mesh_enabled', translate("Enable mesh network (802.11s)"))
+      o.default = uci:get_bool('wireless', 'mesh_' .. radio, "disabled") and o.disabled or o.enabled
+      o.rmempty = false
+    end
 
-    --box for the mesh network
-    o = p:option(Flag, radio .. '_mesh_enabled', translate("Enable mesh network"))
-    o.default = uci:get_bool('wireless', 'mesh_' .. radio, "disabled") and o.disabled or o.enabled
-    o.rmempty = false
+    if uci:get('wireless', 'ibss_' .. radio) then
+      o = p:option(Flag, radio .. '_ibss_enabled', translate("Enable mesh network (IBSS)"))
+      o.default = uci:get_bool('wireless', 'ibss_' .. radio, "disabled") and o.disabled or o.enabled
+      o.rmempty = false
+    end
 
     local phy
 
@@ -120,17 +128,29 @@ function f.handle(self, state, data)
 
     for _, radio in ipairs(radios) do
 
-      local clientdisabled = 0
-      if data[radio .. '_client_enabled'] == '0' then
-        clientdisabled = 1
+      if uci:get('wireless', 'client_' .. radio) then
+	local disabled = 0
+	if data[radio .. '_client_enabled'] == '0' then
+	  disabled = 1
+	end
+	uci:set('wireless', 'client_' .. radio, "disabled", disabled)
+      end
+
+      if uci:get('wireless', 'mesh_' .. radio) then
+	local disabled = 0
+	if data[radio .. '_mesh_enabled'] == '0' then
+	  disabled = 1
+	end
+	uci:set('wireless', 'mesh_' .. radio, "disabled", disabled)
       end
-      uci:set('wireless', 'client_' .. radio, "disabled", clientdisabled)
 
-      local meshdisabled = 0
-      if data[radio .. '_mesh_enabled'] == '0' then
-        meshdisabled = 1
+      if uci:get('wireless', 'ibss_' .. radio) then
+	local disabled = 0
+	if data[radio .. '_ibss_enabled'] == '0' then
+	  disabled = 1
+	end
+	uci:set('wireless', 'ibss_' .. radio, "disabled", disabled)
       end
-      uci:set('wireless', 'mesh_' .. radio, "disabled", meshdisabled)
 
       if data[radio .. '_txpower'] then
         if data[radio .. '_txpower'] == 'default' then
diff --git a/package/gluon-luci-wifi-config/i18n/de.po b/package/gluon-luci-wifi-config/i18n/de.po
index d633d84cb..099e79b59 100644
--- a/package/gluon-luci-wifi-config/i18n/de.po
+++ b/package/gluon-luci-wifi-config/i18n/de.po
@@ -19,15 +19,21 @@ msgstr "2,4GHz-WLAN"
 msgid "5GHz WLAN"
 msgstr "5GHz-WLAN"
 
-msgid "Enable client network"
-msgstr "Client-Netz aktivieren"
+msgid "Enable client network (access point)"
+msgstr "Client-Netz aktivieren (Access Point)"
 
-msgid "Enable mesh network"
-msgstr "Mesh-Netz aktivieren"
+msgid "Enable mesh network (802.11s)"
+msgstr "Mesh-Netz aktivieren (802.11s)"
+
+msgid "Enable mesh network (IBSS)"
+msgstr "Mesh-Netz aktivieren (IBSS)"
 
 msgid "Transmission power"
 msgstr "Sendeleistung"
 
+msgid "WLAN"
+msgstr "WLAN"
+
 msgid ""
 "You can enable or disable your node's client and mesh network SSIDs here. "
 "Please don't disable the mesh network without a good reason, so other nodes "
@@ -36,11 +42,10 @@ msgid ""
 "values include the antenna gain where available, but there are many devices "
 "for which the gain is unavailable or inaccurate."
 msgstr ""
-"In diesem Abschnitt hast du die Möglichkeit, die SSIDs des Client- und "
-"des Mesh-Netzes zu aktivieren bzw. deaktivieren. Bitte lass die SSID des "
-"Mesh-Netzes aktiviert, damit sich andere Knoten mit deinem verbinden "
-"können.<br /><br />"
-"Außerdem kann hier die Sendeleistung des WLAN-Adapters konfiguriert werden. "
-"Wenn möglich, ist in den Werten der Sendeleistung der Antennengewinn "
+"In diesem Abschnitt hast du die Möglichkeit, die SSIDs des Client- und des "
+"Mesh-Netzes zu aktivieren bzw. deaktivieren. Bitte lass die SSID des Mesh-"
+"Netzes aktiviert, damit sich andere Knoten mit deinem verbinden können.<br /"
+"><br />Außerdem kann hier die Sendeleistung des WLAN-Adapters konfiguriert "
+"werden. Wenn möglich, ist in den Werten der Sendeleistung der Antennengewinn "
 "enthalten; diese Werte sind allerdings für viele Geräte nicht verfügbar oder "
 "fehlerhaft."
diff --git a/package/gluon-luci-wifi-config/i18n/gluon-luci-wifi-config.pot b/package/gluon-luci-wifi-config/i18n/gluon-luci-wifi-config.pot
index fa61df184..9b1c86440 100644
--- a/package/gluon-luci-wifi-config/i18n/gluon-luci-wifi-config.pot
+++ b/package/gluon-luci-wifi-config/i18n/gluon-luci-wifi-config.pot
@@ -10,15 +10,21 @@ msgstr ""
 msgid "5GHz WLAN"
 msgstr ""
 
-msgid "Enable client network"
+msgid "Enable client network (access point)"
 msgstr ""
 
-msgid "Enable mesh network"
+msgid "Enable mesh network (802.11s)"
+msgstr ""
+
+msgid "Enable mesh network (IBSS)"
 msgstr ""
 
 msgid "Transmission power"
 msgstr ""
 
+msgid "WLAN"
+msgstr ""
+
 msgid ""
 "You can enable or disable your node's client and mesh network SSIDs here. "
 "Please don't disable the mesh network without a good reason, so other nodes "
-- 
GitLab