summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gluon-luci-wifi-config/Makefile32
-rw-r--r--gluon-luci-wifi-config/files/usr/lib/lua/luci/controller/admin/wifi-config.lua5
-rw-r--r--gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua94
3 files changed, 131 insertions, 0 deletions
diff --git a/gluon-luci-wifi-config/Makefile b/gluon-luci-wifi-config/Makefile
new file mode 100644
index 0000000..2dd03f0
--- /dev/null
+++ b/gluon-luci-wifi-config/Makefile
@@ -0,0 +1,32 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gluon-luci-wifi-config
+PKG_VERSION:=0.1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/gluon-luci-wifi-config
+ SECTION:=gluon
+ CATEGORY:=Gluon
+ DEPENDS:=+gluon-luci-admin
+ TITLE:=UI for Wifi Settings
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/gluon-luci-wifi-config/install
+ $(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,gluon-luci-wifi-config))
diff --git a/gluon-luci-wifi-config/files/usr/lib/lua/luci/controller/admin/wifi-config.lua b/gluon-luci-wifi-config/files/usr/lib/lua/luci/controller/admin/wifi-config.lua
new file mode 100644
index 0000000..ade24de
--- /dev/null
+++ b/gluon-luci-wifi-config/files/usr/lib/lua/luci/controller/admin/wifi-config.lua
@@ -0,0 +1,5 @@
+module("luci.controller.admin.wifi-config", package.seeall)
+
+function index()
+ entry({"admin", "wifi-config"}, cbi("admin/wifi-config"), "WLAN-Config", 20)
+end
diff --git a/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua b/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua
new file mode 100644
index 0000000..567c565
--- /dev/null
+++ b/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua
@@ -0,0 +1,94 @@
+local f, s, o, p, q
+local uci = luci.model.uci.cursor()
+local config = 'wireless'
+
+--set the heading, button and stuff
+f = SimpleForm("wifi", "WLAN-Config")
+f.reset = false
+f.template = "admin/expertmode"
+f.submit = "Speichern"
+
+-- text, which describes what the package does to the user
+s = f:section(SimpleSection, nil, [[
+In diesem Abschnitt hast du die Möglichkeit die SSIDs des Client- und des
+Mesh-Netzes zu deaktivieren. Bitte lass die SSID des Mesh-Netzes aktiviert,
+damit sich auch andere Router über dich mit dem Freifunk verbinden können.
+]])
+
+
+local radios = {}
+
+-- look for wifi interfaces and add them to the array
+uci:foreach('wireless', 'wifi-device',
+function(s)
+ table.insert(radios, s['.name'])
+end
+)
+
+--add a client and mesh checkbox for each interface
+for index, radio in ipairs(radios) do
+ --get the hwmode to seperate 2.4GHz and 5Ghz radios
+ local hwmode = uci:get('wireless', radio, 'hwmode')
+
+ if hwmode == '11g' or hwmode == '11ng' then --if 2.4GHz
+
+ p = f:section(SimpleSection, [[2,4GHz Wlan]], nil)
+
+ --box for the clientnet
+ o = p:option(Flag, 'clientbox' .. index, "Client-Netz aktivieren")
+ o.default = (uci:get_bool(config, 'client_' .. radio, "disabled")) and o.disabled or o.enabled
+ o.rmempty = false
+ --box for the meshnet
+ o = p:option(Flag, 'meshbox' .. index, "Mesh-Netz aktivieren")
+ o.default = (uci:get_bool(config, 'mesh_' .. radio, "disabled")) and o.disabled or o.enabled
+ o.rmempty = false
+
+ elseif hwmode == '11a' or hwmode == '11na' then --if 5GHz
+
+ q = f:section(SimpleSection, [[5GHz Wlan]], nil)
+
+ --box for the clientnet
+ o = q:option(Flag, 'clientbox' .. index, "Client-Netz aktivieren")
+ o.default = (uci:get_bool(config, 'client_' .. radio, "disabled")) and o.disabled or o.enabled
+ o.rmempty = false
+ --box for the meshnet
+ o = q:option(Flag, 'meshbox' .. index, "Mesh-Netz aktivieren")
+ o.default = (uci:get_bool(config, 'mesh_' .. radio, "disabled")) and o.disabled or o.enabled
+ o.rmempty = false
+
+ end
+end
+
+--if the save-button is pushed
+function f.handle(self, state, data)
+ if state == FORM_VALID then
+
+ for index, radio in ipairs(radios) do
+
+ local clientstate, meshstate
+ -- get the data from the boxes and invert it
+ if data["clientbox"..index] == '0' then
+ clientenabled = 'true'
+ else
+ clientenabled = 'false'
+ end
+ -- write the data to the config file
+ uci:set(config, 'client_' .. radio, "disabled", clientenabled)
+
+
+ if data["meshbox"..index] == '0' then
+ meshenabled = 'true'
+ else
+ meshenabled = 'false'
+ end
+
+ uci:set(config, 'mesh_' .. radio, "disabled", meshenabled)
+
+ end
+
+ uci:save(config)
+ uci:commit(config)
+ end
+end
+
+return f