mirror of
https://github.com/coolsnowwolf/luci
synced 2025-01-07 07:06:41 +08:00
luci-proto-modemmanager: add luci pacakge
This commit is contained in:
parent
d82d969fe7
commit
105d0e4596
16
protocols/luci-proto-modemmanager/Makefile
Executable file
16
protocols/luci-proto-modemmanager/Makefile
Executable file
@ -0,0 +1,16 @@
|
||||
#
|
||||
# Copyright 2019 Telco Antennas Pty Ltd <nicholas.smith@telcoantennas.com.au>
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=Support for ModemManager
|
||||
LUCI_DEPENDS:=+modemmanager
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
include ../../luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
|
@ -0,0 +1,44 @@
|
||||
-- Copyright 2019 Telco Antennas Pty Ltd <nicholas.smith@telcoantennas.com.au>
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
local map, section, net = ...
|
||||
|
||||
local device, apn, pincode, username, password, iptype
|
||||
local auth, ipv6
|
||||
|
||||
device = section:taboption("general", Value, "device", translate("Modem device"))
|
||||
device.rmempty = false
|
||||
|
||||
-- Supports only one modem that has already been registered by MM. Ensures the modem is usable.
|
||||
-- Assumes modem is on index 0
|
||||
local handle = io.popen("mmcli -m 0 | grep 'device: ' | grep -Eo '/sys/devices/.*' | tr -d \"'\"", "r")
|
||||
local device_suggestions = handle:read("*l")
|
||||
handle:close()
|
||||
|
||||
if handle then
|
||||
device:value(device_suggestions)
|
||||
end
|
||||
|
||||
apn = section:taboption("general", Value, "apn", translate("APN"))
|
||||
|
||||
pincode = section:taboption("general", Value, "pincode", translate("PIN"))
|
||||
|
||||
username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
|
||||
|
||||
password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
|
||||
password.password = true
|
||||
|
||||
auth = section:taboption("general", Value, "auth", translate("Authentication type"))
|
||||
auth:value("", translate("-- Please choose --"))
|
||||
auth:value("both", "PAP/CHAP (both)")
|
||||
auth:value("pap", "PAP")
|
||||
auth:value("chap", "CHAP")
|
||||
auth:value("none", "NONE")
|
||||
|
||||
iptype = section:taboption("general", Value, "iptype", translate("IP connection type"))
|
||||
iptype:value("", translate("-- Please choose --"))
|
||||
iptype:value("ipv4", "IPv4 only")
|
||||
iptype:value("ipv6", "IPv6 only")
|
||||
iptype:value("ipv4v6", "IPv4/IPv6 (both - defaults to IPv4)")
|
||||
|
||||
metric = section:taboption("general", Value, "metric", translate("Gateway metric"))
|
@ -0,0 +1,55 @@
|
||||
-- Copyright 2019 Telco Antennas Pty Ltd <nicholas.smith@telcoantennas.com.au>
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
local proto = netmod:register_protocol("modemmanager")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("Mobile Data")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
local base = netmod._M.protocol
|
||||
local ifname = base.ifname(self) -- call base class "protocol.ifname(self)"
|
||||
|
||||
-- Note: ifname might be nil if the adapter could not be determined through ubus (default name to carrier-wan in this case)
|
||||
if ifname == nil then
|
||||
ifname = "carrier-" .. self.sid
|
||||
end
|
||||
return ifname
|
||||
end
|
||||
|
||||
function proto.get_interface(self)
|
||||
return interface(self:ifname(), self)
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "modemmanager"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/modemmanager.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^mobiledata%-%w")
|
||||
|
||||
netmod:register_error_code("CALL_FAILED", luci.i18n.translate("Call failed. Ensure that your SIM is active and has data."))
|
||||
netmod:register_error_code("NO_CID", luci.i18n.translate("Unable to obtain client ID from the carrier. Check your SIM or try again in a few minutes."))
|
||||
netmod:register_error_code("PLMN_FAILED", luci.i18n.translate("Setting PLMN failed"))
|
Loading…
Reference in New Issue
Block a user