更新插件

This commit is contained in:
ling 2024-01-06 00:46:42 +08:00
parent c2d5737801
commit 7924809511
5 changed files with 53 additions and 28 deletions

View File

@ -44,27 +44,18 @@ function at(at_port,at_command)
end end
-- 获取模组连接状态 -- 获取模组连接状态
function getModemConnectStatus(at_port) function getModemConnectStatus(at_port,manufacturer)
local at_command="AT+CGDCONT?"
local response=at(at_port,at_command)
-- 第六个引号的索引 local connect_status="unknown"
local sixth_index=1
for i = 1, 5 do if at_port and manufacturer then
sixth_index=string.find(response,'"',sixth_index)+1 local odpall = io.popen("cd /usr/share/modem && source $(dirname \"$0\")/"..manufacturer..".sh && get_connect_status "..at_port)
connect_status = odpall:read("*a")
connect_status=string.gsub(connect_status, "\n", "")
odpall:close()
end end
-- 第七个引号的索引
local seven_index=string.find(response,'"',sixth_index+1)
-- 获取IPv4和IPv6 return connect_status
local ip=string.sub(response,sixth_index,seven_index-1)
local not_ip="0.0.0.0,0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0"
if string.find(ip,not_ip) then
return "disconnect"
else
return "connect"
end
end end
-- 获取模组基本信息 -- 获取模组基本信息
@ -76,10 +67,7 @@ function getModemBaseInfo(at_port)
--获取数据接口 --获取数据接口
local data_interface=modem_device["data_interface"]:upper() local data_interface=modem_device["data_interface"]:upper()
--获取连接状态 --获取连接状态
local connect_status="unknown" local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"])
if modem_device["at_port"] then
connect_status=getModemConnectStatus(modem_device["at_port"])
end
--设置值 --设置值
modem_base_info=modem_device modem_base_info=modem_device
@ -166,10 +154,7 @@ function getModems()
local translation={} local translation={}
uci:foreach("modem", "modem-device", function (modem_device) uci:foreach("modem", "modem-device", function (modem_device)
-- 获取连接状态 -- 获取连接状态
local connect_status="unknown" local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"])
if modem_device["at_port"] then
connect_status=getModemConnectStatus(modem_device["at_port"])
end
-- 获取翻译 -- 获取翻译
translation[connect_status]=luci.i18n.translate(connect_status) translation[connect_status]=luci.i18n.translate(connect_status)

View File

@ -27,6 +27,25 @@ get_fibocom_mode()
echo "$mode" echo "$mode"
} }
#获取连接状态
# $1:AT串口
get_connect_status()
{
local at_port="$1"
local 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"
if [ "$response" = "$not_ip" ]; then
connect_status="disconnect"
else
connect_status="connect"
fi
echo "$connect_status"
}
#获取SIM卡状态 #获取SIM卡状态
get_fibocom_sim_status() get_fibocom_sim_status()
{ {
@ -148,7 +167,7 @@ get_band()
case $1 in case $1 in
"WCDMA") band="B$2" ;; "WCDMA") band="B$2" ;;
"LTE") band="B$(($2-100))" ;; "LTE") band="B$(($2-100))" ;;
"NR") band="N$(($2-500))" ;; "NR") band="$2" band="N${band#*50}" ;;
esac esac
echo "$band" echo "$band"
} }

View File

