diff --git a/luci-app-modem/luasrc/controller/modem.lua b/luci-app-modem/luasrc/controller/modem.lua
index 3659628..aa9ef30 100644
--- a/luci-app-modem/luasrc/controller/modem.lua
+++ b/luci-app-modem/luasrc/controller/modem.lua
@@ -24,16 +24,19 @@ function index()
entry({"admin", "network", "modem", "status"}, call("act_status")).leaf = true
--AT命令
- -- local modem_number=uci:get('modem','@global[0]','modem_number')
- -- if modem_number ~= "0" or modem_number == nil then
- entry({"admin", "network", "modem", "at_commands"},template("modem/at_commands"),translate("AT Commands"),30).leaf = true
- -- end
+ entry({"admin", "network", "modem", "at_commands"},template("modem/at_commands"),translate("AT Commands"),30).leaf = true
entry({"admin", "network", "modem", "mode_info"}, call("modeInfo"), nil).leaf = true
entry({"admin", "network", "modem", "send_at_command"}, call("sendATCommand"), nil).leaf = true
entry({"admin", "network", "modem", "user_at_command"}, call("userATCommand"), nil).leaf = true
entry({"admin", "network", "modem", "get_at_port"}, call("getATPort"), nil).leaf = true
end
+-- 判断字符串是否含有字母
+function hasLetters(str)
+ local pattern = "%a" -- 匹配字母的正则表达式
+ return string.find(str, pattern) ~= nil
+end
+
-- AT命令
function at(at_port,at_command)
-- local odpall = io.popen("sh modem_at.sh "..at_port.." '"..at_command.."'")
@@ -49,7 +52,7 @@ function getModemConnectStatus(at_port,manufacturer)
local connect_status="unknown"
if at_port and manufacturer then
- local odpall = io.popen("cd /usr/share/modem && source $(dirname \"$0\")/"..manufacturer..".sh && get_connect_status "..at_port)
+ local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && get_connect_status "..at_port)
connect_status = odpall:read("*a")
connect_status=string.gsub(connect_status, "\n", "")
odpall:close()
@@ -59,8 +62,8 @@ function getModemConnectStatus(at_port,manufacturer)
end
-- 获取模组基本信息
-function getModemBaseInfo(at_port)
- local modem_base_info={}
+function getModemDeviceInfo(at_port)
+ local modem_device_info={}
uci:foreach("modem", "modem-device", function (modem_device)
if at_port == modem_device["at_port"] then
@@ -70,28 +73,26 @@ function getModemBaseInfo(at_port)
local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"])
--设置值
- modem_base_info=modem_device
- modem_base_info["data_interface"]=data_interface
- modem_base_info["connect_status"]=connect_status
+ modem_device_info=modem_device
+ modem_device_info["data_interface"]=data_interface
+ modem_device_info["connect_status"]=connect_status
return true
end
end)
- return modem_base_info
+ return modem_device_info
end
-- 获取模组更多信息
function getModemMoreInfo(at_port,manufacturer)
- local modem_more_info={}
-
- -- if manufacturer == "unknown" then
- -- return modem_more_info
- -- end
+ --获取模组信息
local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer)
local opd = odpall:read("*a")
odpall:close()
- modem_more_info=json.parse(opd)
+
+ --设置值
+ local modem_more_info=json.parse(opd)
return modem_more_info
end
@@ -102,34 +103,53 @@ function getModemInfo()
local at_port = http.formvalue("port")
--获取信息
- local modem_base_info
+ local modem_device_info
local modem_more_info
if at_port then
- modem_base_info=getModemBaseInfo(at_port)
- modem_more_info=getModemMoreInfo(at_port,modem_base_info["manufacturer"])
+ modem_device_info=getModemDeviceInfo(at_port)
+ modem_more_info=getModemMoreInfo(at_port,modem_device_info["manufacturer"])
end
--设置信息
local modem_info={}
- modem_info["base_info"]=modem_base_info
+ modem_info["device_info"]=modem_device_info
modem_info["more_info"]=modem_more_info
--设置翻译
local translation={}
+ --SIM卡信息翻译
if modem_more_info["sim_info"] then
- for key in pairs(modem_more_info["sim_info"]) do
- local key_origin=modem_more_info["sim_info"][key]:upper()
- translation[key_origin]=luci.i18n.translate(key_origin)
+
+ local sim_info=modem_more_info["sim_info"]
+ for i = 1, #sim_info do
+ local info = sim_info[i]
+ for key in pairs(info) do
+ translation[key]=luci.i18n.translate(key)
+ local value=info[key]
+ if hasLetters(value) then
+ translation[value]=luci.i18n.translate(value)
+ end
+ end
end
end
-
+ --网络信息翻译
+ if modem_more_info["network_info"] then
+ for key in pairs(modem_more_info["network_info"]) do
+ translation[key]=luci.i18n.translate(key)
+ local value=modem_more_info["network_info"][key]
+ if hasLetters(value) then
+ translation[value]=luci.i18n.translate(value)
+ end
+ end
+ end
+ --小区信息翻译
if modem_more_info["cell_info"] then
for key in pairs(modem_more_info["cell_info"]) do
translation[key]=luci.i18n.translate(key)
local network_mode=modem_more_info["cell_info"][key]
for i = 1, #network_mode do
- local value = network_mode[i]
- for key in pairs(value) do
+ local info = network_mode[i]
+ for key in pairs(info) do
translation[key]=luci.i18n.translate(key)
end
end
diff --git a/luci-app-modem/luasrc/model/cbi/modem/index.lua b/luci-app-modem/luasrc/model/cbi/modem/index.lua
index 55523fe..19facb3 100644
--- a/luci-app-modem/luasrc/model/cbi/modem/index.lua
+++ b/luci-app-modem/luasrc/model/cbi/modem/index.lua
@@ -5,7 +5,8 @@ m = Map("modem")
m.title = translate("Modem Config")
m.description = translate("Configuration panel for Modem, Add configuration to all modems on this page")
-s = m:section(NamedSection, "global", "global")
+--全局配置
+s = m:section(NamedSection, "global", "global", translate("Global Config"))
s.anonymous = true
s.addremove = false
diff --git a/luci-app-modem/luasrc/view/modem/at_commands.htm b/luci-app-modem/luasrc/view/modem/at_commands.htm
index a0060e3..770a578 100644
--- a/luci-app-modem/luasrc/view/modem/at_commands.htm
+++ b/luci-app-modem/luasrc/view/modem/at_commands.htm
@@ -1,60 +1,15 @@
<%+header%>
-
-
<%:Modem Information%>
-
<%:%>
+
<%:Modem Information%>
+
<%:%>
diff --git a/luci-app-modem/luasrc/view/modem/modem_status.htm b/luci-app-modem/luasrc/view/modem/modem_status.htm
index 0990ca1..9c54ed1 100644
--- a/luci-app-modem/luasrc/view/modem/modem_status.htm
+++ b/luci-app-modem/luasrc/view/modem/modem_status.htm
@@ -48,7 +48,7 @@
}
else
{
- name=name.toUpperCase();
+ mode=mode.toUpperCase();
}
// 获取连接状态
diff --git a/luci-app-modem/po/zh-cn/modem.po b/luci-app-modem/po/zh-cn/modem.po
index 06d12ab..5befef6 100644
--- a/luci-app-modem/po/zh-cn/modem.po
+++ b/luci-app-modem/po/zh-cn/modem.po
@@ -31,6 +31,12 @@ msgstr "正在加载模组状态"
msgid "Loading modem"
msgstr "正在加载模组"
+msgid "Configuration panel for Modem, Add configuration to all modems on this page"
+msgstr "通信模组服务配置界面,在此页面给所有模组添加配置"
+
+msgid "Global Config"
+msgstr "全局配置"
+
msgid "connect"
msgstr "已连接"
@@ -52,15 +58,15 @@ msgstr "连接状态"
msgid "Config List"
msgstr "配置列表"
-msgid "Configuration panel for Modem, Add configuration to all modems on this page"
-msgstr "通信模组服务配置界面,在此页面给所有模组添加配置"
-
msgid "AT Commands"
msgstr "AT命令"
msgid "Debugging Your Module with AT Command"
msgstr "使用AT命令调试你的模组"
+msgid "Response"
+msgstr "响应"
+
msgid "Modem Information"
msgstr "模组信息"
@@ -166,18 +172,30 @@ msgstr "SIM卡信息"
msgid "ISP"
msgstr "运营商"
-msgid "IMEI"
-msgstr "IMEI"
+msgid "SIM Slot"
+msgstr "SIM卡卡槽"
-msgid "IMSI"
-msgstr "IMSI"
+msgid "SIM Status"
+msgstr "SIM卡状态"
-msgid "ICCID"
-msgstr "ICCID"
+msgid "miss"
+msgstr "未插入"
+
+msgid "locked"
+msgstr "锁定"
msgid "SIM Number"
msgstr "SIM卡号码"
+msgid "IMEI"
+msgstr "国际移动设备识别码"
+
+msgid "IMSI"
+msgstr "国际移动用户识别码"
+
+msgid "ICCID"
+msgstr "集成电路卡识别码"
+
msgid "Network Information"
msgstr "网络信息"
diff --git a/luci-app-modem/root/usr/share/modem/fibocom.sh b/luci-app-modem/root/usr/share/modem/fibocom.sh
index 88aed2e..0111089 100755
--- a/luci-app-modem/root/usr/share/modem/fibocom.sh
+++ b/luci-app-modem/root/usr/share/modem/fibocom.sh
@@ -6,7 +6,7 @@ current_dir="$(dirname "$0")"
get_fibocom_mode()
{
local at_port="$1"
- local at_command="AT+GTUSBMODE?"
+ at_command="AT+GTUSBMODE?"
local mode_num=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+GTUSBMODE: //g' | sed 's/\r//g')
local mode
@@ -32,11 +32,12 @@ get_fibocom_mode()
get_connect_status()
{
local at_port="$1"
- local at_command="AT+CGDCONT?"
+ at_command="AT+CGDCONT?"
local response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $6}')
local not_ip="0.0.0.0,0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0"
+ local connect_status
if [ "$response" = "$not_ip" ]; then
connect_status="disconnect"
else
@@ -46,51 +47,25 @@ get_connect_status()
echo "$connect_status"
}
-#获取SIM卡状态
-get_fibocom_sim_status()
-{
- debug "检查SIM状态"
- local sim_status
-
- local at_command="AT+CPIN?"
- local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
- local sim_error=$(echo "$response" | grep "ERROR")
- if [ -n "$sim_error" ]; then
- debug "未插入SIM卡"
- sim_status="miss"
- return
- fi
- local sim_ready=$(echo "$response" | grep "READY")
- if [ -n "$sim_ready" ]; then
- debug "SIM卡正常"
- sim_status="ready"
- else
- debug "SIM卡被锁定"
- sim_status="locked"
- return
- fi
- echo "$sim_status"
-}
-
#基本信息
fibocom_base_info()
{
debug "Fibocom base info"
- local at_command="ATI"
- local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+ at_command="ATI"
+ response=$(sh $current_dir/modem_at.sh $at_port $at_command)
- #名称
+ #Name(名称)
name=$(echo "$response" | sed -n '3p' | sed 's/Model: //g' | sed 's/\r//g')
- #制造商
+ #Manufacturer(制造商)
manufacturer=$(echo "$response" | sed -n '2p' | sed 's/Manufacturer: //g' | sed 's/\r//g')
- #固件版本
+ #Revision(固件版本)
revision=$(echo "$response" | sed -n '4p' | sed 's/Revision: //g' | sed 's/\r//g')
- #拨号模式
+ #Mode(拨号模式)
mode=$(get_fibocom_mode $at_port | tr 'a-z' 'A-Z')
- #温度
+ #Temperature(温度)
at_command="AT+MTSM=1,6"
response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+MTSM: //g' | sed 's/\r//g')
if [ -n "$response" ]; then
@@ -103,8 +78,31 @@ fibocom_sim_info()
{
debug "Fibocom sim info"
+ #SIM Slot(SIM卡卡槽)
+ at_command="AT+GTDUALSIM"
+ sim_slot=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}' | sed 's/SUB//g')
+
+ #IMEI(国际移动设备识别码)
+ at_command="AT+CGSN"
+ imei=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
+
+ #SIM Status(SIM状态)
+ at_command="AT+CPIN?"
+ response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
+ if [[ "$response" = *"READY"* ]]; then
+ sim_status="ready"
+ elif [[ "$response" = *"ERROR"* ]]; then
+ sim_status="miss"
+ else
+ sim_status="locked"
+ fi
+
+ if [ "$sim_status" != "ready" ]; then
+ return
+ fi
+
#ISP(互联网服务提供商)
- local at_command="AT+COPS?"
+ at_command="AT+COPS?"
isp=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
# if [ "$isp" = "CHN-CMCC" ] || [ "$isp" = "CMCC" ]|| [ "$isp" = "46000" ]; then
# isp="中国移动"
@@ -114,21 +112,17 @@ fibocom_sim_info()
# isp="中国电信"
# fi
- #IMEI
- at_command="AT+CGSN"
- imei=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
+ #SIM Number(SIM卡号码,手机号)
+ at_command="AT+CNUM?"
+ sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
- #IMSI
+ #IMSI(国际移动用户识别码)
at_command="AT+CIMI"
imsi=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
- #ICCID
+ #ICCID(集成电路卡识别码)
at_command="AT+ICCID"
iccid=$(sh $current_dir/modem_at.sh $at_port $at_command | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}")
-
- #SIM卡号码(手机号)
- at_command="AT+CNUM?"
- sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
}
#网络信息
@@ -136,8 +130,14 @@ fibocom_network_info()
{
debug "Fibocom network info"
+ #Connect Status(连接状态)
+ connect_status=$(get_connect_status $at_port)
+ if [ "$connect_status" != "connect" ]; then
+ return
+ fi
+
#Network Type(网络类型)
- local at_command="AT+PSRAT?"
+ at_command="AT+PSRAT?"
network_type=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+PSRAT: //g' | sed 's/\r//g')
# #CSQ
@@ -165,9 +165,9 @@ get_band()
{
local band
case $1 in
- "WCDMA") band="B$2" ;;
- "LTE") band="B$(($2-100))" ;;
- "NR") band="$2" band="N${band#*50}" ;;
+ "WCDMA") band="$2" ;;
+ "LTE") band="$(($2-100))" ;;
+ "NR") band="$2" band="${band#*50}" ;;
esac
echo "$band"
}
@@ -265,119 +265,120 @@ get_ecio()
echo "$ecio"
}
-#网络信息
+#小区信息
fibocom_cell_info()
{
debug "Fibocom cell info"
#RSRQ,RSRP,SINR
at_command='AT+GTCCINFO?'
- local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+ response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+
local rat=$(echo "$response" | grep "service" | awk -F' ' '{print $1}')
response=$(echo "$response" | sed -n '4p')
- case $rat in
- "NR")
- network_mode="NR5G-SA Mode"
- nr_mcc=$(echo "$response" | awk -F',' '{print $3}')
- nr_mnc=$(echo "$response" | awk -F',' '{print $4}')
- nr_tac=$(echo "$response" | awk -F',' '{print $5}')
- nr_cell_id=$(echo "$response" | awk -F',' '{print $6}')
- nr_arfcn=$(echo "$response" | awk -F',' '{print $7}')
- nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
- nr_band_num=$(echo "$response" | awk -F',' '{print $9}')
- nr_band=$(get_band "NR" $nr_band_num)
- nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
- nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num)
- nr_sinr=$(echo "$response" | awk -F',' '{print $11}')
- nr_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
- nr_rxlev=$(get_rxlev "NR" $nr_rxlev_num)
- nr_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
- nr_rsrp=$(get_rsrp "NR" $nr_rsrp_num)
- nr_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
- nr_rsrq=$(get_rsrq "NR" $nr_rsrq_num)
+ case $rat in
+ "NR")
+ network_mode="NR5G-SA Mode"
+ nr_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ nr_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ nr_tac=$(echo "$response" | awk -F',' '{print $5}')
+ nr_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ nr_arfcn=$(echo "$response" | awk -F',' '{print $7}')
+ nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ nr_band_num=$(echo "$response" | awk -F',' '{print $9}')
+ nr_band=$(get_band "NR" $nr_band_num)
+ nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
+ nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num)
+ nr_sinr=$(echo "$response" | awk -F',' '{print $11}')
+ nr_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
+ nr_rxlev=$(get_rxlev "NR" $nr_rxlev_num)
+ nr_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
+ nr_rsrp=$(get_rsrp "NR" $nr_rsrp_num)
+ nr_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
+ nr_rsrq=$(get_rsrq "NR" $nr_rsrq_num)
+ ;;
+ "LTE-NR")
+ network_mode="EN-DC Mode"
+ #LTE
+ endc_lte_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ endc_lte_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ endc_lte_tac=$(echo "$response" | awk -F',' '{print $5}')
+ endc_lte_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ endc_lte_earfcn=$(echo "$response" | awk -F',' '{print $7}')
+ endc_lte_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ endc_lte_band_num=$(echo "$response" | awk -F',' '{print $9}')
+ endc_lte_band=$(get_band "LTE" $endc_lte_band_num)
+ ul_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
+ endc_lte_ul_bandwidth=$(get_ul_bandwidth $ul_bandwidth_num)
+ endc_lte_dl_bandwidth="$endc_lte_ul_bandwidth"
+ endc_lte_rssnr_num=$(echo "$response" | awk -F',' '{print $11}')
+ endc_lte_rssnr=$(get_rssnr $endc_lte_rssnr_num)
+ endc_lte_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
+ endc_lte_rxlev=$(get_rxlev "LTE" $endc_lte_rxlev_num)
+ endc_lte_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
+ endc_lte_rsrp=$(get_rsrp "LTE" $endc_lte_rsrp_num)
+ endc_lte_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
+ endc_lte_rsrq=$(get_rsrq "LTE" $endc_lte_rsrq_num)
+ #NR5G-NSA
+ endc_nr_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ endc_nr_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ endc_nr_tac=$(echo "$response" | awk -F',' '{print $5}')
+ endc_nr_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ endc_nr_arfcn=$(echo "$response" | awk -F',' '{print $7}')
+ endc_nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ endc_nr_band_num=$(echo "$response" | awk -F',' '{print $9}')
+ endc_nr_band=$(get_band "NR" $endc_nr_band_num)
+ nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
+ endc_nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num)
+ endc_nr_sinr=$(echo "$response" | awk -F',' '{print $11}')
+ endc_nr_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
+ endc_nr_rxlev=$(get_rxlev "NR" $endc_nr_rxlev_num)
+ endc_nr_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
+ endc_nr_rsrp=$(get_rsrp "NR" $endc_nr_rsrp_num)
+ endc_nr_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
+ endc_nr_rsrq=$(get_rsrq "NR" $endc_nr_rsrq_num)
;;
- "LTE-NR")
- network_mode="EN-DC Mode"
- #LTE
- endc_lte_mcc=$(echo "$response" | awk -F',' '{print $3}')
- endc_lte_mnc=$(echo "$response" | awk -F',' '{print $4}')
- endc_lte_tac=$(echo "$response" | awk -F',' '{print $5}')
- endc_lte_cell_id=$(echo "$response" | awk -F',' '{print $6}')
- endc_lte_earfcn=$(echo "$response" | awk -F',' '{print $7}')
- endc_lte_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
- endc_lte_band_num=$(echo "$response" | awk -F',' '{print $9}')
- endc_lte_band=$(get_band "LTE" $endc_lte_band_num)
- ul_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
- endc_lte_ul_bandwidth=$(get_ul_bandwidth $ul_bandwidth_num)
- endc_lte_dl_bandwidth="$endc_lte_ul_bandwidth"
- endc_lte_rssnr_num=$(echo "$response" | awk -F',' '{print $11}')
- endc_lte_rssnr=$(get_rssnr $endc_lte_rssnr_num)
- endc_lte_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
- endc_lte_rxlev=$(get_rxlev "LTE" $endc_lte_rxlev_num)
- endc_lte_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
- endc_lte_rsrp=$(get_rsrp "LTE" $endc_lte_rsrp_num)
- endc_lte_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
- endc_lte_rsrq=$(get_rsrq "LTE" $endc_lte_rsrq_num)
- #NR5G-NSA
- endc_nr_mcc=$(echo "$response" | awk -F',' '{print $3}')
- endc_nr_mnc=$(echo "$response" | awk -F',' '{print $4}')
- endc_nr_tac=$(echo "$response" | awk -F',' '{print $5}')
- endc_nr_cell_id=$(echo "$response" | awk -F',' '{print $6}')
- endc_nr_arfcn=$(echo "$response" | awk -F',' '{print $7}')
- endc_nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
- endc_nr_band_num=$(echo "$response" | awk -F',' '{print $9}')
- endc_nr_band=$(get_band "NR" $endc_nr_band_num)
- nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
- endc_nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num)
- endc_nr_sinr=$(echo "$response" | awk -F',' '{print $11}')
- endc_nr_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
- endc_nr_rxlev=$(get_rxlev "NR" $endc_nr_rxlev_num)
- endc_nr_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
- endc_nr_rsrp=$(get_rsrp "NR" $endc_nr_rsrp_num)
- endc_nr_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
- endc_nr_rsrq=$(get_rsrq "NR" $endc_nr_rsrq_num)
- ;;
- "LTE"|"eMTC"|"NB-IoT")
- network_mode="LTE Mode"
- lte_mcc=$(echo "$response" | awk -F',' '{print $3}')
- lte_mnc=$(echo "$response" | awk -F',' '{print $4}')
- lte_tac=$(echo "$response" | awk -F',' '{print $5}')
- lte_cell_id=$(echo "$response" | awk -F',' '{print $6}')
- lte_earfcn=$(echo "$response" | awk -F',' '{print $7}')
- lte_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
- lte_band_num=$(echo "$response" | awk -F',' '{print $9}')
- lte_band=$(get_band "LTE" $lte_band_num)
- ul_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
- lte_ul_bandwidth=$(get_ul_bandwidth $ul_bandwidth_num)
- lte_dl_bandwidth="$lte_ul_bandwidth"
- lte_rssnr=$(echo "$response" | awk -F',' '{print $11}')
- lte_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
- lte_rxlev=$(get_rxlev "LTE" $lte_rxlev_num)
- lte_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
- lte_rsrp=$(get_rsrp "LTE" $lte_rsrp_num)
- lte_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
- lte_rsrq=$(get_rsrq "LTE" $lte_rsrq_num)
- ;;
- "WCDMA"|"UMTS")
- network_mode="WCDMA Mode"
- wcdma_mcc=$(echo "$response" | awk -F',' '{print $3}')
- wcdma_mnc=$(echo "$response" | awk -F',' '{print $4}')
- wcdma_lac=$(echo "$response" | awk -F',' '{print $5}')
- wcdma_cell_id=$(echo "$response" | awk -F',' '{print $6}')
- wcdma_uarfcn=$(echo "$response" | awk -F',' '{print $7}')
- wcdma_psc=$(echo "$response" | awk -F',' '{print $8}')
- wcdma_band_num=$(echo "$response" | awk -F',' '{print $9}')
- wcdma_band=$(get_band "WCDMA" $wcdma_band_num)
- wcdma_ecno=$(echo "$response" | awk -F',' '{print $10}')
- wcdma_rscp=$(echo "$response" | awk -F',' '{print $11}')
- wcdma_rac=$(echo "$response" | awk -F',' '{print $12}')
- wcdma_rxlev_num=$(echo "$response" | awk -F',' '{print $13}')
- wcdma_rxlev=$(get_rxlev "WCDMA" $wcdma_rxlev_num)
- wcdma_reserved=$(echo "$response" | awk -F',' '{print $14}')
- wcdma_ecio_num=$(echo "$response" | awk -F',' '{print $15}' | sed 's/\r//g')
- wcdma_ecio=$(get_ecio $wcdma_ecio_num)
- ;;
- esac
+ "LTE"|"eMTC"|"NB-IoT")
+ network_mode="LTE Mode"
+ lte_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ lte_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ lte_tac=$(echo "$response" | awk -F',' '{print $5}')
+ lte_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ lte_earfcn=$(echo "$response" | awk -F',' '{print $7}')
+ lte_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ lte_band_num=$(echo "$response" | awk -F',' '{print $9}')
+ lte_band=$(get_band "LTE" $lte_band_num)
+ ul_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
+ lte_ul_bandwidth=$(get_ul_bandwidth $ul_bandwidth_num)
+ lte_dl_bandwidth="$lte_ul_bandwidth"
+ lte_rssnr=$(echo "$response" | awk -F',' '{print $11}')
+ lte_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
+ lte_rxlev=$(get_rxlev "LTE" $lte_rxlev_num)
+ lte_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
+ lte_rsrp=$(get_rsrp "LTE" $lte_rsrp_num)
+ lte_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
+ lte_rsrq=$(get_rsrq "LTE" $lte_rsrq_num)
+ ;;
+ "WCDMA"|"UMTS")
+ network_mode="WCDMA Mode"
+ wcdma_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ wcdma_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ wcdma_lac=$(echo "$response" | awk -F',' '{print $5}')
+ wcdma_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ wcdma_uarfcn=$(echo "$response" | awk -F',' '{print $7}')
+ wcdma_psc=$(echo "$response" | awk -F',' '{print $8}')
+ wcdma_band_num=$(echo "$response" | awk -F',' '{print $9}')
+ wcdma_band=$(get_band "WCDMA" $wcdma_band_num)
+ wcdma_ecno=$(echo "$response" | awk -F',' '{print $10}')
+ wcdma_rscp=$(echo "$response" | awk -F',' '{print $11}')
+ wcdma_rac=$(echo "$response" | awk -F',' '{print $12}')
+ wcdma_rxlev_num=$(echo "$response" | awk -F',' '{print $13}')
+ wcdma_rxlev=$(get_rxlev "WCDMA" $wcdma_rxlev_num)
+ wcdma_reserved=$(echo "$response" | awk -F',' '{print $14}')
+ wcdma_ecio_num=$(echo "$response" | awk -F',' '{print $15}' | sed 's/\r//g')
+ wcdma_ecio=$(get_ecio $wcdma_ecio_num)
+ ;;
+ esac
}
@@ -523,20 +524,23 @@ get_fibocom_info()
#基本信息
fibocom_base_info
- #获取SIM状态
- sim_status=$(get_fibocom_sim_status)
- if [ "$sim_status" != "ready" ];then
+ #SIM卡信息
+ fibocom_sim_info
+ if [ "$sim_status" != "ready" ]; then
return
fi
- #SIM卡信息
- fibocom_sim_info
#网络信息
fibocom_network_info
+ if [ "$connect_status" != "connect" ]; then
+ return
+ fi
+
#小区信息
fibocom_cell_info
return
+
# Fibocom_Cellinfo
#基站信息
diff --git a/luci-app-modem/root/usr/share/modem/modem_info.sh b/luci-app-modem/root/usr/share/modem/modem_info.sh
index 625eab6..6f685fd 100755
--- a/luci-app-modem/root/usr/share/modem/modem_info.sh
+++ b/luci-app-modem/root/usr/share/modem/modem_info.sh
@@ -15,17 +15,19 @@ init_modem_info()
at_port='-' #AT串口
mode='unknown' #拨号模式
temperature="NaN $(printf "\xc2\xb0")C" #温度
- update_time='' #更新时间
+ update_time='-' #更新时间
#SIM卡信息
sim_status="miss" #SIM卡状态
+ sim_slot="-" #SIM卡卡槽
isp="-" #运营商(互联网服务提供商)
+ sim_number='-' #SIM卡号码(手机号)
imei='-' #IMEI
imsi='-' #IMSI
iccid='-' #ICCID
- sim_number='-' #SIM卡号码(手机号)
#网络信息
+ connect_status="disconnect" #SIM卡状态
network_type="-" #蜂窝网络类型
#小区信息
@@ -131,8 +133,8 @@ init_modem_info()
qos="" #最大Qos级别
}
-#获取基本信息
-get_base_info()
+#设置基本信息
+set_base_info()
{
base_info="\"base_info\":{
\"manufacturer\":\"$manufacturer\",
@@ -144,28 +146,44 @@ get_base_info()
},"
}
-#获取SIM卡信息
-get_sim_info()
+#设置SIM卡信息
+set_sim_info()
{
- sim_info="\"sim_info\":{
- \"isp\":\"$isp\",
- \"imei\":\"$imei\",
- \"imsi\":\"$imsi\",
- \"iccid\":\"$iccid\",
- \"sim_number\":\"$sim_number\"
- },"
+ if [ "$sim_status" = "ready" ]; then
+ sim_info="\"sim_info\":[
+ {\"ISP\":\"$isp\", \"full_name\":\"Internet Service Provider\"},
+ {\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"},
+ {\"SIM Number\":\"$sim_number\", \"full_name\":\"SIM Number\"},
+ {\"IMEI\":\"$imei\", \"full_name\":\"International Mobile Equipment Identity\"},
+ {\"IMSI\":\"$imsi\", \"full_name\":\"International Mobile Subscriber Identity\"},
+ {\"ICCID\":\"$iccid\", \"full_name\":\"Integrate Circuit Card Identity\"}
+ ],"
+ elif [ "$sim_status" = "miss" ]; then
+ sim_info="\"sim_info\":[
+ {\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
+ {\"IMEI\":\"$imei\", \"full_name\":\"International Mobile Equipment Identity\"}
+ ],"
+ elif [ "$sim_status" = "locked" ]; then
+ sim_info="\"sim_info\":[
+ {\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
+ {\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"},
+ {\"IMEI\":\"$imei\", \"full_name\":\"International Mobile Equipment Identity\"},
+ {\"IMSI\":\"$imsi\", \"full_name\":\"International Mobile Subscriber Identity\"},
+ {\"ICCID\":\"$iccid\", \"full_name\":\"Integrate Circuit Card Identity\"}
+ ],"
+ fi
}
-#获取网络信息
-get_network_info()
+#设置网络信息
+set_network_info()
{
network_info="\"network_info\":{
\"network_type\":\"$network_type\"
},"
}
-#获取信号信息
-get_cell_info()
+#设置信号信息
+set_cell_info()
{
if [ "$network_mode" = "NR5G-SA Mode" ]; then
cell_info="\"cell_info\":{
@@ -284,16 +302,17 @@ info_to_json()
network_info="\"network_info\":{},"
cell_info="\"cell_info\":{}"
- #获取基本信息
- get_base_info
+ #设置基本信息
+ set_base_info
- if [ "$sim_status" = "ready" ];then
- #获取SIM卡信息
- get_sim_info
- #获取网络信息
- get_network_info
- #获取小区信息
- get_cell_info
+ #设置SIM卡信息
+ set_sim_info
+
+ if [ "$sim_status" = "ready" ] && [ "$connect_status" = "connect" ]; then
+ #设置网络信息
+ set_network_info
+ #设置小区信息
+ set_cell_info
fi
#拼接所有信息(不要漏掉最后一个})
diff --git a/luci-app-modem/root/usr/share/modem/quectel.sh b/luci-app-modem/root/usr/share/modem/quectel.sh
index 3f89fe6..2585535 100755
--- a/luci-app-modem/root/usr/share/modem/quectel.sh
+++ b/luci-app-modem/root/usr/share/modem/quectel.sh
@@ -6,7 +6,7 @@ current_dir="$(dirname "$0")"
get_quectel_mode()
{
local at_port="$1"
- local at_command='AT+QCFG="usbnet"'
+ at_command='AT+QCFG="usbnet"'
local mode_num=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+QCFG: "usbnet",//g' | sed 's/\r//g')
local mode
@@ -27,10 +27,11 @@ get_quectel_mode()
get_connect_status()
{
local at_port="$1"
- local at_command="AT+QNWINFO"
+ at_command="AT+QNWINFO"
local response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
+ local connect_status
if [[ "$response" = *"No Service"* ]]; then
connect_status="disconnect"
else
@@ -40,51 +41,25 @@ get_connect_status()
echo "$connect_status"
}
-#获取SIM卡状态
-get_quectel_sim_status()
-{
- debug "检查SIM状态"
- local sim_status
-
- local at_command="AT+CPIN?"
- local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
- local sim_error=$(echo "$response" | grep "ERROR")
- if [ -n "$sim_error" ]; then
- debug "未插入SIM卡"
- sim_status="miss"
- return
- fi
- local sim_ready=$(echo "$response" | grep "READY")
- if [ -n "$sim_ready" ]; then
- debug "SIM卡正常"
- sim_status="ready"
- else
- debug "SIM卡被锁定"
- sim_status="locked"
- return
- fi
- echo "$sim_status"
-}
-
#基本信息
quectel_base_info()
{
debug "Quectel base info"
- local at_command="ATI"
- local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+ at_command="ATI"
+ response=$(sh $current_dir/modem_at.sh $at_port $at_command)
- #名称
+ #Name(名称)
name=$(echo "$response" | sed -n '3p' | sed 's/\r//g')
- #制造商
+ #Manufacturer(制造商)
manufacturer=$(echo "$response" | sed -n '2p' | sed 's/\r//g')
- #固件版本
+ #Revision(固件版本)
revision=$(echo "$response" | sed -n '4p' | sed 's/Revision: //g' | sed 's/\r//g')
- #拨号模式
+ #Mode(拨号模式)
mode=$(get_quectel_mode $at_port | tr 'a-z' 'A-Z')
- #温度
+ #Temperature(温度)
at_command="AT+QTEMP"
response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}')
if [ -n "$response" ]; then
@@ -111,8 +86,31 @@ quectel_sim_info()
{
debug "Quectel sim info"
+ #SIM Slot(SIM卡卡槽)
+ at_command="AT+QUIMSLOT?"
+ sim_slot=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F' ' '{print $2}' | sed 's/\r//g')
+
+ #IMEI(国际移动设备识别码)
+ at_command="AT+CGSN"
+ imei=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
+
+ #SIM Status(SIM状态)
+ at_command="AT+CPIN?"
+ response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
+ if [[ "$response" = *"READY"* ]]; then
+ sim_status="ready"
+ elif [ "$response" = "" ]; then
+ sim_status="miss"
+ else
+ sim_status="locked"
+ fi
+
+ if [ "$sim_status" != "ready" ]; then
+ return
+ fi
+
#ISP(互联网服务提供商)
- local at_command="AT+COPS?"
+ at_command="AT+COPS?"
isp=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
# if [ "$isp" = "CHN-CMCC" ] || [ "$isp" = "CMCC" ]|| [ "$isp" = "46000" ]; then
# isp="中国移动"
@@ -124,21 +122,17 @@ quectel_sim_info()
# isp="中国电信"
# fi
- #IMEI
- at_command="AT+CGSN"
- imei=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
+ #SIM Number(SIM卡号码,手机号)
+ at_command="AT+CNUM"
+ sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}')
- #IMSI
+ #IMSI(国际移动用户识别码)
at_command="AT+CIMI"
imsi=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
- #ICCID
+ #ICCID(集成电路卡识别码)
at_command="AT+ICCID"
# iccid=$(sh $current_dir/modem_at.sh $at_port $at_command | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}")
-
- #SIM卡号码(手机号)
- at_command="AT+CNUM"
- sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}')
}
#网络信息
@@ -146,9 +140,15 @@ quectel_network_info()
{
debug "Quectel network info"
+ #Connect Status(连接状态)
+ connect_status=$(get_connect_status $at_port)
+ if [ "$connect_status" != "connect" ]; then
+ return
+ fi
+
#Network Type(网络类型)
- # local at_command="AT+COPS?"
- local at_command="AT+QNWINFO"
+ # at_command="AT+COPS?"
+ at_command="AT+QNWINFO"
network_type=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
#CSQ
@@ -176,9 +176,9 @@ get_band()
{
local band
case $1 in
- "WCDMA") band="B$2" ;;
- "LTE") band="B$2" ;;
- "NR") band="N$2" ;;
+ "WCDMA") band="$2" ;;
+ "LTE") band="$2" ;;
+ "NR") band="$2" ;;
esac
echo "$band"
}
@@ -280,9 +280,9 @@ quectel_cell_info()
{
debug "Quectel cell info"
- local at_command='AT+QENG="servingcell"'
- local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
-
+ at_command='AT+QENG="servingcell"'
+ response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+
local lte=$(echo "$response" | grep "+QENG: \"LTE\"")
local nr5g_nsa=$(echo "$response" | grep "+QENG: \"NR5G-NSA\"")
if [ -n "$lte" ] && [ -n "$nr5g_nsa" ] ; then
@@ -708,16 +708,18 @@ get_quectel_info()
#基本信息
quectel_base_info
- #获取SIM状态
- sim_status=$(get_quectel_sim_status)
- if [ "$sim_status" != "ready" ];then
+ #SIM卡信息
+ quectel_sim_info
+ if [ "$sim_status" != "ready" ]; then
return
fi
- #SIM卡信息
- quectel_sim_info
#网络信息
quectel_network_info
+ if [ "$connect_status" != "connect" ]; then
+ return
+ fi
+
#小区信息
quectel_cell_info