Feature: Introduce a mechanism to add delays and execute commands post-init or pre-dial to address the issue raised in #32.
This commit is contained in:
parent
6d30afefad
commit
c338e65c01
@ -114,4 +114,30 @@ for _, band in ipairs(band_options) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pre_dial_delay = s:option(Value, "pre_dial_delay", translate("Pre Dial Delay")..translate(" (beta)"))
|
||||||
|
pre_dial_delay.description = translate("Delay of executing AT command before dialing, in seconds."..translate("(still in beta))"))
|
||||||
|
pre_dial_delay.placeholder = translate("Enter delay in seconds")
|
||||||
|
pre_dial_delay.default = "0"
|
||||||
|
pre_dial_delay.datatype = "uinteger"
|
||||||
|
pre_dial_delay.rmempty = true
|
||||||
|
|
||||||
|
pre_add_delay = s:option(Value, "post_init_delay", translate("Post Init Delay")..translate(" (beta)"))
|
||||||
|
pre_add_delay.description = translate("Delay of executing AT command after modem initialization, in seconds."..translate("(still in beta))"))
|
||||||
|
pre_add_delay.placeholder = translate("Enter delay in seconds")
|
||||||
|
pre_add_delay.default = "0"
|
||||||
|
pre_add_delay.datatype = "uinteger"
|
||||||
|
pre_add_delay.rmempty = true
|
||||||
|
|
||||||
|
pre_add_at_cmds = s:option(DynamicList, "post_init_at_cmds", translate("Post Init AT Commands")..translate(" (beta)"))
|
||||||
|
pre_add_at_cmds.description = translate("AT commands to execute after modem initialization."..translate("(still in beta))"))
|
||||||
|
pre_add_at_cmds.placeholder = translate("Enter AT commands")
|
||||||
|
pre_add_at_cmds.datatype = "string"
|
||||||
|
pre_add_at_cmds.rmempty = true
|
||||||
|
|
||||||
|
pre_dial_at_cmds = s:option(DynamicList, "pre_dial_at_cmds", translate("Pre Dial AT Commands")..translate(" (beta)"))
|
||||||
|
pre_dial_at_cmds.description = translate("AT commands to execute before dialing."..translate("(still in beta))"))
|
||||||
|
pre_dial_at_cmds.placeholder = translate("Enter AT commands")
|
||||||
|
pre_dial_at_cmds.datatype = "string"
|
||||||
|
pre_dial_at_cmds.rmempty = true
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
@ -102,11 +102,7 @@ slot_type.cfgvalue = function(t, n)
|
|||||||
return name:upper()
|
return name:upper()
|
||||||
end
|
end
|
||||||
|
|
||||||
slot_path = s:option(DummyValue, "slot", translate("Slot Path"))
|
path = s:option(DummyValue, "path", translate("Slot Path"))
|
||||||
slot_path.cfgvalue = function(t, n)
|
|
||||||
local path = (Value.cfgvalue(t, n) or "-")
|
|
||||||
return path
|
|
||||||
end
|
|
||||||
|
|
||||||
default_alias = s:option(DummyValue, "alias", translate("Alias"))
|
default_alias = s:option(DummyValue, "alias", translate("Alias"))
|
||||||
default_alias.cfgvalue = function(t, n)
|
default_alias.cfgvalue = function(t, n)
|
||||||
|
@ -771,3 +771,40 @@ msgstr "重启调制解调器"
|
|||||||
|
|
||||||
msgid "AT Debug"
|
msgid "AT Debug"
|
||||||
msgstr "AT调试"
|
msgstr "AT调试"
|
||||||
|
|
||||||
|
msgid "Post Init Delay"
|
||||||
|
msgstr "初始化延时"
|
||||||
|
|
||||||
|
msgid "Delay of executing AT command after modem initialization, in seconds."
|
||||||
|
msgstr "模组初始化后执行AT命令的延迟时间,以秒为单位。"
|
||||||
|
|
||||||
|
msgid "Enter delay in seconds"
|
||||||
|
msgstr "输入延时(秒)"
|
||||||
|
|
||||||
|
msgid "Post Init AT Commands"
|
||||||
|
msgstr "初始化后AT命令"
|
||||||
|
|
||||||
|
msgid "AT commands to execute after modem initialization."
|
||||||
|
msgstr "模组初始化后执行的AT命令。"
|
||||||
|
|
||||||
|
msgid "Enter AT commands"
|
||||||
|
msgstr "输入AT命令"
|
||||||
|
|
||||||
|
msgid "Pre Dial Delay"
|
||||||
|
msgstr "拨号前延时"
|
||||||
|
|
||||||
|
msgid "Delay of executing AT command before dialing, in seconds."
|
||||||
|
msgstr "拨号前执行AT命令的延迟时间,以秒为单位。"
|
||||||
|
|
||||||
|
|
||||||
|
msgid "Pre Dial AT Commands"
|
||||||
|
msgstr "拨号前AT命令"
|
||||||
|
|
||||||
|
msgid "AT commands to execute before dialing."
|
||||||
|
msgstr "拨号前执行的AT命令。"
|
||||||
|
|
||||||
|
msgid "(still in beta)"
|
||||||
|
msgstr "(仍在测试中)"
|
||||||
|
|
||||||
|
msgid “(beta)"
|
||||||
|
msgstr "(测试)"
|
||||||
|
@ -771,3 +771,40 @@ msgstr "重启调制解调器"
|
|||||||
|
|
||||||
msgid "AT Debug"
|
msgid "AT Debug"
|
||||||
msgstr "AT调试"
|
msgstr "AT调试"
|
||||||
|
|
||||||
|
msgid "Post Init Delay"
|
||||||
|
msgstr "初始化延时"
|
||||||
|
|
||||||
|
msgid "Delay of executing AT command after modem initialization, in seconds."
|
||||||
|
msgstr "模组初始化后执行AT命令的延迟时间,以秒为单位。"
|
||||||
|
|
||||||
|
msgid "Enter delay in seconds"
|
||||||
|
msgstr "输入延时(秒)"
|
||||||
|
|
||||||
|
msgid "Post Init AT Commands"
|
||||||
|
msgstr "初始化后AT命令"
|
||||||
|
|
||||||
|
msgid "AT commands to execute after modem initialization."
|
||||||
|
msgstr "模组初始化后执行的AT命令。"
|
||||||
|
|
||||||
|
msgid "Enter AT commands"
|
||||||
|
msgstr "输入AT命令"
|
||||||
|
|
||||||
|
msgid "Pre Dial Delay"
|
||||||
|
msgstr "拨号前延时"
|
||||||
|
|
||||||
|
msgid "Delay of executing AT command before dialing, in seconds."
|
||||||
|
msgstr "拨号前执行AT命令的延迟时间,以秒为单位。"
|
||||||
|
|
||||||
|
|
||||||
|
msgid "Pre Dial AT Commands"
|
||||||
|
msgstr "拨号前AT命令"
|
||||||
|
|
||||||
|
msgid "AT commands to execute before dialing."
|
||||||
|
msgstr "拨号前执行的AT命令。"
|
||||||
|
|
||||||
|
msgid "(still in beta)"
|
||||||
|
msgstr "(仍在测试中)"
|
||||||
|
|
||||||
|
msgid “(beta)"
|
||||||
|
msgstr "(测试)"
|
||||||
|
@ -11,6 +11,12 @@ debug_subject="modem_dial"
|
|||||||
source "${SCRIPT_DIR}/generic.sh"
|
source "${SCRIPT_DIR}/generic.sh"
|
||||||
touch $log_file
|
touch $log_file
|
||||||
|
|
||||||
|
exec_pre_dial()
|
||||||
|
{
|
||||||
|
section=$1
|
||||||
|
/usr/share/qmodem/modem_hook.sh $section pre_dial
|
||||||
|
}
|
||||||
|
|
||||||
get_led()
|
get_led()
|
||||||
{
|
{
|
||||||
config_foreach get_led_by_slot modem-slot
|
config_foreach get_led_by_slot modem-slot
|
||||||
@ -575,6 +581,7 @@ dial(){
|
|||||||
done
|
done
|
||||||
set_if
|
set_if
|
||||||
m_debug "dialing $modem_path driver $driver"
|
m_debug "dialing $modem_path driver $driver"
|
||||||
|
exec_pre_dial $modem_config
|
||||||
case $driver in
|
case $driver in
|
||||||
"qmi")
|
"qmi")
|
||||||
qmi_dial
|
qmi_dial
|
||||||
|
51
luci/luci-app-qmodem/root/usr/share/qmodem/modem_hook.sh
Executable file
51
luci/luci-app-qmodem/root/usr/share/qmodem/modem_hook.sh
Executable file
@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
. /lib/functions.sh
|
||||||
|
|
||||||
|
config_name="qmodem"
|
||||||
|
config_section=$1
|
||||||
|
init_type=$2
|
||||||
|
|
||||||
|
case $init_type in
|
||||||
|
post_init)
|
||||||
|
# pre-add at commands
|
||||||
|
cfg_prefix="post_init"
|
||||||
|
debug_subject="post_init"
|
||||||
|
;;
|
||||||
|
pre_dial)
|
||||||
|
# pre-dial at commands
|
||||||
|
cfg_prefix="pre_dial"
|
||||||
|
debug_subject="pre_dial"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
m_debug "init_type error"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
_execute_ats(){
|
||||||
|
command=$1
|
||||||
|
res=$(at $at_port $command)
|
||||||
|
m_debug "execute_ats $config_section: $command $at_port"
|
||||||
|
m_debug "execute_ats_result $config_section: $res"
|
||||||
|
}
|
||||||
|
|
||||||
|
. /usr/share/qmodem/modem_util.sh
|
||||||
|
config_load ${config_name}
|
||||||
|
|
||||||
|
config_get ${cfg_prefix}_delay $config_section delay
|
||||||
|
|
||||||
|
config_get at_port $config_section at_port
|
||||||
|
|
||||||
|
if [ -f "$at_port" ] || [ -z "$at_port" ]; then
|
||||||
|
m_debug "$config_section:at_port is not set or not a file"
|
||||||
|
m_debug "at_port $config_section: $at_port"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$delay" ]; then
|
||||||
|
sleep $delay
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
config_list_foreach $config_section ${cfg_prefix}_at_cmds _execute_ats
|
@ -8,6 +8,14 @@ debug_subject="modem_scan"
|
|||||||
source /lib/functions.sh
|
source /lib/functions.sh
|
||||||
source /usr/share/qmodem/modem_util.sh
|
source /usr/share/qmodem/modem_util.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exec_post_init()
|
||||||
|
{
|
||||||
|
section_name=$1
|
||||||
|
/usr/share/qmodem/modem_hook.sh $section_name post_init
|
||||||
|
}
|
||||||
|
|
||||||
get_associate_usb()
|
get_associate_usb()
|
||||||
{
|
{
|
||||||
target_slot=$1
|
target_slot=$1
|
||||||
@ -315,6 +323,7 @@ add()
|
|||||||
if [ "$is_fixed_device" == "1" ];then
|
if [ "$is_fixed_device" == "1" ];then
|
||||||
m_debug "modem $modem_name slot $slot slot_type $slot_type is fixed device, skip"
|
m_debug "modem $modem_name slot $slot slot_type $slot_type is fixed device, skip"
|
||||||
lock -u /tmp/lock/modem_add_$slot
|
lock -u /tmp/lock/modem_add_$slot
|
||||||
|
exec_post_init $section_name
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
case $slot_type in
|
case $slot_type in
|
||||||
@ -407,6 +416,8 @@ EOF
|
|||||||
uci commit qmodem
|
uci commit qmodem
|
||||||
mkdir -p /var/run/qmodem/${section_name}_dir
|
mkdir -p /var/run/qmodem/${section_name}_dir
|
||||||
lock -u /tmp/lock/modem_add_$slot
|
lock -u /tmp/lock/modem_add_$slot
|
||||||
|
#增加预初始化脚本
|
||||||
|
exec_post_init $section_name
|
||||||
#判断是否重启网络
|
#判断是否重启网络
|
||||||
[ -n "$is_exist" ] && [ "$orig_network" == "$net_devices" ] && [ "$orig_at_port" == "/dev/$at_port" ] && [ "$orig_state" == "enabled" ] && [ "$orig_name" == "$modem_name" ] && return
|
[ -n "$is_exist" ] && [ "$orig_network" == "$net_devices" ] && [ "$orig_at_port" == "/dev/$at_port" ] && [ "$orig_state" == "enabled" ] && [ "$orig_name" == "$modem_name" ] && return
|
||||||
/etc/init.d/qmodem_network restart
|
/etc/init.d/qmodem_network restart
|
||||||
|
Loading…
x
Reference in New Issue
Block a user