update to qmodem

This commit is contained in:
fujr 2024-10-09 11:51:26 +08:00
parent ef2be423d2
commit 6046debe6f
71 changed files with 576 additions and 1608 deletions

View File

@ -1,9 +0,0 @@
module("luci.controller.modem_mwan", package.seeall)
function index()
if not nixio.fs.access("/etc/config/modem_mwan") then
return
end
--mwan配置
entry({"admin", "network", "modem", "mwan_config"}, cbi("modem/mwan_config"), luci.i18n.translate("Mwan Config"), 21).leaf = true
end

View File

@ -1,89 +0,0 @@
local d = require "luci.dispatcher"
local uci = luci.model.uci.cursor()
local sys = require "luci.sys"
local script_path="/usr/share/modem/"
m = Map("modem_mwan")
m.title = translate("Mwan Config")
m.description = translate("Check and modify the mwan configuration")
s = m:section(NamedSection, "global", "global", translate("gloal Config"))
s.anonymous = true
s.addremove = false
enable_mwan = s:option(Flag, "enable_mwan", translate("Enable MWAN"))
sticky = s:option(Flag,"sticky_mode",translate("sticky mode"))
sticky.default = 0
sticky.description = translate("same source ip address will always use the same wan interface")
sticky_timeout = s:option(Value,"sticky_timeout",translate("sticky timeout"))
sticky_timeout.default = 300
sticky_timeout.datatype = "uinteger"
sticky_timeout:depends("sticky_mode",1)
s = m:section(NamedSection, "ipv4", "ipv4", translate("IPV4 Config"))
s.anonymous = true
s.addremove = false
--设置mwan策略 0:不使用 1:使用(作为后备) 2:使用(作为主要) 3:使用(作为负载均衡)
o = s:option(ListValue, "mwan_policy", translate("MWAN Policy"))
o:value("0", translate("Not Use"))
o:value("1", translate("Use(WWAN As Backup)"))
o:value("2", translate("Use(WWAN As Main)"))
o:value("3", translate("Use(WWAN For Load Balance)"))
--设置mwan 有线wan端口
o = s:option(Value, "wan_ifname", translate("WAN Interface"))
o.rmempty = ture
o.description = translate("Please enter the WAN interface name")
o.template = "cbi/network_netlist"
o.widget = "optional"
o.nocreate = true
o.unspecified = true
--设置mwan wwan端口
o = s:option(Value, "wwan_ifname", translate("WWAN Interface"))
o.rmempty = ture
o.description = translate("Please enter the WWAN interface name")
o.template = "cbi/network_netlist"
o.widget = "optional"
o.nocreate = true
o.unspecified = true
o = s:option(DynamicList, 'track_ip', translate('track_ip'))
o.datatype = 'host'
-- m.title = translate("Mwan Config")
-- m.description = translate("Check and modify the mwan configuration")
-- s = m:section(NamedSection, "ipv6", "ipv6", translate("IPV6 Config"))
-- s.anonymous = true
-- s.addremove = false
-- --设置mwan策略 0:不使用 1:使用(作为后备) 2:使用(作为主要) 3:使用(作为负载均衡)
-- o = s:option(ListValue, "mwan_policy", translate("MWAN Policy"))
-- o:value("0", translate("Not Use"))
-- o:value("1", translate("Use(WWAN As Backup)"))
-- o:value("2", translate("Use(WWAN As Main)"))
-- o:value("3", translate("Use(WWAN For Load Balance)"))
-- --设置mwan 有线wan端口
-- o = s:option(Value, "wan_ifname", translate("WAN Interface"))
-- o.rmempty = ture
-- o.description = translate("Please enter the WAN interface name")
-- o.template = "cbi/network_netlist"
-- o.widget = "optional"
-- o.nocreate = true
-- o.unspecified = true
-- --设置mwan wwan端口
-- o = s:option(Value, "wwan_ifname", translate("WWAN Interface"))
-- o.rmempty = ture
-- o.description = translate("Please enter the WWAN interface name")
-- o.template = "cbi/network_netlist"
-- o.widget = "optional"
-- o.nocreate = true
-- o.unspecified = true
-- o = s:option(DynamicList, 'track_ip', translate('track_ip'))
-- o.datatype = 'host'
return m

View File

@ -1,12 +0,0 @@
#model/modem_mwan.lua
msgid "same source ip address will always use the same wan interface"
msgstr "相同的源IP地址将在一定时间内始终使用相同的WAN接口"
msgid "Check and modify the mwan configuration"
msgstr "检查和修改mwan配置"
msgid "sticky mode"
msgstr "粘性模式"
msgid "sticky timeout"
msgstr "粘性超时"

View File

@ -1,12 +0,0 @@
#model/modem_mwan.lua
msgid "same source ip address will always use the same wan interface"
msgstr "相同的源IP地址将在一定时间内始终使用相同的WAN接口"
msgid "Check and modify the mwan configuration"
msgstr "检查和修改mwan配置"
msgid "sticky mode"
msgstr "粘性模式"
msgid "sticky timeout"
msgstr "粘性超时"

View File

@ -1,10 +0,0 @@
config ipv4 'ipv4'
option wan_ifname 'wan'
option wwan_ifname '2_1'
list track_ip 'test.ustc.edu.cn'
list track_ip 'cip.cc'
list track_ip '208.67.222.222'
list track_ip '208.67.220.220'
config global 'global'
option enable_mwan '0'

View File

@ -1,58 +0,0 @@
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=30
set_rule()
{
proto=$1
policy=$2
case $policy in
0)
cmd="stop"
;;
1)
cmd="wan"
;;
2)
cmd="wwan"
;;
3)
cmd="lb"
;;
*)
cmd="stop"
;;
esac
logger -t modem_mwan "before set $proto $cmd"
/usr/share/modem/modem_mwan.sh $proto $cmd
logger -t modem_mwan "set $proto $cmd"
}
start_service() {
logger -t modem_mwan "start modem_mwan"
config_load modem_mwan
config_get enable global enable_mwan 0
if [ "$enable" = "0" ]; then
stop_service
fi
config_get v4 ipv4 mwan_policy 0
set_rule ipv4 $v4
}
stop_service() {
/usr/share/modem/modem_mwan.sh ipv4 stop
/usr/share/modem/modem_mwan.sh ipv4 disable
}
service_triggers() {
procd_add_reload_trigger 'modem_mwan'
}
reload_service() {
stop
start
}

View File

@ -1,192 +0,0 @@
#! /bin/sh
. /lib/functions.sh
family=$1
config_load modem_mwan
config_get wan "$family" wan_ifname
config_get wwan "$family" wwan_ifname
config_get track_ip "$family" track_ip
config_get sticky_mode global sticky_mode
config_get sticky_timeout global sticky_timeout
append_if(){
interface=$1
track_ip=$2
uci batch <<EOF
set mwan3.$interface=interface
set mwan3.$interface.enabled=1
set mwan3.$interface.family="$family"
set mwan3.$interface.track_method=ping
set mwan3.$interface.reliability='1'
set mwan3.$interface.count='1'
set mwan3.$interface.size='56'
set mwan3.$interface.max_ttl='60'
set mwan3.$interface.timeout='4'
set mwan3.$interface.interval='10'
set mwan3.$interface.failure_interval='5'
set mwan3.$interface.recovery_interval='5'
set mwan3.$interface.down='5'
set mwan3.$interface.up='5'
set mwan3.$interface.add_by=modem
delete mwan3.$interface.track_ip
EOF
if [ -n "$track_ip" ]; then
for ip in $track_ip; do
uci add_list mwan3.$interface.track_ip=$ip
done
fi
}
add_mwan3_member()
{
interface=$1
metric=$2
weight=$3
member_name="${interface}_m_${metric}_w_${weight}"
uci batch <<EOF
set mwan3.$member_name=member
set mwan3.$member_name.interface=$interface
set mwan3.$member_name.metric=$metric
set mwan3.$member_name.weight=$weight
set mwan3.$member_name.add_by=modem
EOF
}
remove_member()
{
config_load mwan3
config_foreach remove_member_cb member
}
remove_member_cb()
{
local add_by
config_get add_by $1 add_by
if [ "$add_by" = "modem" ]; then
uci delete mwan3.$1
fi
}
add_mwan3_policy()
{
policy_name=$1
use_member=$2
uci batch <<EOF
set mwan3.$policy_name=policy
set mwan3.$policy_name.last_resort='default'
set mwan3.$policy_name.add_by=modem
delete mwan3.$policy_name.use_member
EOF
for member in $use_member; do
uci add_list mwan3.$policy_name.use_member=$member
done
}
flush_config(){
config_load mwan3
config_foreach remove_cb interface
config_foreach remove_cb member
config_foreach remove_cb policy
config_foreach remove_cb rule
}
remove_cb(){
local add_by
config_get add_by $1 add_by
if [ "$add_by" = "modem" ]; then
uci delete mwan3.$1
fi
}
add_balance_policy()
{
add_mwan3_member $wan 1 1
add_mwan3_member $wwan 1 1
add_mwan3_policy lb_${family} "${wan}_m_1_w_1 ${wwan}_m_1_w_1"
}
add_wan_prefer_policy()
{
config_load modem_mwan
config_get wan "$family" wan_ifname
config_get wwan "$family" wwan_ifname
config_get track_ip "$family" track_ip
add_mwan3_member $wan 1 1
add_mwan3_member $wwan 2 1
add_mwan3_policy preferwan_${family} "${wan}_w_1_m_1 ${wwan}_w_2_m_1"
}
add_wwan_prefer_policy()
{
add_mwan3_member $wan 2 1
add_mwan3_member $wwan 1 1
add_mwan3_policy preferwwan_${family} "${wan}_w_2_m_1 ${wwan}_w_1_m_1"
}
set_if()
{
family=$1
append_if $wan "$track_ip"
append_if $wwan "$track_ip"
}
gen_if()
{
append_if $wan "$track_ip"
append_if $wwan "$track_ip"
}
gen_rule()
{
use_policy=$1
rule_name=${family}_rule
uci batch <<EOF
set mwan3.$rule_name=rule
set mwan3.$rule_name.family="$family"
set mwan3.$rule_name.sticky=$sticky_mode
set mwan3.$rule_name.proto='all'
set mwan3.$rule_name.use_policy=$use_policy
set mwan3.$rule_name.add_by=modem
EOF
if [ -n "$sticky_timeout" ]; then
uci set mwan3.$rule_name.timeout=$sticky_timeout
fi
}
/etc/init.d/mwan3 stop
case $2 in
"lb")
set_if $family
add_balance_policy
gen_rule lb_${family}
start=start
;;
"wan")
set_if $family
add_wan_prefer_policy
gen_rule preferwan_${family}
start=start
;;
"wwan")
set_if $family
add_wwan_prefer_policy
gen_rule preferwwan_${family}
start=start
;;
"disable")
/etc/init.d/mwan3 stop
flush_config
;;
"stop")
rule_name=${family}_rule
uci delete mwan3.$rule_name
;;
esac
uci commit mwan3
/etc/init.d/mwan3 $start

