feat: modem soft reboot support

This commit is contained in:
sfwtw 2025-04-27 21:12:19 +08:00
parent f21eb3b3e9
commit 40b3c450fb
8 changed files with 35 additions and 24 deletions

View File

@ -73,6 +73,10 @@ extend_prefix = s:taboption("advanced", Flag, "extend_prefix", translate("Extend
extend_prefix.description = translate("Once checking, the prefix will be apply to lan zone")
extend_prefix.default = "0"
soft_reboot = s:taboption("advanced", Flag, "soft_reboot", translate("Soft Reboot"))
soft_reboot.description = translate("enable modem soft reboot")
soft_reboot.default = "0"
-- 网络类型
pdp_type= s:taboption("advanced", ListValue, "pdp_type", translate("PDP Type"))
pdp_type.default = "ipv4v6"

View File

@ -69,6 +69,9 @@ name.cfgvalue = function(t, n)
return Value.cfgvalue(t, n) or "-"
end
soft_reboot = s:option(Flag, "soft_reboot", translate("Soft Reboot"))
soft_reboot.default = "0"
-- PDP Context Index
define_connect = s:option(Value, "define_connect", translate("PDP Context Index"))
define_connect.default = "1"

View File

@ -48,6 +48,9 @@ msgstr ""
msgid "Once checking, the prefix will be apply to lan zone"
msgstr ""
msgid "enable modem soft reboot"
msgstr ""
msgid "PDP Type"
msgstr ""

View File

@ -64,6 +64,9 @@ msgstr "扩展前缀"
msgid "Once checking, the prefix will be apply to lan zone"
msgstr "启用后该接口的前缀会被通告至Lan区域"
msgid "enable modem soft reboot"
msgstr "启用模组软重启"
msgid "PDP Type"
msgstr "PDP类型"

View File

@ -64,6 +64,9 @@ msgstr "扩展前缀"
msgid "Once checking, the prefix will be apply to lan zone"
msgstr "启用后该接口的前缀会被通告至Lan区域"
msgid "enable modem soft reboot"
msgstr "启用模组软重启"
msgid "PDP Type"
msgstr "PDP类型"

39
luci/luci-app-qmodem/root/etc/init.d/qmodem_reboot Normal file → Executable file
View File

@ -1,9 +1,7 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
USE_PROCD=1
START=95
STOP=0
USE_PROCD=1
start_service() {
:
@ -12,28 +10,25 @@ start_service() {
stop_service() {
procd_set_param timeout 30
config_load qmodem
config_foreach _reboot_usb modem-device
config_foreach _soft_reboot modem-device
}
_reboot_usb() {
config_get data_interface $1 data_interface
if [ "$data_interface" == "usb" ]; then
config_get name $1 name
if [ "$name" == "fm350-gl" ]; then
config_get at_port $1 at_port
_soft_reboot() {
config_get soft_reboot $1 soft_reboot
if [ "$soft_reboot" == "1" ]; then
config_get at_port $1 at_port
response=$(tom_modem -d "$at_port" -o a -c "AT+CFUN=1,1")
retries=3
while ! echo "$response" | grep -qi "ok" && [ $retries -gt 0 ]; do
sleep 1
response=$(tom_modem -d "$at_port" -o a -c "AT+CFUN=1,1")
retries=3
while ! echo "$response" | grep -qi "ok" && [ $retries -gt 0 ]; do
sleep 1
response=$(tom_modem -d "$at_port" -o a -c "AT+CFUN=1,1")
retries=$((retries - 1))
done
max_retries=15
while [ -e "/dev/$at_port" ] && [ $max_retries -gt 0 ]; do
sleep 1
max_retries=$((max_retries - 1))
done
fi
retries=$((retries - 1))
done
max_retries=15
while [ -e "$at_port" ] && [ $max_retries -gt 0 ]; do
sleep 1
max_retries=$((max_retries - 1))
done
fi
}

View File

@ -1,8 +1,7 @@
#!/bin/sh
# Copyright (C) 2024 Tom <fjrcn@outlook.com>
/etc/init.d/modeminit enable
/etc/init.d/modem enable
/etc/init.d/qmodem_reboot enable
uci -q batch <<-EOF >/dev/null
delete ucitrack.@qmodem[-1]

View File

@ -412,6 +412,7 @@ add()
set qmodem.$section_name.path="$modem_path"
set qmodem.$section_name.data_interface="$slot_type"
set qmodem.$section_name.enable_dial="1"
set qmodem.$section_name.soft_reboot="0"
set qmodem.$section_name.pdp_type="ip"
set qmodem.$section_name.state="enabled"
set qmodem.$section_name.metric=$metric