@ -197,6 +197,7 @@ get_cell_info()
{\"Physical Cell ID\":\"$endc_lte_physical_cell_id\", \"full_name\":\"Physical Cell ID\"}, {\"Physical Cell ID\":\"$endc_lte_physical_cell_id\", \"full_name\":\"Physical Cell ID\"},
{\"EARFCN\":\"$endc_lte_earfcn\", \"full_name\":\"E-UTRA Absolute Radio Frequency Channel Number\"}, {\"EARFCN\":\"$endc_lte_earfcn\", \"full_name\":\"E-UTRA Absolute Radio Frequency Channel Number\"},
{\"Freq band indicator\":\"$endc_lte_freq_band_ind\", \"full_name\":\"Freq band indicator\"}, {\"Freq band indicator\":\"$endc_lte_freq_band_ind\", \"full_name\":\"Freq band indicator\"},
{\"Band\":\"$endc_lte_band\", \"full_name\":\"Band\"},
{\"UL Bandwidth\":\"$endc_lte_ul_bandwidth\", \"full_name\":\"UL Bandwidth\"}, {\"UL Bandwidth\":\"$endc_lte_ul_bandwidth\", \"full_name\":\"UL Bandwidth\"},
{\"DL Bandwidth\":\"$endc_lte_dl_bandwidth\", \"full_name\":\"DL Bandwidth\"}, {\"DL Bandwidth\":\"$endc_lte_dl_bandwidth\", \"full_name\":\"DL Bandwidth\"},
{\"TAC\":\"$endc_lte_tac\", \"full_name\":\"Tracking area code of cell servedby neighbor Enb\"}, {\"TAC\":\"$endc_lte_tac\", \"full_name\":\"Tracking area code of cell servedby neighbor Enb\"},
@ -236,6 +237,7 @@ get_cell_info()
{\"Physical Cell ID\":\"$lte_physical_cell_id\", \"full_name\":\"Physical Cell ID\"}, {\"Physical Cell ID\":\"$lte_physical_cell_id\", \"full_name\":\"Physical Cell ID\"},
{\"EARFCN\":\"$lte_earfcn\", \"full_name\":\"E-UTRA Absolute Radio Frequency Channel Number\"}, {\"EARFCN\":\"$lte_earfcn\", \"full_name\":\"E-UTRA Absolute Radio Frequency Channel Number\"},
{\"Freq band indicator\":\"$lte_freq_band_ind\", \"full_name\":\"Freq band indicator\"}, {\"Freq band indicator\":\"$lte_freq_band_ind\", \"full_name\":\"Freq band indicator\"},
{\"Band\":\"$lte_band\", \"full_name\":\"Band\"},
{\"UL Bandwidth\":\"$lte_ul_bandwidth\", \"full_name\":\"UL Bandwidth\"}, {\"UL Bandwidth\":\"$lte_ul_bandwidth\", \"full_name\":\"UL Bandwidth\"},
{\"DL Bandwidth\":\"$lte_dl_bandwidth\", \"full_name\":\"DL Bandwidth\"}, {\"DL Bandwidth\":\"$lte_dl_bandwidth\", \"full_name\":\"DL Bandwidth\"},
{\"TAC\":\"$lte_tac\", \"full_name\":\"Tracking area code of cell servedby neighbor Enb\"}, {\"TAC\":\"$lte_tac\", \"full_name\":\"Tracking area code of cell servedby neighbor Enb\"},
@ -259,6 +261,7 @@ get_cell_info()
{\"UARFCN\":\"$wcdma_uarfcn\", \"full_name\":\"UTRA Absolute Radio Frequency Channel Number\"}, {\"UARFCN\":\"$wcdma_uarfcn\", \"full_name\":\"UTRA Absolute Radio Frequency Channel Number\"},
{\"PSC\":\"$wcdma_psc\", \"full_name\":\"Primary Scrambling Code\"}, {\"PSC\":\"$wcdma_psc\", \"full_name\":\"Primary Scrambling Code\"},
{\"RAC\":\"$wcdma_rac\", \"full_name\":\"Routing Area Code\"}, {\"RAC\":\"$wcdma_rac\", \"full_name\":\"Routing Area Code\"},
{\"Band\":\"$wcdma_band\", \"full_name\":\"Band\"},
{\"RSCP\":\"$wcdma_rscp\", \"full_name\":\"Received Signal Code Power\"}, {\"RSCP\":\"$wcdma_rscp\", \"full_name\":\"Received Signal Code Power\"},
{\"Ec/Io\":\"$wcdma_ecio\", \"full_name\":\"Ec/Io\"}, {\"Ec/Io\":\"$wcdma_ecio\", \"full_name\":\"Ec/Io\"},
{\"Ec/No\":\"$wcdma_ecno\", \"full_name\":\"Ec/No\"}, {\"Ec/No\":\"$wcdma_ecno\", \"full_name\":\"Ec/No\"},

View File

@ -22,6 +22,24 @@ get_quectel_mode()
echo "$mode" echo "$mode"
} }
#获取连接状态
# $1:AT串口
get_connect_status()
{
local at_port="$1"
local at_command="AT+QNWINFO"
local response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
if [[ "$response" = *"No Service"* ]]; then
connect_status="disconnect"
else
connect_status="connect"
fi
echo "$connect_status"
}
#获取SIM卡状态 #获取SIM卡状态
get_quectel_sim_status() get_quectel_sim_status()
{ {