From 501c3b38bb9106d893fc97d58c568443ead225bf Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 26 Mar 2018 14:42:47 +0200 Subject: [PATCH] add gluon-config-mode-outdoor package adds a section to the wizard for outdoor capable devices that informs the user of of the regulatory situation and allows a quick toggle of the outdoor mode. --- package/features | 3 +- package/gluon-config-mode-outdoor/Makefile | 13 +++++++++ package/gluon-config-mode-outdoor/i18n/de.po | 9 ++++++ .../i18n/gluon-config-mode-outdoor.pot | 7 +++++ .../gluon/config-mode/wizard/0250-outdoor.lua | 28 +++++++++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 package/gluon-config-mode-outdoor/Makefile create mode 100644 package/gluon-config-mode-outdoor/i18n/de.po create mode 100644 package/gluon-config-mode-outdoor/i18n/gluon-config-mode-outdoor.pot create mode 100644 package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua diff --git a/package/features b/package/features index 8b44c82e..5de9e424 100644 --- a/package/features +++ b/package/features @@ -3,7 +3,8 @@ nodefault 'web-wizard' packages 'web-wizard' \ 'gluon-config-mode-hostname' \ 'gluon-config-mode-geo-location' \ - 'gluon-config-mode-contact-info' + 'gluon-config-mode-contact-info' \ + 'gluon-config-mode-outdoor' packages 'web-wizard & autoupdater' \ 'gluon-config-mode-autoupdater' diff --git a/package/gluon-config-mode-outdoor/Makefile b/package/gluon-config-mode-outdoor/Makefile new file mode 100644 index 00000000..2f3acfcd --- /dev/null +++ b/package/gluon-config-mode-outdoor/Makefile @@ -0,0 +1,13 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-config-mode-outdoor +PKG_VERSION:=1 + +include ../gluon.mk + +define Package/gluon-config-mode-outdoor + TITLE:=UI for displaying & changing the outdoor mode flag in the wizard + DEPENDS:=+gluon-config-mode-core +endef + +$(eval $(call BuildPackageGluon,gluon-config-mode-outdoor)) diff --git a/package/gluon-config-mode-outdoor/i18n/de.po b/package/gluon-config-mode-outdoor/i18n/de.po new file mode 100644 index 00000000..55cdb230 --- /dev/null +++ b/package/gluon-config-mode-outdoor/i18n/de.po @@ -0,0 +1,9 @@ +msgid "" +"Please enable this option in case the node is to be installed outdoors " +"to comply with local frequency regulations." +msgstr "" +"Wenn der Knoten im Freien aufgestellt werden soll, dann aktiviere bitte " +"diese Option um den örtlichen Frequenzbestimmungen zu entsprechen." + +msgid "Node will be installed outdoors" +msgstr "Knoten wird im Außenbereich betrieben" diff --git a/package/gluon-config-mode-outdoor/i18n/gluon-config-mode-outdoor.pot b/package/gluon-config-mode-outdoor/i18n/gluon-config-mode-outdoor.pot new file mode 100644 index 00000000..d7c04908 --- /dev/null +++ b/package/gluon-config-mode-outdoor/i18n/gluon-config-mode-outdoor.pot @@ -0,0 +1,7 @@ +msgid "" +"Please enable this option in case the node is to be installed outdoors " +"to comply with local frequency regulations." +msgstr "" + +msgid "Node will be installed outdoors" +msgstr "" diff --git a/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua b/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua new file mode 100644 index 00000000..edfe839f --- /dev/null +++ b/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua @@ -0,0 +1,28 @@ +return function(form, uci) + local platform_info = require 'platform_info' + + if not platform_info.is_outdoor_device() then + -- only visible on wizard for outdoor devices + return + end + + local pkg_i18n = i18n 'gluon-config-mode-outdoor' + + local section = form:section(Section, nil, pkg_i18n.translate( + "Please enable this option in case the node is to be installed outdoors " + .. "to comply with local frequency regulations." + )) + + local outdoor = section:option(Flag, 'outdoor', pkg_i18n.translate("Node will be installed outdoors")) + outdoor.default = outdoor_mode + + function outdoor:write(data) + if data ~= outdoor_mode then + uci:set('gluon', 'wireless', 'outdoor', data) + uci:save('gluon') + os.execute('/lib/gluon/upgrade/200-wireless') + end + end + + return {'gluon', 'wireless'} +end