From 909730265e45b6289d04fbdcdf0053d8a419fb52 Mon Sep 17 00:00:00 2001 From: fujr Date: Mon, 6 May 2024 16:47:10 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E4=BF=AE=E6=94=B9=E9=94=81=E5=B0=8F?= =?UTF-8?q?=E5=8C=BA=E3=80=81=E9=A2=91=E7=82=B9=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=A7=BB=E8=BF=9C=E9=94=81=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E3=80=81=E9=94=81=E9=A2=91=E6=94=AF=E6=8C=81=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=83=A8=E5=88=86=E9=A1=B5=E9=9D=A2=E5=8E=9F=E4=BD=9C?= =?UTF-8?q?=E8=80=85=20xhr=E6=B8=85=E9=99=A4=E7=94=A8=E6=88=B7=E6=AD=A3?= =?UTF-8?q?=E5=9C=A8=E7=BC=96=E8=BE=91=E9=85=8D=E7=BD=AE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luci-app-modem/luasrc/controller/modem.lua | 45 +-- .../luasrc/view/modem/modem_debug.htm | 205 +++++------ luci-app-modem/root/etc/config/modem | 11 +- .../root/usr/share/modem/fibocom.sh | 40 +++ .../root/usr/share/modem/quectel.sh | 331 +++++++++++++++++- 5 files changed, 483 insertions(+), 149 deletions(-) diff --git a/luci-app-modem/luasrc/controller/modem.lua b/luci-app-modem/luasrc/controller/modem.lua index 911f5b4..2f5da63 100644 --- a/luci-app-modem/luasrc/controller/modem.lua +++ b/luci-app-modem/luasrc/controller/modem.lua @@ -655,38 +655,21 @@ end function setLockCell() local at_port = http.formvalue("port") local manufacturer = getManufacturer(at_port) - local pci = http.formvalue("pci") - local arfcn = http.formvalue("arfcn") - local scs = http.formvalue("scs") --0:15KHz 1:30KHz 2:60KHz - local nrband = http.formvalue("nrband") - local celltype = http.formvalue("celltype") --0:LTE 1:NR - local lock = http.formvalue("lock") --0:unlock 1:lock_pci 2:lock_arfcn 3:lock_self + local func = http.formvalue("func") + local pci = http.formvalue("pci") == nil and 0 or http.formvalue("pci") + local arfcn = http.formvalue("arfcn") == nil and 0 or http.formvalue("arfcn") + local scs = http.formvalue("scs") == nil and 0 or http.formvalue("scs") + local nrband = http.formvalue("nrband") == nil and 0 or http.formvalue("nrband") + local celltype = http.formvalue("celltype") == nil and 0 or http.formvalue("celltype") response={} - if (lock == "0") then - local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_unlockcell "..at_port - local result=shell(command) - response["response"]=result - response["time"]=os.date("%Y-%m-%d %H:%M:%S") - response["lock"]=0 - elseif (lock == "1") then - local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_lockpci "..at_port.." "..celltype.." "..arfcn.." "..pci.." "..scs.." "..nrband - local result=shell(command) - response["response"]=result - response["time"]=os.date("%Y-%m-%d %H:%M:%S") - response["lock"]="pci" - elseif (lock == "2") then - local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_lockarfcn "..at_port.." "..celltype.." "..arfcn - local result=shell(command) - response["response"]=result - response["time"]=os.date("%Y-%m-%d %H:%M:%S") - response["lock"]="arfcn" - elseif (lock == "3") then - local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_lockcurrent "..at_port - local result=shell(command) - response["response"]=result - response["time"]=os.date("%Y-%m-%d %H:%M:%S") - response["lock"]="self" - end + + local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_setlockcell "..at_port.." "..func .." "..celltype.." "..arfcn.." "..pci.." "..scs.." "..nrband + local command=string.format("source %s%s.sh && %s_setlockcell \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",script_path,manufacturer,manufacturer,at_port,func,celltype,arfcn,pci,scs,nrband) + local result=shell(command) + response["response"]=result + response["time"]=os.date("%Y-%m-%d %H:%M:%S") + response["lock"]="pci" + luci.http.prepare_content("application/json") luci.http.write_json(response) end diff --git a/luci-app-modem/luasrc/view/modem/modem_debug.htm b/luci-app-modem/luasrc/view/modem/modem_debug.htm index d07c0ac..0ad4c91 100644 --- a/luci-app-modem/luasrc/view/modem/modem_debug.htm +++ b/luci-app-modem/luasrc/view/modem/modem_debug.htm @@ -46,6 +46,7 @@ } + //设置标签菜单事件 function set_tab_event(parent_element) { @@ -55,6 +56,8 @@ for (var i = 0; i < childElements.length; i++) { childElements[i].addEventListener('click', function (event) { tab_event(this); + //remove_dont_edit_flag + document.getElementById("tab_menu").removeAttribute("dont_edit"); var debug_params = { first_cache: true }; get_modem_debug_info(debug_params); }); @@ -399,8 +402,9 @@ //设置当前拨号模式 document.getElementById('current_mode').innerHTML = current_mode_view; - - if (first_cache) { + dont_edit_flag = document.getElementById("tab_menu").getAttribute("dont_edit"); + if (dont_edit_flag == null) { + document.getElementById("tab_menu").setAttribute("dont_edit", "true"); //设置支持的拨号模式 var mode_option_view = ''; for (mode of modes) { @@ -416,8 +420,6 @@ //设置拨号模式选项 element = document.getElementById('mode_option_' + current_mode).checked = true; - //设置第一次获取数据标志 - first_cache = false; } } @@ -469,21 +471,18 @@ //获取偏好视图 var current_prefer_view = get_current_prefer_view(network_prefer); - - //设置偏好选项和复选框 - if (first_cache) { - //更新偏好配置 - for (key in network_prefer) { + dont_edit_flag = document.getElementById("tab_menu").getAttribute("dont_edit"); + if (dont_edit_flag == null) { + document.getElementById("tab_menu").setAttribute("dont_edit", "true"); + for (key in network_prefer) { //设置偏好配置 var prefer_config_element = document.getElementById('prefer_config_' + key.toLowerCase()); if (prefer_config_element != null) { prefer_config_element.checked = network_prefer[key]; } } - } - - //设置第一次获取数据标志 - first_cache = false; + + } } function set_lockband_info(lockband_info, first_cache) { @@ -495,7 +494,8 @@ //设置偏好选项和复选框 if (first_cache) { - for (key in avalible_lockband) { + sortted_keys = Object.keys(avalible_lockband).sort(); + for (key of sortted_keys) { id = "lockband_config_" + key; checkbox_get = document.getElementById(id); if (checkbox_get == null) { @@ -595,6 +595,7 @@ // 设置网络偏好 function set_network_prefer() { //禁用功能 + disabled_function("network_prefer", true); //获取选中的模组 @@ -603,10 +604,11 @@ //获取偏好配置 var network_prefer_config = {}; var checkboxes = document.getElementById('prefer_custom_config').querySelectorAll('input[type="checkbox"]'); - for (checkbox of checkboxes) { - network_prefer_config[checkbox.value.toUpperCase()] = Number(checkbox.checked); - } - + + for (checkbox of checkboxes) { + network_prefer_config[checkbox.value.toUpperCase()] = Number(checkbox.checked); + } + //设置偏好 XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "set_network_prefer")%>', { "port": at_port, "prefer_config": network_prefer_config }, function (x, data) { @@ -650,7 +652,6 @@ if (checkbox_get == null) { checkbox_span = document.createElement('span'); checkbox_span.className = "cbi-checkbox"; - checkbox = document.createElement('input'); checkbox.id = "lockband_config_" + key; checkbox.name = "lockband_option"; @@ -711,7 +712,6 @@ if (Object.keys(network_prefer_info).length == 0) { return false } - //设置网络偏好信息 set_network_prefer_info(network_prefer_info, debug_params.first_cache); } @@ -744,57 +744,6 @@ } } - function unlock_cell() { - var at_port = document.getElementById("modem_select").value; - XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "set_lock_cell")%>', { "port": at_port, "lock": "0" }, - function (x, data) { - console.log(data["response"]); - update_cell_config(); - } - ); - - } - - function lock_current_cell() { - var at_port = document.getElementById("modem_select").value; - XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "set_lock_cell")%>', { "port": at_port, "lock": "3" }, - function (x, data) { - console.log(data["response"]); - update_cell_config(); - } - ); - - } - - function lock_pci() { - var at_port = document.getElementById("modem_select").value; - var pci = document.getElementById("pci_input").value; - var arfcn = document.getElementById("arfcn_input").value; - var rat = document.getElementById("rat_select").value; - var scs = document.getElementById("scs_select").value; - var nrband = document.getElementById("nrband_input").value; - XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "set_lock_cell")%>', { "port": at_port, "lock": "1", "pci": pci, "arfcn": arfcn, "celltype": rat , "scs": scs, "nrband": nrband}, - function (x, data) { - console.log(data["response"]); - update_cell_config(); - } - ); - - } - - function lock_arfcn() { - var at_port = document.getElementById("modem_select").value; - var arfcn = document.getElementById("arfcn_input").value; - var rat = document.getElementById("rat_select").value; - XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "set_lock_cell")%>', { "port": at_port, "lock": "2", "arfcn": arfcn, "celltype": rat }, - function (x, data) { - console.log(data["response"]); - update_cell_config(); - } - ); - - } - // 更新neighbor cell信息 function update_cell_config() { function onclick_copy_fun_gen(cellinfo) { @@ -819,51 +768,77 @@ neighbor_cell_info.removeChild(neighbor_cell_info.firstChild); } //add new child nodes - lte_cell = data["LTE"]; - nr_cell = data["NR"]; + lockcell_feature = data["Feature"]; + //render feature button + lockcell_feature_div = document.getElementById('lockcell_feature'); + for (key in lockcell_feature) { + v = lockcell_feature[key]; + feature_button_id = "lockcell_feature_" + v; + if (document.getElementById(feature_button_id) != null) { + continue; + } + feature_button = document.createElement('input'); + feature_button.type = "button"; + feature_button.id = feature_button_id; + feature_button.value = key; + feature_button.className = "cbi-button-apply"; + console.log("key:" + key + " feature:" + v) + feature_button.onclick = function () { + var at_port = document.getElementById("modem_select").value; + var pci = document.getElementById("pci_input").value; + var arfcn = document.getElementById("arfcn_input").value; + var rat = document.getElementById("rat_select").value; + var scs = document.getElementById("scs_select").value; + var nrband = document.getElementById("nrband_input").value; + XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "set_lock_cell")%>', { "port": at_port, "func": this.id.replace("lockcell_feature_",""), "pci": pci, "arfcn": arfcn, "celltype": rat, "scs": scs, "nrband": nrband}, + function (x, data) { + console.log(data["response"]); + update_cell_config(); + } + ); + }; + lockcell_feature_div.appendChild(feature_button); + } + lockcell_status = data["lockcell_status"]; - for (cell of lte_cell) { - cell['rat'] = "0"; - cell_tr = document.createElement('tr'); - cell_tr.className = "tr"; - cell_td_left = document.createElement('td'); - cell_td_left.className = "td"; - cell_td_left.innerHTML = `RAT: LTE PCI:${cell['pci']} ARFCN:${cell['arfcn']} RSRP:${cell['rsrp']} RSRQ:${cell['rsrq']} `; - cell_td_right = document.createElement('td'); - cell_td_right.className = "td"; - copy_botton = document.createElement('input'); - copy_botton.type = "button"; - copy_botton.innerHTML = "Copy"; - copy_botton.className = "cbi-button"; - copy_botton.value = "Copy"; - - copy_botton.onclick = onclick_copy_fun_gen(cell); - cell_td_right.appendChild(copy_botton); - cell_tr.appendChild(cell_td_left); - cell_tr.appendChild(cell_td_right); - neighbor_cell_info.appendChild(cell_tr); + neighbor_cells = { + "LTE" : data["LTE"], + "NR" : data["NR"] } - for (cell of nr_cell) { - cell['rat'] = "1"; - cell_tr = document.createElement('tr'); - cell_tr.className = "tr"; - cell_td_left = document.createElement('td'); - cell_td_left.className = "td"; - cell_td_left.innerHTML = `RAT: LTE PCI:${cell['pci']} ARFCN:${cell['arfcn']} RSRP:${cell['rsrp']} RSRQ:${cell['rsrq']} `; - cell_td_right = document.createElement('td'); - cell_td_right.className = "td"; - copy_botton = document.createElement('input'); - copy_botton.type = "button"; - copy_botton.innerHTML = "Copy"; - copy_botton.className = "cbi-button"; - copy_botton.value = "Copy"; + for (type in neighbor_cells) { + for (cell_info of neighbor_cells[type]) { + + rat = type == "LTE" ? 0 : 1; + cell_info["rat"] = rat; + innerHTML = `RAT:${type} ` + console.log(innerHTML) + for (cell_info_key in cell_info){ + if (cell_info[cell_info_key] == "") { + continue + } + innerHTML += `${cell_info_key}:${cell_info[cell_info_key]} ` + } + cell_tr = document.createElement('tr'); + cell_tr.className = "tr"; + cell_td_left = document.createElement('td'); + cell_td_left.className = "td"; + cell_td_left.innerHTML = innerHTML; + cell_td_right = document.createElement('td'); + cell_td_right.className = "td"; + copy_botton = document.createElement('input'); + copy_botton.type = "button"; + copy_botton.innerHTML = "Copy"; + copy_botton.className = "cbi-button"; + copy_botton.value = "Copy"; - copy_botton.onclick = onclick_fun_gen(cell); - cell_td_right.appendChild(copy_botton); - cell_tr.appendChild(cell_td_left); - cell_tr.appendChild(cell_td_right); - neighbor_cell_info.appendChild(cell_tr); + copy_botton.onclick = onclick_copy_fun_gen(cell_info); + cell_td_right.appendChild(copy_botton); + cell_tr.appendChild(cell_td_left); + cell_tr.appendChild(cell_td_right); + neighbor_cell_info.appendChild(cell_tr); + } } + lockcell_status_div = document.getElementById('current_cell_status'); childElements = lockcell_status_div.childNodes; keys = Object.keys(lockcell_status); @@ -1341,15 +1316,15 @@ <%:Submit%> -
- +
diff --git a/luci-app-modem/root/etc/config/modem b/luci-app-modem/root/etc/config/modem index 4021139..754b0d5 100644 --- a/luci-app-modem/root/etc/config/modem +++ b/luci-app-modem/root/etc/config/modem @@ -246,4 +246,13 @@ config custom-commands config custom-commands option description '重置模组 > AT+CFUN=15' - option command 'AT+CFUN=15' \ No newline at end of file + option command 'AT+CFUN=15' + + +config dial-config 'defa0' + option network_bridge '0' + option enable '1' + option network 'wwan0' + option pdp_type 'ipv4v6' + option auth 'none' + option id 'defa0' diff --git a/luci-app-modem/root/usr/share/modem/fibocom.sh b/luci-app-modem/root/usr/share/modem/fibocom.sh index 848166d..856c46e 100755 --- a/luci-app-modem/root/usr/share/modem/fibocom.sh +++ b/luci-app-modem/root/usr/share/modem/fibocom.sh @@ -636,6 +636,13 @@ fibocom_get_neighborcell() get_lockcell_command="AT+GTCELLLOCK?" cell_type="undefined" json_init + json_add_object "Feature" + json_add_string "unlockcell" "1" + json_add_string "lockpci" "2" + json_add_string "lockarfcn" "3" + json_add_string "lockcurrent" "4" + json_add_string "reboot modem" "5" + json_close_object json_add_array "NR" json_close_array json_add_array "LTE" @@ -752,6 +759,39 @@ fibocom_get_neighborcell() json_dump } +fibocom_setlockcell(){ + #at_port,func,celltype,arfcn,pci,scs,nrband + # "unlockcell" "1" + # "lockpci" "2" + # "lockarfcn" "3" + # "lockcurrent" "4" + # "reboot modem" "5" + local at_port="$1" + local func="$2" + local cell_type="$3" + local arfcn="$4" + local pci="$5" + local scs="$6" + local nrband="$7" + case $func in + "1") + fibocom_unlockcell $at_port + ;; + "2") + fibocom_lockpci $at_port $cell_type $arfcn $pci $scs $nrband + ;; + "3") + fibocom_lockarfcn $at_port $cell_type $arfcn + ;; + "4") + fibocom_lockcurrent $at_port + ;; + "5") + sh ${SCRIPT_DIR}/modem_reboot.sh $at_port at+cfun=1,1 + ;; + esac +} + fibocom_unlockcell() { local at_port="$1" diff --git a/luci-app-modem/root/usr/share/modem/quectel.sh b/luci-app-modem/root/usr/share/modem/quectel.sh index 6cdddfd..31de39a 100755 --- a/luci-app-modem/root/usr/share/modem/quectel.sh +++ b/luci-app-modem/root/usr/share/modem/quectel.sh @@ -3,7 +3,7 @@ #脚本目录 SCRIPT_DIR="/usr/share/modem" - +source /usr/share/libubox/jshn.sh #预设 quectel_presets() { @@ -534,6 +534,333 @@ quectel_get_band() echo "$band" } +quectel_get_lockband_qualcomm() +{ + local at_port="$1" + debug "Quectel sdx55 get lockband info" + get_wcdma_config_command='AT+QNWPREFCFG="gw_band"' + get_lte_config_command='AT+QNWPREFCFG="lte_band"' + get_nsa_nr_config_command='AT+QNWPREFCFG="nsa_nr5g_band"' + get_sa_nr_config_command='AT+QNWPREFCFG="nr5g_band"' + wcdma_avalible_band="1,2,3,4,5,6,7,8,9,19" + lte_avalible_band="1,2,3,4,5,7,8,12,13,14,17,18,19,20,25,26,28,29,30,32,34,38,39,40,41,42,66,71" + nsa_nr_avalible_band="1,2,3,5,7,8,12,20,25,28,38,40,41,48,66,71,77,78,79,257,258,260,261" + sa_nr_avalible_band="1,2,3,5,7,8,12,20,25,28,38,40,41,48,66,71,77,78,79" + gw_band=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $get_wcdma_config_command |grep -e "+QNWPREFCFG: " ) + lte_band=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $get_lte_config_command|grep -e "+QNWPREFCFG: ") + nsa_nr_band=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $get_nsa_nr_config_command|grep -e "+QNWPREFCFG: ") + sa_nr_band=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $get_sa_nr_config_command|grep -e "+QNWPREFCFG: ") + json_init + json_add_object "available_band" + for i in $(echo "$wcdma_avalible_band" | awk -F"," '{for(j=1; j<=NF; j++) print $j}'); do + json_add_string "UMTS_$i" "UMTS_$i" + done + for i in $(echo "$lte_avalible_band" | awk -F"," '{for(j=1; j<=NF; j++) print $j}'); do + json_add_string "LTE_B$i" "LTE_B$i" + done + for i in $(echo "$nsa_nr_avalible_band" | awk -F"," '{for(j=1; j<=NF; j++) print $j}'); do + json_add_string "NSA_NR_N$i" "NSA_NR_N$i" + done + for i in $(echo "$sa_nr_avalible_band" | awk -F"," '{for(j=1; j<=NF; j++) print $j}'); do + json_add_string "SA_NR_N$i" "SA_NR_N$i" + done + json_close_object + json_add_array "lock_band" + #+QNWPREFCFG: "nr5g_band",1:3:7:20:28:40:41:71:77:78:79 + for i in $(echo "$gw_band" | cut -d, -f2 |tr -d '\r' | awk -F":" '{for(j=1; j<=NF; j++) print $j}'); do + if [ -n "$i" ]; then + json_add_string "" "UMTS_$i" + fi + done + for i in $(echo "$lte_band" | cut -d, -f2|tr -d '\r' | awk -F":" '{for(j=1; j<=NF; j++) print $j}'); do + if [ -n "$i" ]; then + json_add_string "" "LTE_B$i" + fi + done + for i in $(echo "$nsa_nr_band" | cut -d, -f2|tr -d '\r' | awk -F":" '{for(j=1; j<=NF; j++) print $j}'); do + if [ -n "$i" ]; then + json_add_string "" "NSA_NR_N$i" + fi + done + for i in $(echo "$sa_nr_band" | cut -d, -f2|tr -d '\r' | awk -F":" '{for(j=1; j<=NF; j++) print $j}'); do + if [ -n "$i" ]; then + json_add_string "" "SA_NR_N$i" + fi + done + json_close_array + json_result=`json_dump` + echo "$json_result" +} + +quectel_get_lockband() +{ + local at_port="$1" + + local platform + local modem_number=$(uci -q get modem.@global[0].modem_number) + for i in $(seq 0 $((modem_number-1))); do + local at_port_tmp=$(uci -q get modem.modem$i.at_port) + if [ "$at_port" = "$at_port_tmp" ]; then + platform=$(uci -q get modem.modem$i.platform) + break + fi + done + case "$platform" in + "qualcomm") + quectel_get_lockband_qualcomm $at_port + ;; + "unisoc") + quectel_get_lockband_unisoc $at_port + ;; + *) + echo "unknown" + ;; + esac +} + + +quectel_set_lockband_qualcomm(){ + local at_port="$1" + local lock_band="$2" + gw_band="" + lte_band="" + nsa_nr_band="" + sa_nr_band="" + for i in $(echo $2 | awk -F"," '{for(j=1; j<=NF; j++) print $j}' );do + num_match=$(echo $i | grep -o "[0-9]\+") + case "$i" in + UMTS_*) + if [ -z "$gw_band" ]; then + gw_band=$num_match + else + gw_band=$gw_band:$num_match + fi + ;; + LTE_B*) + if [ -z "$lte_band" ]; then + lte_band=$num_match + else + lte_band=$lte_band:$num_match + fi + ;; + NSA_NR_N*) + if [ -z "$nsa_nr_band" ]; then + nsa_nr_band=$num_match + else + nsa_nr_band=$nsa_nr_band:$num_match + fi + ;; + SA_NR_N*) + if [ -z "$sa_nr_band" ]; then + sa_nr_band=$num_match + else + sa_nr_band=$sa_nr_band:$num_match + fi + ;; + esac + done + if [ -n "$gw_band" ]; then + at_command="AT+QNWPREFCFG=\"gw_band\",$gw_band" + res1=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $at_command) + fi + if [ -n "$lte_band" ]; then + at_command="AT+QNWPREFCFG=\"lte_band\",$lte_band" + res2=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $at_command) + fi + if [ -n "$nsa_nr_band" ]; then + at_command="AT+QNWPREFCFG=\"nsa_nr5g_band\",$nsa_nr_band" + res3=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $at_command) + fi + if [ -n "$sa_nr_band" ]; then + at_command="AT+QNWPREFCFG=\"nr5g_band\",$sa_nr_band" + res4=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $at_command) + fi + json_init + json_add_string result1 "$res1" + json_add_string result2 "$res2" + json_add_string result3 "$res3" + json_add_string result4 "$res4" + json_result=`json_dump` + echo "$json_result" +} +#设置锁频 +quectel_set_lockband() +{ + debug "quectel set lockband info" + local at_port="$1" + local platform + local modem_number=$(uci -q get modem.@global[0].modem_number) + for i in $(seq 0 $((modem_number-1))); do + local at_port_tmp=$(uci -q get modem.modem$i.at_port) + if [ "$at_port" = "$at_port_tmp" ]; then + platform=$(uci -q get modem.modem$i.platform) + break + fi + done + case "$platform" in + "qualcomm") + quectel_set_lockband_qualcomm $at_port $2 + ;; + "unisoc") + quectel_set_lockband_unisoc $at_port $2 + ;; + *) + echo "unknown" + ;; + esac + +} + +quectel_get_neighborcell_qualcomm(){ + local at_port="$1" + local at_command='AT+QENG="neighbourcell"' + sh ${SCRIPT_DIR}/modem_at.sh $at_port $at_command > /tmp/quectel_neighborcell + json_init + json_add_object "Feature" + json_add_string "lockpci" "1" + json_add_string "unlockcell" "2" + json_add_string "manually search" "3" + json_add_string "reboot modem" "4" + json_close_object + json_add_array "NR" + json_close_array + json_add_array "LTE" + json_close_array + while read line; do + if [ -n "$(echo $line | grep "+QENG:")" ]; then + # +QENG: "neighbourcell intra","LTE",,,< + # RSRQ>,,,,,,,, + # …] + # [+QENG: "neighbourcell inter","LTE",,,< + # RSRQ>,,,,,,, + # …] + # [+QENG:"neighbourcell","WCDMA",,,,,,, + # …] + line=$(echo $line | sed 's/+QENG: //g') + case $line in + *WCDMA*) + type="WCDMA" + + arfcn=$(echo $line | awk -F',' '{print $3}') + pci=$(echo $line | awk -F',' '{print $4}') + rscp=$(echo $line | awk -F',' '{print $6}') + ecno=$(echo $line | awk -F',' '{print $7}') + ;; + *LTE*) + type="LTE" + neighbourcell=$(echo $line | awk -F',' '{print $1}' | tr -d '"') + arfcn=$(echo $line | awk -F',' '{print $3}') + pci=$(echo $line | awk -F',' '{print $4}') + rsrp=$(echo $line | awk -F',' '{print $5}') + rsrq=$(echo $line | awk -F',' '{print $6}') + + ;; + *NR*) + type="NR" + arfcn=$(echo $line | awk -F',' '{print $3}') + pci=$(echo $line | awk -F',' '{print $4}') + rsrp=$(echo $line | awk -F',' '{print $5}') + rsrq=$(echo $line | awk -F',' '{print $6}') + ;; + esac + json_select $type + json_add_object "" + json_add_string "neighbourcell" "$neighbourcell" + json_add_string "arfcn" "$arfcn" + json_add_string "pci" "$pci" + json_add_string "rscp" "$rscp" + json_add_string "ecno" "$ecno" + json_add_string "rsrp" "$rsrp" + json_add_string "rsrq" "$rsrq" + json_close_object + json_select ".." + fi + done < /tmp/quectel_neighborcell + json_result=`json_dump` + echo "$json_result" +} + +quectel_get_neighborcell(){ + debug "quectel set lockband info" + local at_port="$1" + local platform + local modem_number=$(uci -q get modem.@global[0].modem_number) + for i in $(seq 0 $((modem_number-1))); do + local at_port_tmp=$(uci -q get modem.modem$i.at_port) + if [ "$at_port" = "$at_port_tmp" ]; then + platform=$(uci -q get modem.modem$i.platform) + break + fi + done + case "$platform" in + "qualcomm") + quectel_get_neighborcell_qualcomm $at_port $2 + ;; + "unisoc") + quectel_get_neighborcell_unisoc $at_port $2 + ;; + *) + echo "unknown" + ;; + esac +} + +quectel_setlockcell(){ + #at_port,func,celltype,arfcn,pci,scs,nrband + # "lockpci" "1" + # "unlockcell" "2" + # "manually search" "3" + # "reboot modem" "4" + local at_port="$1" + local func="$2" + local cell_type="$3" + local arfcn="$4" + local pci="$5" + local scs="$6" + local nrband="$7" + case $func in + "1") + quectel_lockpci $at_port + ;; + "2") + quectel_unlockcell $at_port $cell_type $arfcn $pci $scs $nrband + ;; + + "4") + sh ${SCRIPT_DIR}/modem_reboot.sh $at_port at+cfun=1,1 + ;; + esac +} + +quectel_unlockcell(){ + unlocklte="AT+QNWLOCK=\"common/4g\",0" + unlocknr="AT+QNWLOCK=\"common/5g\",0" + res1=$(sh ${SCRIPT_DIR}/modem_at.sh $1 $unlocklte) + res2=$(sh ${SCRIPT_DIR}/modem_at.sh $1 $unlocknr) +} + +quectel_lockpci(){ + local at_port="$1" + local cell_type="$2" + local arfcn="$3" + local pci="$4" + local scs="$5" + local nrband="$6" + if [ "$cell_type" = "LTE" ]; then + locklte="AT+QNWLOCK=\"common/4g\",1,$arfcn,$pci" + res=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $locklte) + elif [ "$cell_type" = "NR" ]; then + locknr="AT+QNWLOCK=\"common/5g\",1,$arfcn,$pci,$scs,$nrband" + res=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $locknr) + fi +} + + #UL_bandwidth # $1:上行带宽数字 quectel_get_lte_ul_bandwidth() @@ -1171,4 +1498,4 @@ get_quectel_info() fi -} \ No newline at end of file +}