View File

@ -1,22 +0,0 @@
# Copyright (C) 2024 Tom <fjrcn@outlook.com>
# This is free software, licensed under the GNU General Public License v3.
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-5gmodem-mwan
LUCI_TITLE:=Luci modem mwan support
LUCI_PKGARCH:=all
PKG_VERSION:=2.0
PKG_LICENSE:=GPLv3
PKG_LINCESE_FILES:=LICENSE
PKF_MAINTAINER:=fujr
LUCI_DEPENDS:=+luci-app-5gmodem +luci-app-mwan3
define Package/luci-app-5gmodem-mwan/conffiles
/etc/config/modem_mwan
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -1,9 +0,0 @@
module("luci.controller.modem_mwan", package.seeall)
function index()
if not nixio.fs.access("/etc/config/modem_mwan") then
return
end
--mwan配置
entry({"admin", "network", "modem", "mwan_config"}, cbi("modem/mwan_config"), luci.i18n.translate("Mwan Config"), 21).leaf = true
end

View File

@ -1,29 +0,0 @@
config ipv4
list member_track_ip 'test.ustc.edu.cn'
list member_track_ip 'cip.cc'
list member_track_ip '208.67.222.222'
list member_track_ip '208.67.220.220'
list member_interface 'wan'
option member_priority '1'
option member_weight '1'
config ipv4
list member_track_ip 'test.ustc.edu.cn'
list member_track_ip 'cip.cc'
list member_track_ip '208.67.222.222'
list member_track_ip '208.67.220.220'
list member_interface '2_1_2'
option member_priority '2'
option member_weight '1'
config ipv4
list member_track_ip 'test.ustc.edu.cn'
list member_track_ip 'cip.cc'
list member_track_ip '208.67.222.222'
list member_track_ip '208.67.220.220'
list member_interface '2_1_4'
option member_priority '2'
option member_weight '1'
config global 'global'
option enable_mwan '1'

View File

@ -1,8 +0,0 @@
-- Copyright 2024 Siriling <siriling@qq.com>
module("luci.controller.modem_ttl", package.seeall)
function index()
if not nixio.fs.access("/etc/config/modem_ttl") then
return
end
entry({"admin", "network", "modem", "modem_ttl"}, cbi("modem/modem_ttl"), luci.i18n.translate("TTL Config"), 22).leaf = true
end

View File

