From 9057ede3b61b664d67fbefb3a19e636d6b90b040 Mon Sep 17 00:00:00 2001 From: fujr Date: Mon, 21 Oct 2024 22:22:27 +0800 Subject: [PATCH] qmodem: use new at tool --- .../luasrc/view/modem_sms/modem_sms.htm | 24 ++++++++++++------- luci/luci-app-qmodem/Makefile | 4 ++-- .../root/usr/share/qmodem/modem_ctrl.sh | 13 ++++++---- .../root/usr/share/qmodem/modem_util.sh | 6 +++-- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/luci/luci-app-qmodem-sms/luasrc/view/modem_sms/modem_sms.htm b/luci/luci-app-qmodem-sms/luasrc/view/modem_sms/modem_sms.htm index 9fc4f9c..0290445 100644 --- a/luci/luci-app-qmodem-sms/luasrc/view/modem_sms/modem_sms.htm +++ b/luci/luci-app-qmodem-sms/luasrc/view/modem_sms/modem_sms.htm @@ -599,7 +599,7 @@ class ModemSMS { var content = this.message_content.value; var is_ascii = /^[\x00-\x7F]*$/.test(content); if (is_ascii) { - this.send_gsm(); + this.send_raw_pdu(); } else{ this.send_raw_pdu(); @@ -782,12 +782,15 @@ class ModemSMS { let at,bt at = a.timestamp; bt = b.timestamp; - at = at.replace(/ /g,""); - bt = bt.replace(/ /g,""); - at = at.replace(/\//g,""); - bt = bt.replace(/\//g,""); - at = at.replace(/:/g,""); - bt = bt.replace(/:/g,""); + if (typeof at == "string") { + at = at.replace(/ /g,""); + bt = bt.replace(/ /g,""); + at = at.replace(/\//g,""); + bt = bt.replace(/\//g,""); + at = at.replace(/:/g,""); + bt = bt.replace(/:/g,""); + } + return bt - at; }); this.view = messages; @@ -831,7 +834,12 @@ class ModemSMS { for (let msg of msgs){ let sender,timestamp,content,part,total,index; sender = msg.sender; - timestamp = msg.timestamp; + if (typeof(msg.timestamp) == "number") { + timestamp = new Date(msg.timestamp*1000).toLocaleString(); + } + else{ + timestamp = msg.timestamp; + } content = msg.content; part = msg.part; total = msg.total; diff --git a/luci/luci-app-qmodem/Makefile b/luci/luci-app-qmodem/Makefile index 40d9b96..43d3403 100644 --- a/luci/luci-app-qmodem/Makefile +++ b/luci/luci-app-qmodem/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-qmodem LUCI_TITLE:=LuCI support for QWRT Modem LUCI_PKGARCH:=all -PKG_VERSION:=2.3.2 +PKG_VERSION:=2.4 PKG_LICENSE:=GPLv3 PKG_LINCESE_FILES:=LICENSE PKG_MAINTAINER:=Tom @@ -25,7 +25,7 @@ LUCI_DEPENDS:=+luci-compat \ +kmod-pcie_mhi \ +pciutils \ +quectel-CM-5G \ - +sms-tool_q \ + +tom_modem \ +jq +bc\ +coreutils +coreutils-stat diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_ctrl.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_ctrl.sh index 49bacbb..aa940dc 100755 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_ctrl.sh +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_ctrl.sh @@ -52,7 +52,8 @@ get_sms(){ [ -z "$file_time" ] && file_time=0 if [ ! -f $cache_file ] || [ $(($current_time - $file_time)) -gt $cache_timeout ]; then touch $cache_file - sms_tool_q -d $at_port -j recv > $cache_file + #sms_tool_q -d $at_port -j recv > $cache_file + tom_modem -d $at_port -o r > $cache_file cat $cache_file else cat $cache_file @@ -147,11 +148,12 @@ case $method in "send_raw_pdu") cmd=$3 [ -n "$sms_at_port" ] && at_port=$sms_at_port - res=$(sms_tool_q -d $at_port send_raw_pdu "$cmd" ) + #res=$(sms_tool_q -d $at_port send_raw_pdu "$cmd" ) + res=$(tom_modem -d $at_port -o s -p "$cmd") json_select result if [ "$?" == 0 ]; then json_add_string status "1" - json_add_string cmd "sms_tool_q -d $at_port send_raw_pdu \"$cmd\"" + json_add_string cmd "tom_modem -d $at_port -o s -p \"$cmd\"" json_add_string "res" "$res" else json_add_string status "0" @@ -162,11 +164,12 @@ case $method in index=$3 [ -n "$sms_at_port" ] && at_port=$sms_at_port for i in $index; do - sms_tool_q -d $at_port delete $i > /dev/null + # sms_tool_q -d $at_port delete $i > /dev/null + tom_modem -d $at_port -o d -i $i touch /tmp/cache_sms_$2 if [ "$?" == 0 ]; then json_add_string status "1" - json_add_string "index$i" "sms_tool_q -d $at_port delete $i" + json_add_string "index$i" "tom_modem -d $at_port -o d -i $i" else json_add_string status "0" fi diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_util.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_util.sh index ec9271f..e914ef6 100755 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_util.sh +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_util.sh @@ -7,7 +7,8 @@ at() local new_str="${2/[$]/$}" local atcmd="${new_str/\"/\"}" #过滤空行 - sms_tool_q -d $at_port at "$atcmd" + #sms_tool_q -d $at_port at "$atcmd" + tom_modem -d $at_port -o a -c "$atcmd" } fastat() @@ -16,7 +17,8 @@ fastat() local new_str="${2/[$]/$}" local atcmd="${new_str/\"/\"}" #过滤空行 - sms_tool_q -t 1 -d $at_port at "$atcmd" + # sms_tool_q -t 1 -d $at_port at "$atcmd" + tom_modem -d $at_port -o a -c "$atcmd" -t 1 } log2file()