Temat: 3ginfo - integracja z luci
W czeluściach netu znalazłem zaczątek luci-app do konfigurowania pakietu 3ginfo spod Luci. Dokonałem w nim lekkiej modyfikacji, aby oprócz wyklikania konfiguracji, wyświetlała efekt odpalenia z shella 3ginfo.
Aby w naszym luci pojwiła sie opcja Services/3ginfo należy poczynić następujące kroki:
1. Zainstalować pakiet 3ginfo
2. W katalogu /usr/lib/lua/luci/controller tworzymy plik 3ginfo.lua o nastepującej zawartości:
module("luci.controller.3ginfo", package.seeall)
function index()
if not nixio.fs.access("/etc/config/3ginfo") then
return
end
local page
page = entry({"admin", "services", "3ginfo"}, cbi("3ginfo"), _("3ginfo - information about your 3g/4g connection"), 60)
page.dependent = true
end3. W katalogu /usr/lib/lua/luci/model/cbi tworzymy plik 3ginfo.lua o nastepującej zawartości:
--[[
LuCI 3ginfo
(c) 2008 Yanira <forum-2008@email.de>
(c) 2012 Jo-Philipp Wich <jow@openwrt.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
3ginfo output mod by muffin
]]--
local f = io.popen("3ginfo")
local l = f:read("*a")
f:close()
local uci = luci.model.uci.cursor_state()
local net = require "luci.model.network"
local m
local s
local dev, pin, port, qos, lang
local try_devices = nixio.fs.glob("/dev/ttyUSB*") or nixio.fs.glob("/dev/ttyACM*") or nixio.fs.glob("/dev/cdc*")
m = Map("3ginfo", translate("3g/LTE info"), "<div><pre>" .. l .. "</pre></div>")
net = net.init(m.uci)
s = m:section(TypedSection, "3ginfo", translate("Settings"))
dev = s:option(Value, "device", translate("Device"))
if try_devices then
local node
for node in try_devices do
dev:value(node, node)
end
end
pin = s:option(Value, "pincode", translate("PIN code (only for 3g), optional"))
pin.default = ""
port = s:option(Value, "http_port", translate("Port for HTTP connections"))
port.default = "81"
qos = s:option(Flag, "qos", translate("Enable QOS support"))
qos.enabled = "1"
qos.disabled = "0"
lang = s:option(Value, "language", translate("Language"))
lang:value("pl", "Polski")
lang:value("en", "English")
lang.default = "en"
return m