@ -1,4 +0,0 @@
#指定换行符
/luasrc/** text eol=lf
# /old/* text eol=lf
/root/** text eol=lf

View File

@ -1,49 +0,0 @@
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

View File

@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -1,51 +0,0 @@
# 中文 | [English](https://github.com/Siriling/5G-Modem-Support/blob/main/EngLish.md)
# luci-app-modem
# 目录
[一、说明](#一说明)
[二、模组支持](#二模组支持)
# 一、说明
- 支持USB和PCIe两种通信方式的通信模组
- 支持配置多个通信模组进行拨号
- 支持IPv6
- 支持高通,紫光展锐,联发科等平台的通信模组
- 支持常见厂商的通信模组(例如:移远,广和通等)
# 二、模组支持
下面列出插件支持的模组
| 厂家名称 | 模组名称 | 平台 | 数据传输模式 | 端口模式 |
| -------- | -------------------------------------------------- | -------- | ------------ | ---------------------------- |
| 移远通信 | RG200U-CNDONGLE版 | 紫光展锐 | USB | ECMMBIMRNDISNCM |
| 移远通信 | RM500U-CN | 紫光展锐 | USB | ECMMBIMRNDISNCM |
| 移远通信 | RM500Q-CN | 高通 | USB | RMNETECMMBIMRNDISNCM |
| 移远通信 | RM500Q-AE | 高通 | USB | RMNETECMMBIMRNDISNCM |
| 移远通信 | RM500Q-GL | 高通 | USB | RMNETECMMBIMRNDISNCM |
| 移远通信 | RM502Q-AE | 高通 | USB | RMNETECMMBIMRNDISNCM |
| 移远通信 | RM502Q-GL | 高通 | USB | RMNETECMMBIMRNDISNCM |
| 移远通信 | RM505Q-AE | 高通 | USB | RMNETECMMBIMRNDISNCM |
| 移远通信 | RM520N-CN | 高通 | USB | RMNETECMMBIMRNDISNCM |
| 移远通信 | RM520N-GL | 高通 | USB | RMNETECMMBIMRNDISNCM |
| 移远通信 | RM500Q-GL | 高通 | PCIE | RMNETMBIM |
| 移远通信 | RG500Q-EA | 高通 | PCIE | RMNETMBIM |
| 移远通信 | RM502Q-GL | 高通 | PCIE | RMNETMBIM |
| 移远通信 | RM520N-GL | 高通 | PCIE | RMNETMBIM |
| 移远通信 | RG520N-EU | 高通 | PCIE | RMNETMBIM |
| 广和通 | FM650-CN | 紫光展锐 | USB | ECMMBIMRNDISNCM |
| 广和通 | FM350-GL | 联发科 | USB | RNDIS |
| 广和通 | FM150-AE-01FM150-AE-11FM150-AE-21FM150-NA-01 | 高通 | USB | RMNETECMMBIMRNDISNCM |
| 广和通 | FM350-GL | 联发科 | PCIE | MBIM |
| 广和通 | FM150-AE-00FM150-AE-10FM150-AE-20FM150-NA-00 | 高通 | PCIE | QMI |
| 美格智能 | SRM815 | 高通 | USB | ECMMBIMRNDISNCM |
| 美格智能 | SRM825 | 高通 | USB | ECMMBIMRNDISNCM |
| 美格智能 | SRM825N | 高通 | USB | ECMMBIMRNDISNCM |

View File

@ -1,6 +0,0 @@
#!/bin/sh
host=$1
scp -oHostkeyalgorithms=+ssh-rsa -r luasrc/* root@$host:/usr/lib/lua/luci/
scp -oHostkeyalgorithms=+ssh-rsa -r root/usr/* root@$host:/usr/
scp -oHostkeyalgorithms=+ssh-rsa -r root/etc/init.d/* root@$host:/etc/init.d/
ssh -oHostkeyalgorithms=+ssh-rsa root@$host rm -rf /tmp/luci-indexcache

View File

@ -1,69 +0,0 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
modem_settings()
{
local board="$1"
case $board in
HC,HC-G80)
#mini pci slot
uci set modem.u1_1_4="modem-slot"
uci set modem.u1_1_4.slot="1-1.4"
uci set modem.u1_1_4.type="usb"
uci set modem.u1_1_4.net_led="wwan"
#m.2 slot (usb2.0)
uci set modem.u1_1_1="modem-slot"
uci set modem.u1_1_1.slot="1-1.1"
uci set modem.u1_1_1.type="usb"
uci set modem.u1_1_1.net_led="wwan"
uci set modem.u1_1_1.ethernet="cpewan0"
#m.2 slot (usb3.0)
uci set modem.u2_1="modem-slot"
uci set modem.u2_1.slot="2-1"
uci set modem.u2_1.type="usb"
uci set modem.u2_1.net_led="wwan"
uci set modem.u2_1.ethernet="cpewan0"
uci commit modem
;;
huasifei,ws3006)
#m2 usb3.0
#(slot 2)
uci set modem.u2_1_2="modem-slot"
uci set modem.u2_1_2.slot="2-1.2"
uci set modem.u2_1_2.type="usb"
uci set modem.u2_1_2.net_led="wwan2"
uci set modem.u2_1_2.sim_led="green:sim2"
#(slot 1)
uci set modem.u2_1_4="modem-slot"
uci set modem.u2_1_4.slot="2-1.4"
uci set modem.u2_1_4.type="usb"
uci set modem.u2_1_4.net_led="wwan1"
uci set modem.u2_1_4.sim_led="green:sim1"
#mini pci slot
#(slot 2)
uci set modem.u1_1_2="modem-slot"
uci set modem.u1_1_2.slot="1-1.2"
uci set modem.u1_1_2.type="usb"
uci set modem.u1_1_2.net_led="wwan2"
uci set modem.u1_1_2.sim_led="green:sim2"
#(slot 1)
uci set modem.u1_1_3="modem-slot"
uci set modem.u1_1_3.slot="1-1.3"
uci set modem.u1_1_3.type="usb"
uci set modem.u1_1_3.net_led="wwan1"
uci set modem.u1_1_3.sim_led="green:sim1"
uci commit modem
;;
esac
}
board=$(board_name)
modem_settings $board
exit 0

View File

@ -1,25 +0,0 @@
#!/bin/sh
# Copyright (C) 2023 Siriling <siriling@qq.com>
uci -q get modem.global >/dev/null || uci -q batch <<-EOF >/dev/null
set modem.global=global
set modem.@global[0].enable_dial=1
set modem.@global[0].modem_number=0
set modem.@global[0].manual_configuration=0
commit modem
EOF
/etc/init.d/modeminit enable
/etc/init.d/modem enable
uci -q batch <<-EOF >/dev/null
delete ucitrack.@modem[-1]
add ucitrack modem
set ucitrack.@modem[-1].init=modem
add ucitrack modem
set ucitrack.@modem_mwan[-1].init=modem_mwan
commit ucitrack
EOF
rm -rf /tmp/luci-*cache
exit 0

View File

@ -1,19 +1,19 @@
# Copyright (C) 2024 Tom <fjrcn@outlook.com>
# Copyright (C) 2023 Siriling <siriling@qq.com>
# This is free software, licensed under the GNU General Public License v3.
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-5modem-mwan-single-module
LUCI_TITLE:=Luci modem mwan support
PKG_NAME:=luci-app-qmodem-mwan
LUCI_TITLE:=Luci qwrt modem mwan support
LUCI_PKGARCH:=all
PKG_VERSION:=2.0
PKG_VERSION:=1
PKG_LICENSE:=GPLv3
PKG_LINCESE_FILES:=LICENSE
PKF_MAINTAINER:=fujr
LUCI_DEPENDS:=+luci-app-5gmodem +luci-app-mwan3
PKG_MAINTAINER:=Tom <fjrcn@outlook.com>
LUCI_DEPENDS:=+luci-app-qmodem +luci-app-mwan3
define Package/luci-app-5gmodem-mwan/conffiles
define Package/luci-app-qmodem-mwan/conffiles
/etc/config/modem_mwan
endef

View File

@ -0,0 +1,9 @@
module("luci.controller.qmodem_mwan", package.seeall)
function index()
if not nixio.fs.access("/etc/config/modem_mwan") then
return
end
--mwan配置
entry({"admin", "network", "qmodem", "mwan_config"}, cbi("qmodem/mwan_config"), luci.i18n.translate("Mwan Config"), 21).leaf = true
end

View File

@ -3,7 +3,7 @@
local d = require "luci.dispatcher"
local uci = luci.model.uci.cursor()
local sys = require "luci.sys"
local script_path="/usr/share/modem/"
local script_path="/usr/share/qmodem/"
m = Map("modem_mwan")
m.title = translate("Mwan Config")

View File

@ -0,0 +1,11 @@
config ipv4
list member_track_ip 'test.ustc.edu.cn'
list member_track_ip 'cip.cc'
list member_track_ip '208.67.222.222'
list member_track_ip '208.67.220.220'
list member_interface 'wan'
option member_priority '1'
option member_weight '1'
config global 'global'
option enable_mwan '1'

View File

@ -6,14 +6,14 @@ start_mwan3()
{
proto=$1
logger -t modem_mwan "before set $proto start"
/usr/share/modem/modem_mwan.sh $proto start
/usr/share/qmodem/modem_mwan.sh $proto start
logger -t modem_mwan "set $proto start"
}
start_service() {
logger -t modem_mwan "start modem_mwan"
config_load modem_mwan
logger -t modem_mwan "start qmodem_mwan"
config_load qmodem_mwan
config_get enable global enable_mwan 0
if [ "$enable" = "0" ]; then
stop_service
@ -22,11 +22,11 @@ start_service() {
}
stop_service() {
/usr/share/modem/modem_mwan.sh ipv4 stop
/usr/share/qmodem/modem_mwan.sh ipv4 stop
}
service_triggers() {
procd_add_reload_trigger 'modem_mwan'
procd_add_reload_trigger 'qmodem_mwan'
}
reload_service() {

View File

@ -0,0 +1,50 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
modem_settings()
{
local board="$1"
case $board in
HC,HC-G80)
add_ipv4_config "1_1_1"
add_ipv4_config "1_1_4"
add_ipv4_config "2_1"
uci commit qmodem_mwan
;;
huasifei,ws3006)
add_ipv4_config "2_1_2"
add_ipv4_config "2_1_4"
add_ipv4_config "1_1_1"
add_ipv4_config "1_1_2"
add_ipv4_config "1_1_3"
uci commit qmodem_mwan
;;
esac
}
add_ipv4_config(){
local interface_name="$1"
cfg=$(uci add qmodem_mwan ipv4)
uci batch<<-EOF >/dev/null
set qmodem_mwan.$cfg.member_interface=$interface_name
set qmodem_mwan.$cfg.member_priority=2
set qmodem_mwan.$cfg.member_weight=1
add_list qmodem_mwan.$cfg.member_track_ip='test.ustc.edu.cn'
add_list qmodem_mwan.$cfg.member_track_ip='cip.cc'
add_list qmodem_mwan.$cfg.member_track_ip='208.67.220.220'
add_list qmodem_mwan.$cfg.member_track_ip='208.67.222.222'
EOF
}
board=$(board_name)
modem_settings $board
exit 0

View File

@ -0,0 +1,10 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
add ucitrack qmodem_mwan
set ucitrack.@qmodem_mwan[-1].init=qmodem_mwan
commit ucitrack
EOF
rm -rf /tmp/luci-*cache
exit 0

View File

@ -1,16 +1,16 @@
# Copyright (C) 2024 Tom <fjrcn@outlook.com>
# Copyright (C) 2023 Siriling <siriling@qq.com>
# This is free software, licensed under the GNU General Public License v3.
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-5gmodem-sms
LUCI_TITLE:=Luci modem sms support
PKG_NAME:=luci-app-qmodem-sms
LUCI_TITLE:=Luci qwrt modem sms support
LUCI_PKGARCH:=all
PKG_VERSION:=2.0
PKG_VERSION:=1
PKG_LICENSE:=GPLv3
PKG_LINCESE_FILES:=LICENSE
PKF_MAINTAINER:=fujr
LUCI_DEPENDS:=+luci-app-5gmodem
PKG_MAINTAINER:=Tom <fjrcn@outlook.com>
LUCI_DEPENDS:=+luci-app-qmodem
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -1,8 +1,8 @@
module("luci.controller.modem_sms", package.seeall)
module("luci.controller.qmodem_sms", package.seeall)
local http = require "luci.http"
local fs = require "nixio.fs"
local json = require("luci.jsonc")
local modem_ctrl = "/usr/share/modem/modem_ctrl.sh "
local modem_ctrl = "/usr/share/qmodem/modem_ctrl.sh "
function shell(command)
local odpall = io.popen(command)
@ -13,10 +13,10 @@ end
function index()
--sim卡配置
entry({"admin", "network", "modem", "modem_sms"},template("modem_sms/modem_sms"), luci.i18n.translate("SMS"), 11).leaf = true
entry({"admin", "network", "modem", "send_sms"}, call("sendSMS"), nil).leaf = true
entry({"admin", "network", "modem", "get_sms"}, call("getSMS"), nil).leaf = true
entry({"admin", "network", "modem", "delete_sms"}, call("delSMS"), nil).leaf = true
entry({"admin", "network", "qmodem", "modem_sms"},template("modem_sms/modem_sms"), luci.i18n.translate("SMS"), 11).leaf = true
entry({"admin", "network", "qmodem", "send_sms"}, call("sendSMS"), nil).leaf = true
entry({"admin", "network", "qmodem", "get_sms"}, call("getSMS"), nil).leaf = true
entry({"admin", "network", "qmodem", "delete_sms"}, call("delSMS"), nil).leaf = true
end
function getSMS()

View File

@ -456,7 +456,7 @@ class LuciTable{
cell_left.classList.add("td")
cell_left.setAttribute("width","33%")
let cell_right = document.createElement('td');
cell_right.classList.add("td")
cell_right.classList.add("td");
row.appendChild(cell_left);
row.appendChild(cell_right);
this.tbody.appendChild(row);
@ -493,6 +493,7 @@ class LuciTable{
cell_left.classList.add("td")
cell_left.setAttribute("width","33%")
let cell_right = document.createElement('td');
cell_right.classList.add("sms_recv_content")
cell_right.classList.add("td")
row.appendChild(cell_left);
row.appendChild(cell_right);
@ -608,7 +609,7 @@ class ModemSMS {
send_gsm(){
var phone_number = this.phone_number.value;
var message_content = this.message_content.value;
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "send_sms")%>',{
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "send_sms")%>',{
"cfg": this.cfg_id,
"phone_number": phone_number,
"message_content": message_content,
@ -630,7 +631,7 @@ class ModemSMS {
if (Array.isArray(pdu)) {
pdu = pdu[0];
}
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "send_sms")%>',{
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "send_sms")%>',{
"cfg": this.cfg_id,
"pdu": pdu,
},(x,data)=>{
@ -694,7 +695,7 @@ class ModemSMS {
if (this.cfg_id == null){
return;
}
XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "network", "modem", "get_sms")%>',{
XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_sms")%>',{
"cfg": this.cfg_id,
}, (x,data) => {
@ -703,7 +704,7 @@ class ModemSMS {
}
update(){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "get_sms")%>',{
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_sms")%>',{
"cfg": this.cfg_id,
}, (x,data) => {
this.combine_messages(data);
@ -711,7 +712,7 @@ class ModemSMS {
}
update_modem_cfg_list(){
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modem_cfg")%>',{},(x,data)=>{
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_modem_cfg")%>',{},(x,data)=>{
var new_cfg_list = [];
var cfgs = data.cfgs;
for (let i = 0; i < cfgs.length; i++) {
@ -844,7 +845,7 @@ class ModemSMS {
delete_btn.value = "<%:Delete%>";
delete_btn.addEventListener('click',()=>{
this.lock();
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "delete_sms")%>',{
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "delete_sms")%>',{
"cfg": this.cfg_id,
"index": index.sort((a,b)=>{return b-a}).join(" "),
},(x,data)=>{
@ -889,6 +890,15 @@ window.onload = function(){
const getSMS = new ModemSMS();
}
</script>
<style>
.sms_recv_content {
text-align: left;
word-wrap: break-word;
white-space: normal;
overflow-wrap: break-word;
}
</style>
<div>
<div class="cbi-map">
<fieldset class="cbi-section">

View File

@ -1,19 +1,19 @@
# Copyright (C) 2024 Tom <fjrcn@outlook.com>
# Copyright (C) 2023 Siriling <siriling@qq.com>
# This is free software, licensed under the GNU General Public License v3.
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-5gmodem-ttl
LUCI_TITLE:=Luci modem ttl support
PKG_NAME:=luci-app-qmodem-ttl
LUCI_TITLE:=Luci qwrt modem ttl support
LUCI_PKGARCH:=all
PKG_VERSION:=2.0
PKG_VERSION:=1
PKG_LICENSE:=GPLv3
PKG_LINCESE_FILES:=LICENSE
PKF_MAINTAINER:=fujr
LUCI_DEPENDS:=+luci-app-5gmodem
PKG_MAINTAINER:=Tom <fjrcn@outlook.com>
LUCI_DEPENDS:=+luci-app-qmodem
define Package/luci-app-5gmodem-ttl/conffiles
define Package/luci-app-qmodem-ttl/conffiles
/etc/config/modem_ttl
endef

View File

@ -0,0 +1,8 @@
-- Copyright 2024 Siriling <siriling@qq.com>
module("luci.controller.qmodem_ttl", package.seeall)
function index()
if not nixio.fs.access("/etc/config/qmodem_ttl") then
return
end
entry({"admin", "network", "qmodem", "modem_ttl"}, cbi("qmodem/modem_ttl"), luci.i18n.translate("TTL Config"), 22).leaf = true
end

View File

@ -1,4 +1,4 @@
m = Map("modem_ttl", translate("TTL Config"))
m = Map("qmodem_ttl", translate("TTL Config"))
s = m:section(NamedSection, "global", "global", translate("Global Config"))
enable = s:option(Flag, "enable", translate("Enable"))

View File

@ -7,7 +7,7 @@ USE_PROCD=1
. /lib/functions.sh
start_service()
{
config_load 'modem_ttl'
config_load 'qmodem_ttl'
config_get enable 'global' 'enable' '0'
if [ "$enable" == 0 ]; then
return
@ -53,7 +53,7 @@ stop_service(){
service_triggers()
{
procd_add_reload_trigger "modem_ttl"
procd_add_reload_trigger "qmodem_ttl"
procd_add_reload_trigger "network"
#netdev
}

View File

@ -1,22 +1,19 @@
# Copyright (C) 2023 Siriling <siriling@qq.com>
# Copyright (C) 2024 Tom <fjrcn@outlook.com>
# This is free software, licensed under the GNU General Public License v3.
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-5gmodem
LUCI_TITLE:=LuCI support for Modem
PKG_NAME:=luci-app-qmodem
LUCI_TITLE:=LuCI support for QWRT Modem
LUCI_PKGARCH:=all
PKG_VERSION:=2.0
PKG_VERSION:=2.1
PKG_LICENSE:=GPLv3
PKG_LINCESE_FILES:=LICENSE
PKF_MAINTAINER:=Tom <fjrcn@outlook.com>
LUCI_DEPENDS:=+luci-compat +kmod-usb-net +kmod-usb-net-cdc-ether +kmod-usb-acm \
PKG_MAINTAINER:=Tom <fjrcn@outlook.com>
LUCI_DEPENDS:=+luci-compat \
+kmod-usb-net-rndis \
+kmod-usb-net-sierrawireless +kmod-usb-ohci\
+kmod-usb-serial-option +kmod-usb-wdm \
+kmod-usb2 +kmod-usb3 \
+kmod-usb-net-sierrawireless +kmod-usb-ohci \
+kmod-usb-serial-option +kmod-usb-serial +kmod-usb-serial-qualcomm \
+kmod-usb-net +kmod-usb-acm \
+kmod-usb-wdm +kmod-usb-net-qmi-wwan \
@ -28,12 +25,12 @@ LUCI_DEPENDS:=+luci-compat +kmod-usb-net +kmod-usb-net-cdc-ether +kmod-usb-acm \
+kmod-pcie_mhi \
+pciutils \
+quectel-CM-5G \
+sms-tool \
+jq +grep +bc\
+sms-tool_q \
+jq +bc\
+coreutils +coreutils-stat
define Package/luci-app-5gmodem/conffiles
define Package/luci-app-qmodem/conffiles
/etc/config/modem
endef

View File

@ -1,31 +1,31 @@
-- Copyright 2024 Siriling <siriling@qq.com>
module("luci.controller.modem", package.seeall)
module("luci.controller.qmodem", package.seeall)
local http = require "luci.http"
local fs = require "nixio.fs"
local json = require("luci.jsonc")
uci = luci.model.uci.cursor()
local script_path="/usr/share/modem/"
local run_path="/tmp/run/modem/"
local modem_ctrl = "/usr/share/modem/modem_ctrl.sh "
local script_path="/usr/share/qmodem/"
local run_path="/tmp/run/qmodem/"
local modem_ctrl = "/usr/share/qmodem/modem_ctrl.sh "
function index()
if not nixio.fs.access("/etc/config/modem") then
if not nixio.fs.access("/etc/config/qmodem") then
return
end
entry({"admin", "network", "modem"}, alias("admin", "network", "modem", "modem_info"), luci.i18n.translate("Modem"), 100).dependent = true
entry({"admin", "network", "qmodem"}, alias("admin", "network", "qmodem", "modem_info"), luci.i18n.translate("QModem"), 100).dependent = true
--模块信息
entry({"admin", "network", "modem", "modem_info"}, template("modem/modem_info"), luci.i18n.translate("Modem Information"),2).leaf = true
entry({"admin", "network", "modem", "get_modem_cfg"}, call("getModemCFG"), nil).leaf = true
entry({"admin", "network", "modem", "modem_ctrl"}, call("modemCtrl")).leaf = true
entry({"admin", "network", "qmodem", "modem_info"}, template("qmodem/modem_info"), luci.i18n.translate("QModem Information"),2).leaf = true
entry({"admin", "network", "qmodem", "get_modem_cfg"}, call("getModemCFG"), nil).leaf = true
entry({"admin", "network", "qmodem", "modem_ctrl"}, call("modemCtrl")).leaf = true
--拨号配置
entry({"admin", "network", "modem", "dial_overview"},cbi("modem/dial_overview"),luci.i18n.translate("Dial Overview"),3).leaf = true
entry({"admin", "network", "modem", "dial_config"}, cbi("modem/dial_config")).leaf = true
entry({"admin", "network", "modem", "modems_dial_overview"}, call("getOverviews"), nil).leaf = true
entry({"admin", "network", "qmodem", "dial_overview"},cbi("qmodem/dial_overview"),luci.i18n.translate("Dial Overview"),3).leaf = true
entry({"admin", "network", "qmodem", "dial_config"}, cbi("qmodem/dial_config")).leaf = true
entry({"admin", "network", "qmodem", "modems_dial_overview"}, call("getOverviews"), nil).leaf = true
--模块调试
entry({"admin", "network", "modem", "modem_debug"},template("modem/modem_debug"),luci.i18n.translate("Modem Debug"),4).leaf = true
entry({"admin", "network", "modem", "send_at_command"}, call("sendATCommand"), nil).leaf = true
entry({"admin", "network", "modem", "modem_scan"}, call("modemScan"), nil).leaf = true
entry({"admin", "network", "qmodem", "modem_debug"},template("qmodem/modem_debug"),luci.i18n.translate("QModem Debug"),4).leaf = true
entry({"admin", "network", "qmodem", "send_at_command"}, call("sendATCommand"), nil).leaf = true
entry({"admin", "network", "qmodem", "modem_scan"}, call("modemScan"), nil).leaf = true
end
--[[
@ -102,9 +102,10 @@ function getOverviews()
-- 获取所有模组
local modems={}
local logs={}
uci:foreach("modem", "modem-device", function (modem_device)
uci:foreach("qmodem", "modem-device", function (modem_device)
section_name = modem_device[".name"]
modem_name = modem_device["name"]
alias = modem_device["alias"]
modem_state = modem_device["state"]
if modem_state == "disabled" then
return
@ -115,10 +116,15 @@ function getOverviews()
json_result = json.parse(result)
modem_info = json_result["modem_info"]
tmp_info = {}
if alias then
title = alias .. "("..modem_name..")"
else
title = modem_name
end
name = {
type = "plain_text",
key = "name",
value = modem_name
value = title
}
table.insert(tmp_info, name)
for k,v in pairs(modem_info) do
@ -136,7 +142,11 @@ function getOverviews()
modem_log = {}
modem_log["log_msg"] = log_msg
modem_log["section_name"] = section_name
if alias then
modem_log["name"] = alias .. "("..modem_name..")"
else
modem_log["name"] = modem_name
end
table.insert(logs, modem_log)
end
end)
@ -154,21 +164,25 @@ function getModemCFG()
local cfgs={}
local translation={}
uci:foreach("modem", "modem-device", function (modem_device)
uci:foreach("qmodem", "modem-device", function (modem_device)
modem_state = modem_device["state"]
if modem_state == "disabled" then
return
end
--获取模组的备注
local network=modem_device["network"]
local remarks=modem_device["remarks"]
local alias=modem_device["alias"]
local config_name=modem_device[".name"]
--设置模组AT串口
local cfg = modem_device[".name"]
local at_port=modem_device["at_port"]
local name=modem_device["name"]:upper()
local config = {}
if alias then
config["name"] = alias .. "("..name..")"
else
config["name"] = name
end
config["at_port"] = at_port
config["cfg"] = cfg
table.insert(cfgs, config)

View File

@ -2,8 +2,8 @@ local dispatcher = require "luci.dispatcher"
local uci = require "luci.model.uci".cursor()
local http = require "luci.http"
m = Map("modem", translate("Dial Config"))
m.redirect = dispatcher.build_url("admin", "network", "modem","dial_overview")
m = Map("qmodem", translate("Dial Config"))
m.redirect = dispatcher.build_url("admin", "network", "qmodem","dial_overview")
s = m:section(NamedSection, arg[1], "modem-device", "")
s.addremove = false
@ -18,9 +18,9 @@ enable = s:taboption("general", Flag, "enable_dial", translate("enable_dial"))
enable.default = "0"
enable.rmempty = false
-- 备注
remarks = s:taboption("general", Value, "remarks", translate("Remarks"))
remarks.rmempty = true
-- 别名
alias = s:taboption("general", Value, "alias", translate("Alias"))
alias.rmempty = true
-- AT串口
at_port = s:taboption("general",Value, "at_port", translate("AT Port"))
@ -31,6 +31,10 @@ ra_master = s:taboption("advanced", Flag, "ra_master", translate("RA Master"))
ra_master.description = translate("After checking, This interface will enable IPV6 RA Master.Only one interface can be set to RA Master.")
ra_master.default = "0"
extend_prefix = s:taboption("advanced", Flag, "extend_prefix", translate("Extend Prefix"))
extend_prefix.description = translate("After checking, the prefix will be apply to lan zone")
extend_prefix.default = "0"
-- 网络类型
pdp_type= s:taboption("advanced", ListValue, "pdp_type", translate("PDP Type"))
pdp_type.default = "ipv4v6"

View File

@ -2,7 +2,7 @@ local d = require "luci.dispatcher"
local uci = luci.model.uci.cursor()
local sys = require "luci.sys"
m = Map("modem")
m = Map("qmodem")
m.title = translate("Dial Overview")
m.description = translate("Check and add modem dialing configurations")
@ -13,7 +13,7 @@ s.addremove = false
-- 模组扫描
o = s:option(Button, "modem_scan", translate("Modem Scan"))
o.template = "modem/modem_scan"
o.template = "qmodem/modem_scan"
-- 启用手动配置
o = s:option(Flag, "manual_configuration", translate("Manual Configuration"))
@ -29,14 +29,14 @@ o = s:option(Button, "reload_dial", translate("Reload Dial Configurations"))
o.inputstyle = "apply"
o.description = translate("Manually Reload dial configurations When the dial configuration fails to take effect")
o.write = function()
sys.call("/etc/init.d/modem_network reload")
luci.http.redirect(d.build_url("admin", "network", "modem", "dial_overview"))
sys.call("/etc/init.d/qmodem_network reload")
luci.http.redirect(d.build_url("admin", "network", "qmodem", "dial_overview"))
end
s = m:section(TypedSection, "modem-device", translate("Config List"))
s.addremove = ture
s.template = "cbi/tblsection"
s.extedit = d.build_url("admin", "network", "modem", "dial_config", "%s")
s.extedit = d.build_url("admin", "network", "qmodem", "dial_config", "%s")
o = s:option(Flag, "enable_dial", translate("enable_dial"))
o.width = "5%"
@ -48,7 +48,12 @@ o.cfgvalue = function(t, n)
return name:upper()
end
o = s:option(DummyValue, "remarks", translate("Remarks"))
o = s:option(DummyValue, "alias", translate("Alias"))
o.cfgvalue = function(t, n)
local alias = (Value.cfgvalue(t, n) or "-")
return alias
end
o = s:option(DummyValue, "state", translate("Modem Status"))
o.cfgvalue = function(t, n)
@ -85,13 +90,13 @@ remove_btn = s:option(Button, "_remove", translate("Remove"))
remove_btn.inputstyle = "remove"
function remove_btn.write(self, section)
local shell
shell="/usr/share/modem/modem_scan.sh remove "..section
shell="/usr/share/qmodem/modem_scan.sh remove "..section
luci.sys.call(shell)
--refresh the page
luci.http.redirect(d.build_url("admin", "network", "modem", "dial_overview"))
luci.http.redirect(d.build_url("admin", "network", "qmodem", "dial_overview"))
end
-- 添加模块拨号日志
m:append(Template("modem/dial_overview"))
m:append(Template("qmodem/dial_overview"))
return m

View File

@ -170,7 +170,7 @@
}
clear(){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "modem_ctrl")%>', {"action":"clear_dial_log","cfg":this.section_name},
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>', {"action":"clear_dial_log","cfg":this.section_name},
function(x, data)
{
var state = data.result.state;
@ -235,7 +235,7 @@
poll()
{
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "modem", "modems_dial_overview")%>',{},
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modems_dial_overview")%>',{},
(x,data)=>{
this.update_modems_state(data.modems);
this.update_modems_log(data.logs);

View File

@ -18,7 +18,7 @@
}
get_config(){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "modem_ctrl")%>',
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>',
{
"cfg": this.cfg_id,
"action": this.get_action
@ -33,7 +33,7 @@
}
set_config(config){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "modem_ctrl")%>',
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>',
{
"cfg": this.cfg_id,
"action": this.set_action,
@ -852,7 +852,7 @@
}
update_modem_cfg_list() {
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modem_cfg")%>', {}, (x, data) => {
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_modem_cfg")%>', {}, (x, data) => {
var new_cfg_list = [];
var cfgs = data.cfgs;
for (let i = 0; i < cfgs.length; i++) {
@ -975,6 +975,11 @@
}
</script>
<style>
.cbi-tabmenu li {
padding: 0.5rem;
}
</style>
<div class="cbi-map">
<fieldset class="cbi-section">
<table class="table">

View File

@ -229,7 +229,7 @@ class ModemInfo {
if (this.cfg_id == null){
return;
}
XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "network", "modem", "modem_ctrl")%>',{
XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>',{
"cfg": this.cfg_id,
"action": "info",
"translate": "1"
@ -239,7 +239,7 @@ class ModemInfo {
}
update(){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "modem_ctrl")%>',{
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>',{
"cfg": this.cfg_id,
"action": "info",
"translate": "1"
@ -249,7 +249,7 @@ class ModemInfo {
}
update_modem_cfg_list(){
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modem_cfg")%>',{},(x,data)=>{
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_modem_cfg")%>',{},(x,data)=>{
var new_cfg_list = [];
var cfgs = data.cfgs;
for (let i = 0; i < cfgs.length; i++) {

View File

@ -22,11 +22,11 @@ function modem_scan()
var description='<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>"/><%:Scaning modem...%>'
document.getElementById('modem_scan_description').innerHTML=description;
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "modem_scan")%>', null,
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_scan")%>', null,
function(x, data)
{
// console.log(data);
location.href='/cgi-bin/luci/admin/network/modem/plugin_config'
location.href='/cgi-bin/luci/admin/network/qmodem/dial_overview'
//启用功能
// disabled_function("modem_scan",false);

View File

@ -19,8 +19,8 @@ msgstr ""
msgid "Base Setting"
msgstr "基本设置"
msgid "Modem"
msgstr "移动通信模组"
msgid "QModem"
msgstr "QWRT模组管理"
msgid "Modem Config"
msgstr "模组配置"
@ -31,7 +31,7 @@ msgstr "模组状态"
msgid "Modem Name"
msgstr "模组名称"
msgid "Modem Debug"
msgid "QModem Debug"
msgstr "模组调试"
msgid "Modem Select"
@ -193,7 +193,7 @@ msgstr "描述"
msgid "Command"
msgstr "命令"
msgid "Modem Information"
msgid "QModem Information"
msgstr "模组信息"
msgid "No modems found"
@ -834,9 +834,6 @@ msgstr "警告!"
msgid "PIN Code"
msgstr "PIN码"
msgid "If solt 2 config is not set,will use slot 1 config."
msgstr "如果未设置卡槽2配置将使用卡槽1配置。"
msgid "If the PIN code is not set, leave it blank."
msgstr "如果未设置PIN码请留空。"
@ -857,3 +854,12 @@ msgstr "已启用"
msgid "disabled"
msgstr "已禁用"
msgid "Extend Prefix"
msgstr "扩展前缀"
msgid "After checking, the prefix will be apply to lan zone"
msgstr "勾选后前缀将应用到LAN区域"
msgid "alias"
str "别名"

View File

@ -19,8 +19,8 @@ msgstr ""
msgid "Base Setting"
msgstr "基本设置"
msgid "Modem"
msgstr "移动通信模组"
msgid "QModem"
msgstr "QWRT模组管理"
msgid "Modem Config"
msgstr "模组配置"
@ -31,7 +31,7 @@ msgstr "模组状态"
msgid "Modem Name"
msgstr "模组名称"
msgid "Modem Debug"
msgid "QModem Debug"
msgstr "模组调试"
msgid "Modem Select"
@ -193,7 +193,7 @@ msgstr "描述"
msgid "Command"
msgstr "命令"
msgid "Modem Information"
msgid "QModem Information"
msgstr "模组信息"
msgid "No modems found"
@ -854,3 +854,12 @@ msgstr "已启用"
msgid "disabled"
msgstr "已禁用"
msgid "Extend Prefix"
msgstr "扩展前缀"
msgid "After checking, the prefix will be apply to lan zone"
msgstr "勾选后前缀将应用到LAN区域"
msgid "alias"
str "别名"

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (C) 2024 Tom <fjrcn@outlook.com>
manual=$(uci get -q modem.global.manual_configuration)
manual=$(uci get -q qmodem.global.manual_configuration)
[ "${manual}" -eq 1 ] && exit
logger -t modem_hotplug "net slot: ${DEVPATH} action: ${ACTION}"
#网络设备名称不存在,退出
@ -20,6 +20,6 @@ slot=$(basename "${slot_dir}")
logger -t modem_hotplug "net slot: ${slot} action: ${ACTION} slot_type: ${slot_type}"
case "${ACTION}" in
add)
/usr/share/modem/modem_scan.sh add "${slot}" "${slot_type}"
/usr/share/qmodem/modem_scan.sh add "${slot}" "${slot_type}"
;;
esac

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (C) 2024 Tom <fjrcn@outlook.com>
manual=$(uci get -q modem.global.manual_configuration)
manual=$(uci get -q qmodem.global.manual_configuration)
[ "${manual}" -eq 1 ] && exit
logger -t modem_hotplug "usb_event slot: ${DEVPATH} action: ${ACTION}"
[ -z "${DEVNUM}" ] && exit
@ -11,9 +11,9 @@ logger -t modem_hotplug "usb_event run slot: ${slot} action: ${ACTION}"
case "${ACTION}" in
bind|\
add)
/usr/share/modem/modem_scan.sh add "${slot}" usb
/usr/share/qmodem/modem_scan.sh add "${slot}" usb
;;
remove)
/usr/share/modem/modem_scan.sh disable "${slot}" usb
/usr/share/qmodem/modem_scan.sh disable "${slot}" usb
;;
esac

View File

@ -7,11 +7,12 @@ USE_PROCD=1
start_service() {
config_load modem
config_load qmodem
config_foreach mk_rundir modem-device
config_get manual_configuration global manual_configuration
[ "$manual_configuration" -eq 1 ] && return
logger -t modem_init "modem init"
config_foreach try_modem_device modem-device
config_foreach try_modem modem-slot
}
@ -43,3 +44,11 @@ try_modem()
/usr/share/modem/modem_scan.sh disable "$slot"
fi
}
try_modem_device()
{
config_get path "$1" path
if [ ! -d "$path" ]; then
/usr/share/modem/modem_scan.sh disable "$1"
fi
}

View File

@ -4,14 +4,14 @@ STOP=13
USE_PROCD=1
#脚本目录
SCRIPT_DIR="/usr/share/modem"
SCRIPT_DIR="/usr/share/qmodem"
#运行目录
MODEM_RUNDIR="/var/run/modem"
MODEM_RUNDIR="/var/run/qmodem"
service_triggers()
{
procd_add_reload_trigger "modem"
procd_add_reload_trigger "qmodem"
}
@ -19,7 +19,7 @@ start_service() {
mkdir -p $MODEM_RUNDIR
#加载模组配置
config_load modem
config_load qmodem
config_get enabled global enable_dial
[ "$enabled" = "0" ] && config_foreach hang_modem modem-device && stop
config_foreach run_modem modem-device
@ -34,7 +34,7 @@ reload_service()
stop_service()
{
#清理运行目录
config_load modem
config_load qmodem
config_foreach hang_modem modem-device
}
@ -42,13 +42,17 @@ stop_service()
run_modem()
{
config_get state $1 state
if [ "$state" = "disabled" ] ;then
return
fi
config_get enabled $1 enable_dial
if [ "$enabled" = "0" ] ;then
hang_modem $1
return
fi
procd_open_instance "modem_$1"
procd_set_param command "/usr/share/modem/modem_dial.sh" "$1" dial
procd_set_param command "/usr/share/qmodem/modem_dial.sh" "$1" dial
procd_set_param respawn
procd_close_instance
logger -t modem_network "dial modem $1"
@ -57,6 +61,6 @@ run_modem()
hang_modem()
{
service_stop "modem_$1"
"/usr/share/modem/modem_dial.sh" "$1" hang
"/usr/share/qmodem/modem_dial.sh" "$1" hang
logger -t modem_network "hang modem $1"
}

View File

@ -0,0 +1,82 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
modem_settings()
{
local board="$1"
case $board in
HC,HC-G80)
#mini pci slot
uci set qmodem.u1_1_4="modem-slot"
uci set qmodem.u1_1_4.slot="1-1.4"
uci set qmodem.u1_1_4.type="usb"
uci set qmodem.u1_1_4.net_led="wwan"
#m.2 slot (usb2.0)
uci set qmodem.u1_1_1="modem-slot"
uci set qmodem.u1_1_1.slot="1-1.1"
uci set qmodem.u1_1_1.type="usb"
uci set qmodem.u1_1_1.net_led="wwan"
uci set qmodem.u1_1_1.ethernet="cpewan0"
#m.2 slot (usb3.0)
uci set qmodem.u2_1="modem-slot"
uci set qmodem.u2_1.slot="2-1"
uci set qmodem.u2_1.type="usb"
uci set qmodem.u2_1.net_led="wwan"
uci set qmodem.u2_1.ethernet="cpewan0"
uci commit qmodem
;;
huasifei,ws3006)
#m2 usb3.0
#(slot 2)
uci set qmodem.u2_1_2="modem-slot"
uci set qmodem.u2_1_2.slot="2-1.2"
uci set qmodem.u2_1_2.type="usb"
uci set qmodem.u2_1_2.net_led="wwan2"
uci set qmodem.u2_1_2.sim_led="green:sim2"
#(slot 1)
uci set qmodem.u2_1_4="modem-slot"
uci set qmodem.u2_1_4.slot="2-1.4"
uci set qmodem.u2_1_4.type="usb"
uci set qmodem.u2_1_4.net_led="wwan1"
uci set qmodem.u2_1_4.sim_led="green:sim1"
#m2 usb2.0
#(slot 2)
uci set qmodem.u1_1_2="modem-slot"
uci set qmodem.u1_1_2.slot="1-1.1"
uci set qmodem.u1_1_2.type="usb"
uci set qmodem.u1_1_2.net_led="wwan2"
uci set qmodem.u1_1_2.sim_led="green:sim2"
#(slot 1)
uci set qmodem.u1_1_4="modem-slot"
uci set qmodem.u1_1_4.slot="1-1.4"
uci set qmodem.u1_1_4.type="usb"
uci set qmodem.u1_1_4.net_led="wwan1"
uci set qmodem.u1_1_4.sim_led="green:sim1"
#mini pci slot
#(slot 2)
uci set qmodem.u1_1_2="modem-slot"
uci set qmodem.u1_1_2.slot="1-1.2"
uci set qmodem.u1_1_2.type="usb"
uci set qmodem.u1_1_2.net_led="wwan2"
uci set qmodem.u1_1_2.sim_led="green:sim2"
#(slot 1)
uci set qmodem.u1_1_3="modem-slot"
uci set qmodem.u1_1_3.slot="1-1.3"
uci set qmodem.u1_1_3.type="usb"
uci set qmodem.u1_1_3.net_led="wwan1"
uci set qmodem.u1_1_3.sim_led="green:sim1"
uci commit qmodem
;;
esac
}
board=$(board_name)
modem_settings $board
exit 0

View File

@ -0,0 +1,17 @@
#!/bin/sh
# Copyright (C) 2024 Tom <fjrcn@outlook.com>
/etc/init.d/modeminit enable
/etc/init.d/modem enable
uci -q batch <<-EOF >/dev/null
delete ucitrack.@qmodem[-1]
add ucitrack qmodem
set ucitrack.@qmodem[-1].init=qmodem_network
add ucitrack qmodem
set ucitrack.@qmodem_mwan[-1].init=qmodem_mwan
commit ucitrack
EOF
rm -rf /tmp/luci-*cache
exit 0

View File

@ -2,21 +2,21 @@
. /lib/functions.sh
info()
{
state=$(uci get modem.$1.state)
state=$(uci get qmodem.$1.state)
if [ "$state" = "disabled" ]; then
return
fi
info=$(/usr/share/modem/modem_ctrl.sh info $1)
info=$(/usr/share/qmodem/modem_ctrl.sh info $1)
json_array=$(echo $json_array | jq ". += [ $info ]")
}
sim_info()
{
state=$(uci get modem.$1.state)
state=$(uci get qmodem.$1.state)
if [ "$state" = "disabled" ]; then
return
fi
/usr/share/modem/modem_ctrl.sh sim_info $1
/usr/share/qmodem/modem_ctrl.sh sim_info $1
}
base_info()
@ -25,26 +25,26 @@ base_info()
if [ "$state" = "disabled" ]; then
return
fi
/usr/share/modem/modem_ctrl.sh base_info $1
/usr/share/qmodem/modem_ctrl.sh base_info $1
}
network_info()
{
state=$(uci get modem.$1.state)
state=$(uci get qmodem.$1.state)
if [ "$state" = "disabled" ]; then
return
fi
/usr/share/modem/modem_ctrl.sh network_info $1
/usr/share/qmodem/modem_ctrl.sh network_info $1
}
cell_info()
{
state=$(uci get modem.$1.state)
state=$(uci get qmodem.$1.state)
if [ "$state" = "disabled" ]; then
return
fi
/usr/share/modem/modem_ctrl.sh cell_info $1
/usr/share/qmodem/modem_ctrl.sh cell_info $1
}
case "$1" in
list)
@ -54,24 +54,24 @@ case "$1" in
case "$2" in
"info")
json_array="[]"
config_load modem
config_load qmodem
config_foreach info modem-device
echo "{\"info\":$json_array}"
;;
"base_info")
config_load modem
config_load qmodem
config_foreach base_info modem-device
;;
"sim_info")
config_load modem
config_load qmodem
config_foreach sim_info modem-device
;;
"network_info")
config_load modem
config_load qmodem
config_foreach network_info modem-device
;;
"cell_info")
config_load modem
config_load qmodem
config_foreach cell_info modem-device
;;
esac

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (C) 2023 Siriling <siriling@qq.com>
source /usr/share/modem/generic.sh
source /usr/share/qmodem/generic.sh
debug_subject="fibocom_ctrl"
#获取拨号模式
# $1:AT串口
@ -57,7 +57,7 @@ get_mode()
mode="$mode_num"
;;
esac
available_modes=$(uci -q get modem.$config_section.modes)
available_modes=$(uci -q get qmodem.$config_section.modes)
json_add_object "mode"
for available_mode in $available_modes; do
if [ "$mode" = "$available_mode" ]; then

View File

@ -1,5 +1,5 @@
#!/bin/sh
SCRIPT_DIR="/usr/share/modem"
SCRIPT_DIR="/usr/share/qmodem"
source /usr/share/libubox/jshn.sh
source "${SCRIPT_DIR}/modem_util.sh"
add_plain_info_entry()

View File

@ -2,23 +2,23 @@
source /usr/share/libubox/jshn.sh
method=$1
config_section=$2
at_port=$(uci get modem.$config_section.at_port)
vendor=$(uci get modem.$config_section.manufacturer)
platform=$(uci get modem.$config_section.platform)
define_connect=$(uci get modem.$config_section.define_connect)
at_port=$(uci get qmodem.$config_section.at_port)
vendor=$(uci get qmodem.$config_section.manufacturer)
platform=$(uci get qmodem.$config_section.platform)
define_connect=$(uci get qmodem.$config_section.define_connect)
[ -z "$define_connect" ] && {
define_connect="1"
}
case $vendor in
"quectel")
. /usr/share/modem/quectel.sh
. /usr/share/qmodem/quectel.sh
;;
"fibocom")
. /usr/share/modem/fibocom.sh
. /usr/share/qmodem/fibocom.sh
;;
*)
. /usr/share/modem/generic.sh
. /usr/share/qmodem/generic.sh
;;
esac
@ -48,7 +48,7 @@ get_sms(){
file_time=$(stat -t $cache_file | awk '{print $14}')
if [ ! -f $cache_file ] || [ $(($current_time - $file_time)) -gt $cache_timeout ]; then
touch $cache_file
sms_tool -d $at_port -j recv > $cache_file
sms_tool_q -d $at_port -j recv > $cache_file
cat $cache_file
else
cat $cache_file
@ -63,7 +63,7 @@ json_close_object
case $method in
"clear_dial_log")
json_select result
log_file="/var/run/modem/${config_section}_dir/dial_log"
log_file="/var/run/qmodem/${config_section}_dir/dial_log"
[ -f $log_file ] && echo "" > $log_file && json_add_string status "1" || json_add_string status "0"
json_close_object
;;
@ -128,11 +128,11 @@ case $method in
cmd_json=$3
phone_number=$(echo $cmd_json | jq -r '.phone_number')
message_content=$(echo $cmd_json | jq -r '.message_content')
sms_tool -d $at_port send "$phone_number" "$message_content" > /dev/null
sms_tool_q -d $at_port send "$phone_number" "$message_content" > /dev/null
json_select result
if [ "$?" == 0 ]; then
json_add_string status "1"
json_add_string cmd "sms_tool -d $at_port send \"$phone_number\" \"$message_content\""
json_add_string cmd "sms_tool_q -d $at_port send \"$phone_number\" \"$message_content\""
json_add_string "cmd_json" "$cmd_json"
else
json_add_string status "0"
@ -141,11 +141,11 @@ case $method in
;;
"send_raw_pdu")
cmd=$3
res=$(sms_tool -d $at_port send_raw_pdu "$cmd" )
res=$(sms_tool_q -d $at_port send_raw_pdu "$cmd" )
json_select result
if [ "$?" == 0 ]; then
json_add_string status "1"
json_add_string cmd "sms_tool -d $at_port send_raw_pdu \"$cmd\""
json_add_string cmd "sms_tool_q -d $at_port send_raw_pdu \"$cmd\""
json_add_string "res" "$res"
else
json_add_string status "0"
@ -155,11 +155,11 @@ case $method in
json_select result
index=$3
for i in $index; do
sms_tool -d $at_port delete $i > /dev/null
sms_tool_q -d $at_port delete $i > /dev/null
touch /tmp/cache_sms_$2
if [ "$?" == 0 ]; then
json_add_string status "1"
json_add_string "index$i" "sms_tool -d $at_port delete $i"
json_add_string "index$i" "sms_tool_q -d $at_port delete $i"
else
json_add_string status "0"
fi

View File

@ -1,8 +1,8 @@
#!/bin/sh
source /lib/functions.sh
#运行目录
MODEM_RUNDIR="/var/run/modem"
SCRIPT_DIR="/usr/share/modem"
MODEM_RUNDIR="/var/run/qmodem"
SCRIPT_DIR="/usr/share/qmodem"
modem_config=$1
mkdir -p "${MODEM_RUNDIR}/${modem_config}_dir"
@ -85,7 +85,7 @@ get_driver()
unlock_sim()
{
pin=$1
sim_lock_file="/var/run/modem/${modem_config}_dir/pincode"
sim_lock_file="/var/run/qmodem/${modem_config}_dir/pincode"
lock ${sim_lock_file}.lock
if [ -f $sim_lock_file ] && [ "$pin" == "$(cat $sim_lock_file)"];then
m_debug "pin code is already try"
@ -108,7 +108,7 @@ unlock_sim()
update_config()
{
config_load modem
config_load qmodem
config_get state $modem_config state
config_get enable_dial $modem_config enable_dial
config_get modem_path $modem_config path
@ -121,8 +121,10 @@ update_config()
config_get platform $modem_config platform
config_get define_connect $modem_config define_connect
config_get ra_master $modem_config ra_master
config_get extend_prefix $modem_config extend_prefix
config_get global_dial global enable_dial
config_get ethernet_5g u$modem_config ethernet
config_get alias $modem_config alias
driver=$(get_driver)
update_sim_slot
case $sim_slot in
@ -156,7 +158,8 @@ update_config()
modem_net=$(find $modem_path -name net |tail -1)
modem_netcard=$(ls $modem_net)
interface_name=$modem_config
interface6_name=${modem_config}v6
[ -n "$alias" ] && interface_name=$alias
interface6_name=${interface_name}v6
}
check_dial_prepare()
@ -265,12 +268,38 @@ check_ip()
fi
}
append_to_fw_zone()
{
local fw_zone=$1
local if_name=$2
source /etc/os-release
local os_version=${VERSION_ID:0:2}
if [ "$os_version" -le 21 ];then
has_ifname=0
origin_line=$(uci -q get firewall.@zone[${fw_zone}].network)
for i in $origin_line
do
if [ "$i" = "$if_name" ];then
has_ifname=1
fi
done
if [ -n "$origin_line" ] && [ "$has_ifname" -eq 0 ];then
uci set firewall.@zone[${fw_zone}].network="${origin_line} ${if_name}"
elif [ -z "$origin_line" ];then
uci set firewall.@zone[${fw_zone}].network="${if_name}"
fi
else
uci add_list firewall.@zone[${fw_zone}].network=${if_name}
fi
}
set_if()
{
#check if exist
interface=$(uci -q get network.$interface_name)
if [ -z "$interface" ];then
uci set network.${interface_name}=interface
uci set network.${interface_name}.modem_config="${modem_config}"
uci set network.${interface_name}.proto='dhcp'
uci set network.${interface_name}.defaultroute='1'
uci set network.${interface_name}.peerdns='0'
@ -280,7 +309,7 @@ set_if()
local num=$(uci show firewall | grep "name='wan'" | wc -l)
local wwan_num=$(uci -q get firewall.@zone[$num].network | grep -w "${interface_name}" | wc -l)
if [ "$wwan_num" = "0" ]; then
uci add_list firewall.@zone[$num].network="${interface_name}"
append_to_fw_zone $num ${interface_name}
fi
#set ipv6
#if pdptype contain 6
@ -288,6 +317,7 @@ set_if()
uci set network.lan.ipv6='1'
uci set network.lan.ip6assign='64'
uci set network.lan.ip6class="${interface6_name}"
uci set network.${interface6_name}.modem_config="${modem_config}"
uci set network.${interface6_name}='interface'
uci set network.${interface6_name}.proto='dhcpv6'
uci set network.${interface6_name}.ifname="@${interface_name}"
@ -304,10 +334,12 @@ set_if()
uci set dhcp.lan.ndp='relay'
uci set dhcp.lan.dhcpv6='relay'
uci commit dhcp
elif [ "$extend_prefix" = "1" ];then
uci set network.${interface6_name}.extendprefix=1
fi
local wwan6_num=$(uci -q get firewall.@zone[$num].network | grep -w "${interface6_name}" | wc -l)
if [ "$wwan6_num" = "0" ]; then
uci add_list firewall.@zone[$num].network="${interface6_name}"
append_to_fw_zone $num ${interface6_name}
fi
fi
uci commit network
@ -342,17 +374,36 @@ set_if()
flush_if()
{
uci delete network.${interface_name}
uci delete network.${interface6_name}
uci delete dhcp.${interface6_name}
uci commit network
uci commit dhcp
# uci delete network.${interface_name}
# uci delete network.${interface6_name}
# uci delete dhcp.${interface6_name}
# uci commit network
# uci commit dhcp
# set_led "net" $modem_config
# set_led "sim" $modem_config 0
# m_debug "delete interface $interface_name"
config_load network
remove_target="$modem_config"
config_foreach flush_ip_cb "interface"
set_led "net" $modem_config
set_led "sim" $modem_config 0
m_debug "delete interface $interface_name"
}
flush_ip_cb()
{
local network_cfg=$1
config_get bind_modem_config "$network_cfg" modem_config
if [ "$remove_target" = "$bind_modem_config" ];then
uci delete network.$network_cfg
uci commit network
uci commit dhcp
fi
}
dial(){
update_config
m_debug "modem_path=$modem_path,driver=$driver,interface=$interface_name,at_port=$at_port,using_sim_slot:$sim_slot"
@ -473,7 +524,8 @@ qmi_dial()
cmd_line="$cmd_line $auth"
fi
if [ -n "$modem_netcard" ]; then
cmd_line="$cmd_line -i $modem_netcard"
qmi_if=$(echo "$modem_netcard" | cut -d_ -f1)
cmd_line="${cmd_line} -i ${qmi_if}"
fi
cmd_line="$cmd_line -f $log_file"

View File

@ -3,9 +3,9 @@
action=$1
config=$2
slot_type=$3
modem_support=$(cat /usr/share/modem/modem_support.json)
modem_support=$(cat /usr/share/qmodem/modem_support.json)
source /usr/share/modem/modem_util.sh
source /usr/share/qmodem/modem_util.sh
scan()
{
@ -155,7 +155,7 @@ add()
#slot_type is usb or pcie
#section name is replace slot .:- with _
section_name=$(echo $slot | sed 's/[\.:-]/_/g')
is_exist=$(uci get modem.$section_name)
is_exist=$(uci get qmodem.$section_name)
case $slot_type in
"usb")
scan_usb_slot_interfaces $slot
@ -172,82 +172,82 @@ add()
m_debug "add modem $modem_name slot $slot slot_type $slot_type"
if [ -n "$is_exist" ]; then
#network at_port state name 不变,则不需要重启网络
orig_network=$(uci get modem.$section_name.network)
orig_at_port=$(uci get modem.$section_name.at_port)
orig_state=$(uci get modem.$section_name.state)
orig_name=$(uci get modem.$section_name.name)
uci del modem.$section_name.modes
uci del modem.$section_name.valid_at_ports
uci del modem.$section_name.tty_devices
uci del modem.$section_name.net_devices
uci del modem.$section_name.ports
uci set modem.$section_name.state="enabled"
orig_network=$(uci get qmodem.$section_name.network)
orig_at_port=$(uci get qmodem.$section_name.at_port)
orig_state=$(uci get qmodem.$section_name.state)
orig_name=$(uci get qmodem.$section_name.name)
uci del qmodem.$section_name.modes
uci del qmodem.$section_name.valid_at_ports
uci del qmodem.$section_name.tty_devices
uci del qmodem.$section_name.net_devices
uci del qmodem.$section_name.ports
uci set qmodem.$section_name.state="enabled"
else
#aqcuire lock
lock /tmp/lock/modem_add
modem_count=$(uci get modem.@global[0].modem_count)
modem_count=$(uci get qmodem.@global[0].modem_count)
[ -z "$modem_count" ] && modem_count=0
modem_count=$(($modem_count+1))
uci set modem.@global[0].modem_count=$modem_count
uci set modem.$section_name=modem-device
uci commit modem
uci set qmodem.@global[0].modem_count=$modem_count
uci set qmodem.$section_name=modem-device
uci commit qmodem
lock -u /tmp/lock/modem_add
#release lock
metric=$(($modem_count+10))
uci batch << EOF
set modem.$section_name.path="/sys/bus/usb/devices/$slot/"
set modem.$section_name.data_interface="$slot_type"
set modem.$section_name.enable_dial="1"
set modem.$section_name.pdp_type="ip"
set modem.$section_name.state="enabled"
set modem.$section_name.metric=$metric
set qmodem.$section_name.path="/sys/bus/usb/devices/$slot/"
set qmodem.$section_name.data_interface="$slot_type"
set qmodem.$section_name.enable_dial="1"
set qmodem.$section_name.pdp_type="ip"
set qmodem.$section_name.state="enabled"
set qmodem.$section_name.metric=$metric
EOF
fi
uci batch <<EOF
set modem.$section_name.name=$modem_name
set modem.$section_name.network=$net_devices
set modem.$section_name.manufacturer=$manufacturer
set modem.$section_name.platform=$platform
set modem.$section_name.define_connect=$define_connect
set qmodem.$section_name.name=$modem_name
set qmodem.$section_name.network=$net_devices
set qmodem.$section_name.manufacturer=$manufacturer
set qmodem.$section_name.platform=$platform
set qmodem.$section_name.define_connect=$define_connect
EOF
for mode in $modes; do
uci add_list modem.$section_name.modes=$mode
uci add_list qmodem.$section_name.modes=$mode
done
for at_port in $valid_at_ports; do
uci add_list modem.$section_name.valid_at_ports="/dev/$at_port"
uci set modem.$section_name.at_port="/dev/$at_port"
uci add_list qmodem.$section_name.valid_at_ports="/dev/$at_port"
uci set qmodem.$section_name.at_port="/dev/$at_port"
done
for at_port in $tty_devices; do
uci add_list modem.$section_name.ports="/dev/$at_port"
uci add_list qmodem.$section_name.ports="/dev/$at_port"
done
uci commit modem
mkdir -p /var/run/modem/${section_name}_dir
uci commit qmodem
mkdir -p /var/run/qmodem/${section_name}_dir
lock -u /tmp/lock/modem_add_$slot
#判断是否重启网络
[ -n "$is_exist" ] && [ "$orig_network" == "$net_devices" ] && [ "$orig_at_port" == "/dev/$at_port" ] && [ "$orig_state" == "enabled" ] && [ "$orig_name" == "$modem_name" ] && return
/etc/init.d/modem_network restart
/etc/init.d/qmodem_network restart
}
remove()
{
section_name=$1
m_debug "remove $section_name"
is_exist=$(uci get modem.$section_name)
is_exist=$(uci get qmodem.$section_name)
[ -z "$is_exist" ] && return
lock /tmp/lock/modem_remove
modem_count=$(uci get modem.@global[0].modem_count)
modem_count=$(uci get qmodem.@global[0].modem_count)
[ -z "$modem_count" ] && modem_count=0
modem_count=$(($modem_count-1))
uci set modem.@global[0].modem_count=$modem_count
uci commit modem
uci set qmodem.@global[0].modem_count=$modem_count
uci commit qmodem
uci batch <<EOF
del modem.${section_name}
del qmodem.${section_name}
del network.${section_name}
del network.${section_name}v6
del dhcp.${section_name}
commit network
commit dhcp
commit modem
commit qmodem
EOF
lock -u /tmp/lock/modem_remove
}
@ -256,8 +256,10 @@ disable()
{
local slot=$1
section_name=$(echo $slot | sed 's/[\.:-]/_/g')
uci set modem.$section_name.state="disabled"
uci commit modem
#reorder to first
uci reorder qmodem.$section_name="1"
uci set qmodem.$section_name.state="disabled"
uci commit qmodem
}

View File

@ -6,7 +6,7 @@ at()
local at_port=$1
local new_str="${2/[$]/$}"
local atcmd="${new_str/\"/\"}"
sms_tool -d $at_port at "$atcmd"
sms_tool_q -d $at_port at "$atcmd"
}
log2file()
@ -32,7 +32,6 @@ m_debug ()
[ -z "$debug_subject" ] && subject="modem_util" || subject="$debug_subject"
[ -n "$direct_debug" ] && echo "$subject" "$1"
if [ -n "$log_file" ];then
logger -t "$subject" "$1"
log2file "$subject" "$1" "$log_file"
else
log2sys "$subject" "$1"

View File

@ -1,6 +1,6 @@
#!/bin/sh
source /usr/share/modem/generic.sh
source /usr/share/qmodem/generic.sh
debug_subject="quectel_ctrl"
#return raw data
get_imei(){
@ -65,7 +65,7 @@ get_mode()
mode="${mode_num}"
;;
esac
available_modes=$(uci -q get modem.$config_section.modes)
available_modes=$(uci -q get qmodem.$config_section.modes)
json_add_object "mode"
for available_mode in $available_modes; do
if [ "$mode" = "$available_mode" ]; then

View File

@ -1,11 +1,11 @@
{
"luci-app-modem": {
"description": "Grant UCI access for luci-app-modem",
"luci-app-qmodem": {
"description": "Grant UCI access for luci-app-qmodem",
"read": {
"uci": [ "modem" ]
"uci": [ "qmodem" ]
},
"write": {
"uci": [ "modem" ]
"uci": [ "qmodem" ]
}
},
"luci-mod-status-index": {

View File

@ -1,30 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sms-tool
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://github.com/obsy/sms_tool
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2023-09-21
PKG_SOURCE_VERSION:=1b6ca03284fd65db8799dbf7c6224210093786b0
PKG_MIRROR_HASH:=6cfb176b475471462709b1e917276b7bade8ec58cff1ee6d5130caac80586b4e
include $(INCLUDE_DIR)/package.mk
define Package/sms-tool
SECTION:=utils
CATEGORY:=Utilities
TITLE:=sms tool
URL:=https://github.com/obsy/sms_tool
endef
define Package/sms-tool/description
SMS Tool for 3G/4G modem
endef
define Package/sms-tool/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/sms_tool $(1)/usr/bin/
endef
$(eval $(call BuildPackage,sms-tool))

28
sms-tool_q/Makefile Normal file
View File

@ -0,0 +1,28 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sms-tool_q
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://github.com/obsy/sms_tool
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2024-7-25
PKG_SOURCE_VERSION:=fce2b931c8d749c28b8281363950e963c98324eb
include $(INCLUDE_DIR)/package.mk
define Package/sms-tool_q
SECTION:=utils
CATEGORY:=Utilities
TITLE:=sms tool
URL:=https://github.com/obsy/sms_tool
endef
define Package/sms-tool_q/description
SMS Tool for 3G/4G modem
endef
define Package/sms-tool_q/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/sms_tool $(1)/usr/bin/sms_tool_q
endef
$(eval $(call BuildPackage,sms-tool_q))

View File

@ -1,48 +1,43 @@
diff --git a/sms_main.c b/sms_main.c
index 5945f02..168b424 100644
--- a/sms_main.c
+++ b/sms_main.c
@@ -193,7 +193,13 @@ int main(int argc, char* argv[])
usage();
if(strlen(argv[2]) > 160)
fprintf(stderr,"sms message too long: '%s'\n", argv[2]);
- }else if (!strcmp("delete",argv[0]))
+ }
+ else if (!strcmp("send_raw_pdu", argv[0]))
+ {
+ if(argc < 2)
+ usage();
+ }
+ else if (!strcmp("delete",argv[0]))
--- a/sms_main.c 2024-10-08 23:11:01.169908895 +0800
+++ b/sms_main.c 2024-10-08 23:10:52.929909691 +0800
@@ -200,7 +200,12 @@
{
if(argc < 2)
usage();
@@ -285,6 +291,50 @@ int main(int argc, char* argv[])
- }else if (!strcmp("recv", argv[0]))
+ }
+ else if (!strcmp("send_raw_pdu", argv[0])){
+ if(argc < 2)
+ usage();
+ }
+ else if (!strcmp("recv", argv[0]))
{
}else if (!strcmp("status", argv[0]))
{
@@ -288,6 +293,48 @@
fprintf(stderr,"reading port\n");
}
+ if (!strcmp("send_raw_pdu", argv[0]))
+ {
+ int pdu_len = strlen(argv[1]);
+ //append ctrl-z to pdustr
+ char* pdu_str;
+ pdu_str = malloc(pdu_len + 4);
+ memcpy(pdu_str, argv[1], pdu_len);
+ sprintf(pdu_str + pdu_len, "%c\r\n", 0x1A);
+ const int pdu_len_except_smsc = 18;
+ snprintf(cmdstr, sizeof(cmdstr), "AT+CMGS=%d\r\n", pdu_len_except_smsc);
+ int pdu_len;
+ int pdu_len_except_smsc;
+ char pdustr[1024];
+
+ alarm(5);
+ pdu_len_except_smsc = strlen(argv[1]) / 2 - 1;
+ sprintf(pdustr, "%s%c\r\n", argv[1],0x1A);
+ sprintf(cmdstr, "AT+CMGS=%d\r\n", pdu_len_except_smsc);
+ //set to pdu mode
+ fputs("AT+CMGF=0\r\n", pf);
+ while(fgets(buf, sizeof(buf), pfi)) {
+ if(starts_with("OK", buf))
+ break;
+ }
+ fputs(cmdstr, pf);
+ printf("cmdstr: %s\n", cmdstr);
+ sleep(1);
+ fputs(pdu_str, pf);
+ printf("pdu_str: %s\n", pdu_str);
+ free(pdu_str);
+ alarm(5);
+ fputs(pdustr, pf);
+
+ errno = 0;
+
+ while(fgets(buf, sizeof(buf), pfi))