diff --git a/driver/quectel_MHI/src/controllers/mhi_qti.c b/driver/quectel_MHI/src/controllers/mhi_qti.c index 9090fbb..3aebff3 100644 --- a/driver/quectel_MHI/src/controllers/mhi_qti.c +++ b/driver/quectel_MHI/src/controllers/mhi_qti.c @@ -1070,6 +1070,7 @@ static struct pci_device_id mhi_pcie_device_id[] = { {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0308)}, //SDX62 {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x011a)}, //SDX35 {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0309)}, //SDX7X + {PCI_DEVICE(PCI_VENDOR_ID_FOXCONN, 0xe0f5)}, //FOXCONN SDX6X {PCI_DEVICE(0x1eac, 0x1001)}, //EM120 {PCI_DEVICE(0x1eac, 0x1002)}, //EM160 {PCI_DEVICE(0x1eac, 0x1004)}, //RM520 diff --git a/driver/quectel_MHI/src/controllers/mhi_qti.h b/driver/quectel_MHI/src/controllers/mhi_qti.h index 7ac021a..2477c6d 100644 --- a/driver/quectel_MHI/src/controllers/mhi_qti.h +++ b/driver/quectel_MHI/src/controllers/mhi_qti.h @@ -12,6 +12,7 @@ #define MHI_SMMU_FORCE_COHERENT BIT(4) #define MHI_PCIE_VENDOR_ID (0x17cb) +#define PCI_VENDOR_ID_FOXCONN (0x105b) #define MHI_PCIE_DEBUG_ID (0xffff) /* runtime suspend timer */ diff --git a/driver/quectel_MHI/src/devices/mhi_netdev_quectel.c b/driver/quectel_MHI/src/devices/mhi_netdev_quectel.c index e0ce5cf..f58f8d6 100644 --- a/driver/quectel_MHI/src/devices/mhi_netdev_quectel.c +++ b/driver/quectel_MHI/src/devices/mhi_netdev_quectel.c @@ -208,7 +208,7 @@ static void qmap_hex_dump(const char *tag, unsigned char *data, unsigned len) { #define MBIM_MUX_ID_SDX7X 112 //sdx7x is 112-126, others is 0-14 -static uint __read_mostly mhi_mbim_enabled = 0; +static uint __read_mostly mhi_mbim_enabled = 1; module_param(mhi_mbim_enabled, uint, S_IRUGO); int mhi_netdev_mbin_enabled(void) { return mhi_mbim_enabled; } @@ -712,13 +712,20 @@ static struct sk_buff * add_mbim_hdr(struct sk_buff *skb, u8 mux_id) { static struct sk_buff * add_qhdr(struct sk_buff *skb, u8 mux_id) { struct qmap_hdr *qhdr; int pad = 0; + struct sk_buff *new_skb = NULL; pad = skb->len%4; if (pad) { pad = 4 - pad; if (skb_tailroom(skb) < pad) { - printk("skb_tailroom small!\n"); - pad = 0; + new_skb = skb_copy_expand(skb, skb_headroom(skb) + sizeof(struct qmap_hdr), + pad, GFP_ATOMIC); + if (!new_skb) { + printk("Failed to expand skb for padding\n"); + return NULL; + } + dev_kfree_skb_any(skb); + skb = new_skb; } if (pad) __skb_put(skb, pad); @@ -736,14 +743,23 @@ static struct sk_buff * add_qhdr_v5(struct sk_buff *skb, u8 mux_id) { struct rmnet_map_header *map_header; struct rmnet_map_v5_csum_header *ul_header; u32 padding, map_datalen; + struct sk_buff *new_skb = NULL; map_datalen = skb->len; padding = map_datalen%4; if (padding) { padding = 4 - padding; if (skb_tailroom(skb) < padding) { - printk("skb_tailroom small!\n"); - padding = 0; + new_skb = skb_copy_expand(skb, skb_headroom(skb) + + sizeof(struct rmnet_map_header) + + sizeof(struct rmnet_map_v5_csum_header), + padding, GFP_ATOMIC); + if (!new_skb) { + printk("Failed to expand skb for padding\n"); + return NULL; + } + dev_kfree_skb_any(skb); + skb = new_skb; } if (padding) __skb_put(skb, padding); @@ -1708,7 +1724,7 @@ static struct net_device * rmnet_vnd_register_device(struct mhi_netdev *pQmapDev out_free_newdev: free_netdev(qmap_net); - return qmap_net; + return NULL; } static void rmnet_vnd_unregister_device(struct net_device *qmap_net) { @@ -3286,6 +3302,7 @@ static int mhi_netdev_probe(struct mhi_device *mhi_dev, || (mhi_dev->vendor == 0x17cb && mhi_dev->dev_id == 0x011a) || (mhi_dev->vendor == 0x1eac && mhi_dev->dev_id == 0x100b) || (mhi_dev->vendor == 0x17cb && mhi_dev->dev_id == 0x0309) + || (mhi_dev->vendor == 0x105b && mhi_dev->dev_id == 0xe0f5) ) { mhi_netdev->qmap_version = 9; } diff --git a/luci/luci-app-qmodem/luasrc/model/cbi/qmodem/modem_cfg.lua b/luci/luci-app-qmodem/luasrc/model/cbi/qmodem/modem_cfg.lua index 82a72c8..209eed5 100644 --- a/luci/luci-app-qmodem/luasrc/model/cbi/qmodem/modem_cfg.lua +++ b/luci/luci-app-qmodem/luasrc/model/cbi/qmodem/modem_cfg.lua @@ -4,7 +4,9 @@ return { simcom = "Simcom", sierra = "Sierra Wireless", fibocom = "Fibocom", - meig = "Meig" + meig = "Meig", + huawei = "Huawei", + neoway = "Neoway" }, platforms = { lte = "LTE", diff --git a/luci/luci-app-qmodem/po/zh-cn/qmodem.po b/luci/luci-app-qmodem/po/zh-cn/qmodem.po index f965a78..f17c446 100644 --- a/luci/luci-app-qmodem/po/zh-cn/qmodem.po +++ b/luci/luci-app-qmodem/po/zh-cn/qmodem.po @@ -625,6 +625,9 @@ msgstr "广和通" msgid "Meig" msgstr "美格" +msgid "Neoway" +msgstr "有方" + msgid "Platform" msgstr "平台" diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh index 4966010..be2f4e6 100755 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh @@ -124,7 +124,7 @@ update_config() update_sim_slot case $sim_slot in 1) - config_get apn $modem_config apn + config_get apn $modem_config apn "auto" config_get username $modem_config username config_get password $modem_config password config_get auth $modem_config auth @@ -136,7 +136,7 @@ update_config() config_get password $modem_config password2 config_get auth $modem_config auth2 config_get pincode $modem_config pincode2 - [ -z "$apn" ] && config_get apn $modem_config apn + [ -z "$apn" ] && config_get apn $modem_config apn "auto" [ -z "$username" ] && config_get username $modem_config username [ -z "$password" ] && config_get password $modem_config password [ -z "$auth" ] && config_get auth $modem_config auth @@ -161,6 +161,15 @@ check_dial_prepare() { cpin=$(at "$at_port" "AT+CPIN?") get_sim_status "$cpin" + [ "$manufacturer" = "neoway" ] && { + local res + res=$(at $at_port 'AT$MYCCID' | grep -q "ERROR") + if [ $? -ne 0 ]; then + sim_state_code="1" + else + sim_state_code="0" + fi + } case $sim_state_code in "0") m_debug "info sim card is miss" @@ -251,6 +260,16 @@ check_ip() ;; esac ;; + "neoway") + case $platform in + "unisoc") + check_ip_command='AT$MYUSBNETACT?' + ;; + esac + ;; + *) + check_ip_command="AT+CGPADDR=1" + ;; esac if [ "$driver" = "mtk_pcie" ]; then @@ -258,6 +277,9 @@ check_ip() local config=$(umbim -d $mbim_port config) ipaddr=$(echo "$config" | grep "ipv4address:" | awk '{print $2}' | cut -d'/' -f1) ipaddr="$ipaddr $(echo "$config" | grep "ipv6address:" | awk '{print $2}' | cut -d'/' -f1)" + elif [ "$manufacturer" = "neoway" ]; then + # $MYURCACT: 0,1,"10.92.220.73" + ipaddr=$(at "$at_port" "$check_ip_command" | grep '$MYUSBNETACT:') else ipaddr=$(at "$at_port" "$check_ip_command" | grep +CGPADDR:) fi @@ -614,22 +636,33 @@ wwan_hang() ecm_hang() { - if [ "$manufacturer" = "quectel" ]; then - at_command="AT+QNETDEVCTL=1,2,1" - elif [ "$manufacturer" = "fibocom" ]; then - #联发科平台(广和通FM350-GL) - if [ "$platform" = "mediatek" ]; then - at_command="AT+CGACT=0,3" - else - at_command="AT+GTRNDIS=0,1" - fi - elif [ "$manufacturer" = "meig" ]; then - at_command="AT$QCRMCALL=0,1,1,2,1" - elif [ "$manufacturer" = "huawei" ]; then - at_command="AT^NDISDUP=0,0" - else - at_command='ATI' - fi + case "$manufacturer" in + "quectel") + at_command="AT+QNETDEVCTL=1,2,1" + ;; + "fibocom") + case "$platform" in + "mediatek") + at_command="AT+CGACT=0,3" + ;; + *) + at_command="AT+GTRNDIS=0,1" + ;; + esac + ;; + "meig") + at_command='AT$QCRMCALL=0,0,1,2,1' + ;; + "huawei") + at_command="AT^NDISDUP=0,0" + ;; + "neoway") + at_command='AT$MYUSBNETACT=0,0' + ;; + *) + at_command="ATI" + ;; + esac fastat "${at_port}" "${at_command}" } @@ -812,7 +845,15 @@ at_dial() "meig") case $platform in "qualcomm") - at_command="" + at_command='AT$QCRMCALL=1,0,1,2,1' + cgdcont_command="AT+CGDCONT=1,\"$pdp_type\",\"$apn\"" + ;; + esac + ;; + "neoway") + case $platform in + "unisoc") + at_command='AT$MYUSBNETACT=0,1' cgdcont_command="AT+CGDCONT=1,\"$pdp_type\",\"$apn\"" ;; esac diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_port_rule.json b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_port_rule.json index 34184a2..a254335 100644 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_port_rule.json +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_port_rule.json @@ -40,6 +40,14 @@ "2c7c:8101": { "name": "rg801", "option_driver": 1 + }, + "3763:3c93": { + "name": "nari-m601", + "mode": "ecm", + "option_driver": 1, + "include": [ + "1.1" + ] } } } diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_scan.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_scan.sh index 6a3be55..5af646c 100755 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_scan.sh +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_scan.sh @@ -347,11 +347,16 @@ match_config() [[ "$name" = *"T99W373"* ]] && name="t99w373" + [[ "$name" = *"dp25-42843-47"* ]] && name="t99w640" + [[ "$name" = *"SIM8380G"* ]] && name="SIM8380G-M2" #rg200u-cn [[ "$name" = *"rg200u-cn"* ]] && name="rg200u-cn" + #nari-m601 + [[ "$name" = *"m601"* ]] && name="n510m" + modem_config=$(echo $modem_support | jq '.modem_support."'$slot_type'"."'$name'"') [ "$modem_config" == "null" ] && return [ -z "$modem_config" ] && return diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_support.json b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_support.json index b599513..e9ac6e7 100644 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_support.json +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_support.json @@ -829,6 +829,16 @@ "mbim", "rmnet" ] + }, + "n510m": { + "manufacturer_id": "3763", + "manufacturer": "neoway", + "platform": "unisoc", + "data_interface": "usb", + "define_connect": "1", + "modes": [ + "ecm" + ] } }, "pcie": { @@ -861,6 +871,15 @@ "mbim" ] }, + "t99w640": { + "manufacturer": "foxconn", + "platform": "qualcomm", + "data_interface": "pcie", + "define_connect": "1", + "modes": [ + "mbim" + ] + }, "simcom_sim8380g-m2": { "manufacturer": "simcom", "platform": "qualcomm", @@ -1309,6 +1328,16 @@ "e0ab" ] } + }, + "neoway": { + "unisoc": { + "vendor_id": [ + "3763" + ], + "product_id": [ + "3c93" + ] + } } } } 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 0879be1..49b5481 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 @@ -11,7 +11,6 @@ at() tom_modem -d $at_port -o a -c "$atcmd" } - fastat() { local at_port=$1 @@ -146,6 +145,23 @@ at_get_slot() ;; esac ;; + "neoway") + at_res=$(at $at_port 'AT+SIMCROSS?' | grep "+SIMCROSS:" | awk -F'[ ,]' '{print $2}' | sed 's/\r//g') + case $at_res in + "1") + sim_slot="1" + ;; + "2") + sim_slot="2" + ;; + *) + sim_slot="1" + ;; + *) + sim_slot="1" + ;; + esac + ;; *) at_q_res=$(at $at_port AT+QSIMDET? |grep +QSIMDET: |awk -F: '{print $2}') at_f_res=$(at $at_port AT+GTDUALSIM? |grep +GTDUALSIM: |awk -F: '{print $2}') diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/dynamic_load.json b/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/dynamic_load.json index 1e3b60d..c9b7356 100644 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/dynamic_load.json +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/dynamic_load.json @@ -6,5 +6,6 @@ "sierra" : "sierra.sh", "simcom" : "simcom.sh", "huawei" : "huawei.sh", - "foxconn" : "foxconn.sh" + "foxconn" : "foxconn.sh", + "neoway" : "neoway.sh" } diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/foxconn.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/foxconn.sh index cdefea5..6b7a571 100644 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/foxconn.sh +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/foxconn.sh @@ -4,6 +4,16 @@ source /usr/share/qmodem/generic.sh debug_subject="quectel_ctrl" +name=$(uci -q get qmodem.$config_section.name) +case "$name" in + "t99w640") + at_pre="AT+" + ;; + *) + at_pre="AT^" + ;; +esac + function get_imei(){ imei=$(at $at_port "ATI" | awk -F': ' '/^IMEI:/ {print $2}' | xargs) json_add_string imei $imei @@ -11,21 +21,26 @@ function get_imei(){ function set_imei(){ imei=$1 - extended="80A$imei" # 添加 80A 前缀 - formatted="" + # 添加 80A 前缀 + extended="80A${imei}" + swapped="" + len=${#extended} i=0 - while [ $i -lt ${#extended} ]; do - byte=$(echo "$extended" | cut -c$((i+1))-$((i+2))) # 获取两个字符 - formatted="$formatted$byte," + while [ $i -lt $len ]; do + pair=$(echo "$extended" | cut -c$((i+1))-$((i+2))) + if [ ${#pair} -eq 2 ]; then + swapped="${swapped}${pair:1:1}${pair:0:1}" + elif [ ${#pair} -eq 1 ]; then + swapped="${swapped}${pair:0:1}" + fi i=$((i+2)) done - # 去除最后的逗号 - formatted=$(echo ${formatted%,}|xargs) - #echo "$formatted" + # 两位分组加逗号,并转小写 + formatted=$(echo "$swapped" | sed 's/../&,/g' | sed 's/,$//' | tr 'A-Z' 'a-z') - at_command="at^nv=550,9,$formatted" - res=$(at $at_port \"$at_command\") + at_command=$at_pre'nv=550,9,"'$formatted'"' + res=$(at $at_port "$at_command") json_select "result" json_add_string "set_imei" "$res" json_close_object @@ -35,14 +50,14 @@ function set_imei(){ function get_mode(){ local mode_num local mode - cfg=$(at $at_port "AT^PCIEMODE?") + cfg=$(at $at_port $at_pre"PCIEMODE?") config_type=`echo -e "$cfg" | grep -o '[0-9]'` if [ "$config_type" = "1" ]; then mode_num="0" json_add_int disable_mode_btn 1 else - ucfg=$(at $at_port "AT+USBSWITCH?") + ucfg=$(at $at_port $at_pre"USBSWITCH?") config_type=$(echo "$ucfg" | grep USBSWITCH: |cut -d':' -f2|xargs) if [ "$config_type" = "9025" ]; then mode_num="1" @@ -90,7 +105,7 @@ set_mode(){ ;; esac #设置模组 - at_command="AT+USBSWITCH=${mode_num}" + at_command=$at_pre"USBSWITCH=${mode_num}" res=$(at "${at_port}" "${at_command}") json_select "result" json_add_string "set_mode" "$res" @@ -98,7 +113,7 @@ set_mode(){ } function get_network_prefer(){ - res=$(at $at_port "AT^SLMODE?"| grep -o '[0-9]\+' | tr -d '\n' | tr -d ' ') + res=$(at $at_port $at_pre"SLMODE?"| grep -o '[0-9]\+' | tr -d '\n' | tr -d ' ') # (RAT index): # 0 Automatically # 1 WCDMA Only @@ -187,7 +202,7 @@ function set_network_prefer(){ code="10" ;; esac - res=$(at $at_port "AT^SLMODE=$(echo "$code" | awk '{print substr($0,1,1) "," substr($0,2,1)}')") + res=$(at $at_port $at_pre"SLMODE=$(echo "$code" | awk '{print substr($0,1,1) "," substr($0,2,1)}')") json_add_string "code" "$code" json_add_string "result" "$res" } @@ -211,7 +226,7 @@ function sim_info() #IMEI(国际移动设备识别码) imei=$(at $at_port "ATI" | awk -F': ' '/^IMEI:/ {print $2}' | xargs) - at_command="at^switch_slot?" + at_command=$at_pre"switch_slot?" sim_slot=$(at $at_port $at_command | grep ENABLE|grep -o 'SIM[0-9]*') #SIM Status(SIM状态) @@ -299,98 +314,105 @@ function network_info() { local rat_num=$(at ${at_port} ${at_command} | grep "+COPS:" | awk -F',' '{print $4}' | sed 's/\r//g') network_type=$(get_rat ${rat_num}) } - #at_command='AT^debug?' + #at_command='AT+debug?' #response=$(at $at_port $at_command) #lte_sinr=$(echo "$response"|awk -F'lte_snr:' '{print $2}'|awk '{print $1}|xargs) add_plain_info_entry "Network Type" "$network_type" "Network Type" } function vendor_get_disabled_features(){ - json_add_string "" "IMEI" json_add_string "" "NeighborCell" } get_lockband_nr() { - #local at_port="$1" m_debug "Quectel sdx55 get lockband info" - 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" - sa_nr_avalible_band="1,2,3,5,7,8,12,20,25,28,38,40,41,48,66,71,77,78,79" - bands_command="AT^BAND_PREF?" + bands_command=$at_pre"BAND_PREF?" get_lockbans=$(at $at_port $bands_command) - gw_band=$(echo "$get_lockbans" | grep "WCDMA,Enable Bands" | cut -d':' -f2 | tr -d ' '|tr ',' ' '|xargs) - lte_band=$(echo "$get_lockbans" | grep "LTE,Enable Bands" | cut -d':' -f2 | tr -d ' '|tr ',' ' ') - sa_nr_band=$(echo "$get_lockbans" | grep "NR5G,Enable Bands" | cut -d':' -f2 | tr -d ' '|tr ',' ' ') + + # WCDMA + wcdma_enable=$(echo "$get_lockbans" | grep "WCDMA,Enable Bands" | cut -d':' -f2 | tr -d ' ' | tr ',' ' ') + wcdma_disable=$(echo "$get_lockbans" | grep "WCDMA,Disable Bands" | cut -d':' -f2 | tr -d ' ' | tr ',' ' ') + wcdma_enable=$(echo "$wcdma_enable" | tr ' ' '\n' | grep -v '^$') + wcdma_disable=$(echo "$wcdma_disable" | tr ' ' '\n' | grep -v '^$') + wcdma_all=$(echo "$wcdma_enable $wcdma_disable" | tr ' ' '\n' | grep -v '^$' | sort -n | uniq) + + # LTE + lte_enable=$(echo "$get_lockbans" | grep "LTE,Enable Bands" | cut -d':' -f2 | tr -d ' ' | tr ',' ' ') + lte_disable=$(echo "$get_lockbans" | grep "LTE,Disable Bands" | cut -d':' -f2 | tr -d ' ' | tr ',' ' ') + lte_enable=$(echo "$lte_enable" | tr ' ' '\n' | grep -v '^$') + lte_disable=$(echo "$lte_disable" | tr ' ' '\n' | grep -v '^$') + lte_all=$(echo "$lte_enable $lte_disable" | tr ' ' '\n' | grep -v '^$' | sort -n | uniq) + + # NR5G_NSA + nr_nsa_enable=$(echo "$get_lockbans" | grep "NR5G_NSA,Enable Bands" | cut -d':' -f2 | tr -d ' ' | tr ',' ' ') + nr_nsa_disable=$(echo "$get_lockbans" | grep "NR5G_NSA,Disable Bands" | cut -d':' -f2 | tr -d ' ' | tr ',' ' ') + nr_nsa_enable=$(echo "$nr_nsa_enable" | tr ' ' '\n' | grep -v '^$') + nr_nsa_disable=$(echo "$nr_nsa_disable" | tr ' ' '\n' | grep -v '^$') + nr_nsa_all=$(echo "$nr_nsa_enable $nr_nsa_disable" | tr ' ' '\n' | grep -v '^$' | sort -n | uniq) + + # NR5G_SA + nr_sa_enable=$(echo "$get_lockbans" | grep "NR5G_SA,Enable Bands" | cut -d':' -f2 | tr -d ' ' | tr ',' ' ') + nr_sa_disable=$(echo "$get_lockbans" | grep "NR5G_SA,Disable Bands" | cut -d':' -f2 | tr -d ' ' | tr ',' ' ') + nr_sa_enable=$(echo "$nr_sa_enable" | tr ' ' '\n' | grep -v '^$') + nr_sa_disable=$(echo "$nr_sa_disable" | tr ' ' '\n' | grep -v '^$') + nr_sa_all=$(echo "$nr_sa_enable $nr_sa_disable" | tr ' ' '\n' | grep -v '^$' | sort -n | uniq) + + # UMTS json_add_object "UMTS" json_add_array "available_band" + for i in $wcdma_all; do + echo "$i" | grep -Eq '^[0-9]+$' && add_avalible_band_entry "$i" "UMTS_$i" + done json_close_array json_add_array "lock_band" - json_close_object - json_close_object - json_add_object "LTE" - json_add_array "available_band" - json_close_array - json_add_array "lock_band" - json_close_array - json_close_object - json_add_object "NR" - json_add_array "available_band" - json_close_array - json_add_array "lock_band" + for i in $wcdma_enable; do + echo "$i" | grep -Eq '^[0-9]+$' && json_add_string "" "$i" + done json_close_array json_close_object - for i in $(echo "$wcdma_avalible_band" | awk -F"," '{for(j=1; j<=NF; j++) print $j}'); do - json_select "UMTS" - json_select "available_band" - add_avalible_band_entry "$i" "UMTS_$i" - json_select .. - json_select .. - done - for i in $(echo "$lte_avalible_band" | awk -F"," '{for(j=1; j<=NF; j++) print $j}'); do - json_select "LTE" - json_select "available_band" - add_avalible_band_entry "$i" "LTE_B$i" - json_select .. - json_select .. - done - for i in $(echo "$sa_nr_avalible_band" | awk -F"," '{for(j=1; j<=NF; j++) print $j}'); do - json_select "NR" - json_select "available_band" - add_avalible_band_entry "$i" "NR_N$i" - json_select .. - json_select .. - done - #+QNWPREFCFG: "nr5g_band",1:3:7:20:28:40:41:71:77:78:79 - for i in $(echo "$gw_band"); do - if [ -n "$i" ]; then - json_select "UMTS" - json_select "lock_band" - json_add_string "" "$i" - json_select .. - json_select .. - 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_select "LTE" - json_select "lock_band" - json_add_string "" "$i" - json_select .. - json_select .. - 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_select "NR" - json_select "lock_band" - json_add_string "" "$i" - json_select .. - json_select .. - fi + # LTE + json_add_object "LTE" + json_add_array "available_band" + for i in $lte_all; do + echo "$i" | grep -Eq '^[0-9]+$' && add_avalible_band_entry "$i" "LTE_B$i" done json_close_array + json_add_array "lock_band" + for i in $lte_enable; do + echo "$i" | grep -Eq '^[0-9]+$' && json_add_string "" "$i" + done + json_close_array + json_close_object + + # NR_NSA + json_add_object "NR_NSA" + json_add_array "available_band" + for i in $nr_nsa_all; do + echo "$i" | grep -Eq '^[0-9]+$' && add_avalible_band_entry "$i" "NR_NSA_N$i" + done + json_close_array + json_add_array "lock_band" + for i in $nr_nsa_enable; do + echo "$i" | grep -Eq '^[0-9]+$' && json_add_string "" "$i" + done + json_close_array + json_close_object + + # NR_SA + json_add_object "NR_SA" + json_add_array "available_band" + for i in $nr_sa_all; do + echo "$i" | grep -Eq '^[0-9]+$' && add_avalible_band_entry "$i" "NR_SA_N$i" + done + json_close_array + json_add_array "lock_band" + for i in $nr_sa_enable; do + echo "$i" | grep -Eq '^[0-9]+$' && json_add_string "" "$i" + done + json_close_array + json_close_object } set_lockband_nr(){ @@ -398,15 +420,15 @@ set_lockband_nr(){ case "$band_class" in "UMTS") lock_band=$(echo $lock_band) - at_command="AT^BAND_PREF=WCDMA,2,$lock_band" + at_command=$at_pre"BAND_PREF=WCDMA,2,$lock_band" res=$(at $at_port $at_command) ;; "LTE") - at_command="AT^BAND_PREF=LTE,2,$lock_band" + at_command=$at_pre"BAND_PREF=LTE,2,$lock_band" res=$(at $at_port $at_command) ;; "NR") - at_command="AT^BAND_PREF=NR5G,2,$lock_band" + at_command=$at_pre"BAND_PREF=NR5G,2,$lock_band" res=$(at $at_port $at_command) ;; esac @@ -440,7 +462,7 @@ function _get_voltage(){ } function _get_temperature(){ - temperature=$(at $at_port "at^temp?" | sed -n 's/.*TSENS: \([0-9]*\)C.*/\1/p' ) + temperature=$(at $at_port $at_pre"temp?" | sed -n 's/.*TSENS: \([0-9]*\)C.*/\1/p' ) [ -n "$temperature" ] && { add_plain_info_entry "temperature" "$temperature C" "Temperature" } @@ -506,12 +528,11 @@ function _band_list_to_mask() cell_info(){ class="Cell Information" - at_command='AT^debug?' + at_command=$at_pre"debug?" response=$(at $at_port $at_command) network_mode=$(echo "$response"|awk -F'RAT:' '{print $2}'|xargs) #add_plain_info_entry "network_mode" "$network_mode" "Network Mode" - case $network_mode in "LTE") lte_mcc=$(echo "$response"|awk -F'mcc:' '{print $2}'|awk -F',' '{print $1}'|xargs) @@ -549,21 +570,36 @@ cell_info(){ #add_plain_info_entry "Srxlev" "$lte_srxlev" "Serving Cell Receive Level" ;; "NR5G_SA") + has_ca=$(echo "$response" | grep -c "nr_scc1:") + nr_display_mode="$network_mode" + nr_mcc=$(echo "$response"|awk -F'mcc:' '{print $2}'|awk -F',' '{print $1}'|xargs) nr_mnc=$(echo "$response"|awk -F'mnc:' '{print $2}'|xargs) nr_earfcn=$(echo "$response"|awk -F'channel:' '{print $2}'|awk -F' ' '{print $1}'|xargs) nr_physical_cell_id=$(echo "$response"|awk -F'pci:' '{print $2}'|awk -F' ' '{print $1}'|xargs) nr_cell_id=$(echo "$response"|awk -F'nr_cell_id:' '{print $2}'|xargs) nr_band=$(echo "$response"|awk -F'nr_band:' '{print $2}'|awk -F' ' '{print $1}'|xargs) + nr_band_width=$(echo "$response"|awk -F'nr_band_width:' '{print $2}'|awk -F' ' '{print $1}'|xargs) nr_freq_band_ind=$(echo "$response"|awk -F'lte_band_width:' '{print $2}'|xargs) nr_sinr=$(echo "$response"|awk -F'nr_snr:' '{print $2}'|awk '{print $1}'|xargs) nr_rsrq=$(echo "$response"|awk -F'rsrq:' '{print $2}'|xargs) - nr_rsrp=$(echo "$response"|awk -F'rsrp:' '{print $2}'|awk '{print $1}'|xargs) - lte_rssi=$(echo "$response"|awk -F'nr_rssi:' '{print $2}'|awk -F',' '{print $1}'|xargs) - #lte_rssnr=$(echo "$response"| + nr_rsrp=$(echo "$response"|awk -F'rsrp:' '{print $2}'|awk '{print $1}'|xargs) + nr_rssi=$(echo "$response"|awk -F'nr_rssi:' '{print $2}'|awk -F',' '{print $1}'|xargs) nr_tac=$(echo "$response"|awk -F'nr_tac:' '{print $2}'|xargs) - #nr_tx_power=$(echo "$response"|awk -F'lte_tx_pwr:' '{print $2}'|xargs) + if [ "$has_ca" -gt 0 ]; then + nr_display_mode="NR5G_SA-CA" + + scc1_band=$(echo "$response" | awk -F'nr_scc1:' '{print $2}' | awk -F'nr_band:' '{print $2}' | awk -F' ' '{print $1}' | xargs) + scc1_band_width=$(echo "$response" | awk -F'nr_scc1:' '{print $2}' | awk -F'nr_band_width:' '{print $2}' | awk -F' ' '{print $1}' | xargs) + + nr_band="$nr_band $scc1_band" + nr_band_width="$nr_band_width $scc1_band_width" + fi + + add_plain_info_entry "Network Mode" "$nr_display_mode" "Network Mode" + add_plain_info_entry "Band" "$nr_band" "Band" + add_plain_info_entry "DL Bandwidth" "$nr_band_width" "DL Bandwidth" add_plain_info_entry "MCC" "$nr_mcc" "Mobile Country Code" add_plain_info_entry "MNC" "$nr_mnc" "Mobile Network Code" #add_plain_info_entry "Duplex Mode" "$lte_duplex_mode" "Duplex Mode" @@ -571,22 +607,12 @@ cell_info(){ add_plain_info_entry "Physical Cell ID" "$nr_physical_cell_id" "Physical Cell ID" add_plain_info_entry "EARFCN" "$nr_earfcn" "E-UTRA Absolute Radio Frequency Channel Number" add_plain_info_entry "Freq band indicator" "$nr_freq_band_ind" "Freq band indicator" - add_plain_info_entry "Band" "$nr_band" "Band" - #add_plain_info_entry "UL Bandwidth" "$nr_ul_bandwidth" "UL Bandwidth" - #add_plain_info_entry "DL Bandwidth" "$nr_dl_bandwidth" "DL Bandwidth" add_plain_info_entry "TAC" "$nr_tac" "Tracking area code of cell served by neighbor Enb" - add_bar_info_entry "RSRQ" "$nr_rsrq" "Reference Signal Received Quality" -20 40 dBm - add_bar_info_entry "RSRP" "$nr_rsrp" "Reference Signal Received Power" -187 -29 dBm - #add_bar_info_entry "RSSI" "$nr_rssi" "Received Signal Strength Indicator" -140 -44 dBm + add_bar_info_entry "RSRQ" "$nr_rsrq" "Reference Signal Received Quality" -43 20 dBm + add_bar_info_entry "RSRP" "$nr_rsrp" "Reference Signal Received Power" -187 -29 dBm add_bar_info_entry "SINR" "$nr_sinr" "Signal to Interference plus Noise Ratio Bandwidth" -23 40 dB - #add_plain_info_entry "RxLev" "$nr_rxlev" "Received Signal Level" add_plain_info_entry "RSSNR" "$nr_rssnr" "Radio Signal Strength Noise Ratio" - #add_plain_info_entry "CQI" "$nr_cql" "Channel Quality Indicator" add_plain_info_entry "TX Power" "$nr_tx_power" "TX Power" - #add_plain_info_entry "Srxlev" "$nr_srxlev" "Serving Cell Receive Level" ;; esac } - - - diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/neoway.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/neoway.sh new file mode 100755 index 0000000..48b8fb1 --- /dev/null +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/neoway.sh @@ -0,0 +1,766 @@ +#!/bin/sh +# Copyright (C) 2025 Fujr +_Vendor="neoway" +_Author="Fujr" +_Maintainer="Fujr " +source /usr/share/qmodem/generic.sh +debug_subject="neoway_ctrl" + +vendor_get_disabled_features(){ + json_add_string "" "NeighborCell" + json_add_string "" "IMEI" + json_add_string "" "DialMode" +} + +#获取网络偏好 +# $1:AT串口 +get_network_prefer() +{ + at_command='AT$MYSYSINFO' + local response=$(at ${at_port} ${at_command} | grep '$MYSYSINFO:' | awk -F',' '{print $1}' | awk '{print $2}' | sed 's/\r//g') + + network_prefer_3g="0"; + network_prefer_4g="0"; + network_prefer_5g="0"; + + case "$response" in + "3") + # 3G + network_prefer_3g="1" + ;; + "4") + # 4G + network_prefer_4g="1" + ;; + "5") + # 5G + network_prefer_5g="1" + ;; + "7") + # 3G + 4G + network_prefer_3g="1" + network_prefer_4g="1" + ;; + "9") + # 5G + network_prefer_5g="1" + ;; + "11") + # 3G + 5G + network_prefer_3g="1" + network_prefer_5g="1" + ;; + "12") + # 4G + 5G + network_prefer_4g="1" + network_prefer_5g="1" + ;; + "14") + # 3G + 4G + 5G + network_prefer_3g="1" + network_prefer_4g="1" + network_prefer_5g="1" + ;; + "*") + # AUTO + network_prefer_3g="1" + network_prefer_4g="1" + network_prefer_5g="1" + ;; + esac + json_add_object network_prefer + json_add_string 2G "$network_prefer_2g" + json_add_string 3G "$network_prefer_3g" + json_add_string 4G "$network_prefer_4g" + json_add_string 5G "$network_prefer_5g" + json_close_object +} + +#设置网络偏好 +# $1:AT串口 +# $2:网络偏好配置 +set_network_prefer() +{ + network_prefer_3g=$(echo $1 |jq -r 'contains(["3G"])') + network_prefer_4g=$(echo $1 |jq -r 'contains(["4G"])') + network_prefer_5g=$(echo $1 |jq -r 'contains(["5G"])') + length=$(echo $1 |jq -r 'length') + + local config_mode="1" + + case "$length" in + "1") + if [ "$network_prefer_3g" = "true" ]; then + config_mode="3" # 仅3G + elif [ "$network_prefer_4g" = "true" ]; then + config_mode="4" # 仅4G + elif [ "$network_prefer_5g" = "true" ]; then + config_mode="9" # 仅5G + fi + ;; + "2") + if [ "$network_prefer_3g" = "true" ] && [ "$network_prefer_4g" = "true" ]; then + config_mode="7" # 3G + 4G + elif [ "$network_prefer_3g" = "true" ] && [ "$network_prefer_5g" = "true" ]; then + config_mode="11" # 3G + 5G + elif [ "$network_prefer_4g" = "true" ] && [ "$network_prefer_5g" = "true" ]; then + config_mode="12" # 4G + 5G + fi + ;; + "3") + config_mode="14" # 3G + 4G + 5G + ;; + *) + config_mode="1" # AUTO + ;; + esac + + at_command='AT$MYSYSINFO='${config_mode} + res=$(at "${at_port}" "${at_command}") + + json_select "result" + json_add_string "set_network_prefer" "$res" + json_close_object +} + +#基本信息 +base_info() +{ + m_debug "Neoway base info" + + #Name(名称) + at_command="AT+CGMM" + name=$(at $at_port $at_command | sed -n '2p' | sed 's/\r//g') + #Manufacturer(制造商) + at_command="AT+CGMI" + manufacturer=$(at $at_port $at_command | grep "+CGMI:" | sed 's/+CGMI: //g' | sed 's/\r//g') + #Revision(固件版本) + at_command="ATI" + revision=$(at $at_port $at_command | sed -n '5p' | sed 's/\r//g') + # at_command="AT+CGMR" + # revision=$(at $at_port $at_command | sed -n '2p' | sed 's/\r//g') + class="Base Information" + add_plain_info_entry "manufacturer" "$manufacturer" "Manufacturer" + add_plain_info_entry "revision" "$revision" "Revision" + add_plain_info_entry "at_port" "$at_port" "AT Port" + get_connect_status +} + +#SIM卡信息 +sim_info() +{ + m_debug "Neoway sim info" + + #SIM Slot(SIM卡卡槽) + at_command="AT+SIMCROSS?" + sim_slot=$(at $at_port $at_command | grep "+SIMCROSS:" | awk -F'[ ,]' '{print $2}' | sed 's/\r//g') + m_debug "SIM Slot: $sim_slot" + #IMEI(国际移动设备识别码) + at_command="AT+CGSN" + imei=$(at $at_port $at_command | sed -n '3p' | awk -F'"' '{print $2}') + + #SIM Status(SIM状态) + at_command="AT+CPIN?" + sim_status_flag=$(at $at_port $at_command | sed -n '3p') + sim_status=$(get_sim_status "$sim_status_flag") + + [ "$sim_status" != "ready" ] && return + + #ISP(互联网服务提供商) + at_command="AT+COPS?" + isp=$(at $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}') + # if [ "$isp" = "CHN-CMCC" ] || [ "$isp" = "CMCC" ]|| [ "$isp" = "46000" ]; then + # isp="中国移动" + # # elif [ "$isp" = "CHN-UNICOM" ] || [ "$isp" = "UNICOM" ] || [ "$isp" = "46001" ]; then + # elif [ "$isp" = "CHN-UNICOM" ] || [ "$isp" = "CUCC" ] || [ "$isp" = "46001" ]; then + # isp="中国联通" + # # elif [ "$isp" = "CHN-CT" ] || [ "$isp" = "CT" ] || [ "$isp" = "46011" ]; then + # elif [ "$isp" = "CHN-TELECOM" ] || [ "$isp" = "CTCC" ] || [ "$isp" = "46011" ]; then + # isp="中国电信" + # fi + + #SIM Number(SIM卡号码,手机号) + at_command="AT+CNUM" + sim_number=$(at $at_port $at_command | sed -n '3p' | awk -F'"' '{print $4}') + + #IMSI(国际移动用户识别码) + at_command="AT+CIMI" + imsi=$(at $at_port $at_command | sed -n '3p' | sed 's/\r//g') + + #ICCID(集成电路卡识别码) + iccid=$(at $at_port 'AT$MYCCID' | grep '$MYCCID:' | awk -F' "' '{print $2}' | sed 's/"//g') + [ -n "$iccid" ] || return + class="SIM Information" + case "$sim_status" in + "ready") + add_plain_info_entry "SIM Status" "$sim_status" "SIM Status" + add_plain_info_entry "ISP" "$isp" "Internet Service Provider" + add_plain_info_entry "SIM Slot" "$sim_slot" "SIM Slot" + add_plain_info_entry "SIM Number" "$sim_number" "SIM Number" + add_plain_info_entry "IMEI" "$imei" "International Mobile Equipment Identity" + add_plain_info_entry "IMSI" "$imsi" "International Mobile Subscriber Identity" + add_plain_info_entry "ICCID" "$iccid" "Integrate Circuit Card Identity" + ;; + "miss") + add_plain_info_entry "SIM Status" "$sim_status" "SIM Status" + add_plain_info_entry "IMEI" "$imei" "International Mobile Equipment Identity" + ;; + "unknown") + add_plain_info_entry "SIM Status" "$sim_status" "SIM Status" + ;; + *) + add_plain_info_entry "SIM Status" "$sim_status" "SIM Status" + add_plain_info_entry "SIM Slot" "$sim_slot" "SIM Slot" + add_plain_info_entry "IMEI" "$imei" "International Mobile Equipment Identity" + add_plain_info_entry "IMSI" "$imsi" "International Mobile Subscriber Identity" + add_plain_info_entry "ICCID" "$iccid" "Integrate Circuit Card Identity" + ;; + esac +} + +#网络信息 +network_info() +{ + m_debug "Neoway network info" + + #CSQ(信号强度) + at_command="AT+CSQ" + response=$(at ${at_port} ${at_command} | grep "+CSQ:" | sed 's/+CSQ: //g' | sed 's/\r//g') + + #最大比特率,信道质量指示 + at_command='AT+C5GQOSRDP' + response=$(at $at_port $at_command | grep "+C5GQOSRDP:") + + if [ -n "$response" ]; then + # Parse 5G QoS parameters + # Format: +C5GQOSRDP: ,<5QI>[,,[,,[,,[,]]]]] + + # Extract DL_SAMBR (downlink session AMBR) and UL_SAMBR (uplink session AMBR) in kbit/s + ambr_dl=$(echo "$response" | awk -F',' '{print $7}' | sed 's/\r//g') + ambr_ul=$(echo "$response" | awk -F',' '{print $8}' | sed 's/\r//g') + + # Convert kbit/s to Mbit/s for display if values exist + [ -n "$ambr_dl" ] && ambr_dl=$(awk "BEGIN { printf \"%.2f\", $ambr_dl/1000 }") + [ -n "$ambr_ul" ] && ambr_ul=$(awk "BEGIN { printf \"%.2f\", $ambr_ul/1000 }") + fi + + class="Network Information" + add_plain_info_entry "AMBR UL" "$ambr_ul" "Access Maximum Bit Rate for Uplink" + add_plain_info_entry "AMBR DL" "$ambr_dl" "Access Maximum Bit Rate for Downlink" +} + +convert_neoway_band_to_readable() { + local act=$1 + local band_value=$2 + case "$act" in + "2") echo "WB$band_value" ;; # UTRAN + "3") echo "B$band_value" ;; # E-UTRAN + "6") echo "N$band_value" ;; # NR + *) echo "$band_value" ;; + esac +} + +convert_readable_band_to_neoway() { + local band=$1 + + local prefix=${band:0:1} + local band_value + + case "$prefix" in + "W") + band_value=${band:2} + echo "2 $band_value" + ;; + "B") + band_value=${band:1} + echo "3 $band_value" + ;; + "N") + band_value=${band:1} + echo "6 $band_value" + ;; + *) + echo "3 $band" + ;; + esac +} + +get_lockband() { + json_add_object "lockband" + + at_command="AT+NWSETBAND?" + response=$(at $at_port $at_command) + + local band_num=$(echo "$response" | grep "+NWSETBAND:" | awk '{print $2}' | sed 's/\r//g') + m_debug "Band number: $band_num" + + json_add_object "UMTS" + json_add_array "available_band" + json_close_array + json_add_array "lock_band" + json_close_array + json_close_object + + json_add_object "LTE" + json_add_array "available_band" + json_close_array + json_add_array "lock_band" + json_close_array + json_close_object + + json_add_object "NR" + json_add_array "available_band" + json_close_array + json_add_array "lock_band" + json_close_array + json_close_object + + at_command="AT+NWSETBAND=?" + available_bands=$(at $at_port $at_command | grep "+" | awk -F',' '{for(i=2;i<=NF;i++) print $i}' | sed 's/\r//g') + m_debug "Available bands: $available_bands" + for band in $available_bands; do + if [[ "$band" == WB* ]]; then + band_value=${band:2} + json_select "UMTS" + json_select "available_band" + add_avalible_band_entry "$band_value" "$band" + json_select .. + json_select .. + elif [[ "$band" == B* ]]; then + band_value=${band:1} + json_select "LTE" + json_select "available_band" + add_avalible_band_entry "$band_value" "$band" + json_select .. + json_select .. + elif [[ "$band" == N* ]]; then + band_value=${band:1} + json_select "NR" + json_select "available_band" + add_avalible_band_entry "$band_value" "$band" + json_select .. + json_select .. + fi + done + + if [ "$band_num" != "0" ]; then + IFS=$'\n' + for line in $(echo "$response" | grep -v "+NWSETBAND:" | grep -v "OK"); do + set -- $(echo $line | tr ',' ' ') + act=$1 + num=$2 + shift 2 + for band_value in "$@"; do + if [[ "$band" == WB* ]]; then + act="2" + elif [[ "$band" == B* ]]; then + act="3" + elif [[ "$band" == N* ]]; then + act="6" + fi + band_value=$(echo "$band_value" | awk -F' ' '{print $3}' | sed 's/\r//g') + m_debug "Processing band: $band_value for act: $act" + if [ -n "$band_value" ]; then + case "$act" in + "2") + json_select "UMTS" + json_select "lock_band" + band_value=${band_value:2} + json_add_string "" "$band_value" + json_select .. + json_select .. + ;; + "3") + json_select "LTE" + json_select "lock_band" + band_value=${band_value:1} + json_add_string "" "$band_value" + json_select .. + json_select .. + ;; + "6") + json_select "NR" + json_select "lock_band" + band_value=${band_value:1} + json_add_string "" "$band_value" + json_select .. + json_select .. + ;; + esac + fi + done + done + unset IFS + fi + + json_close_object +} + +set_lockband() { + m_debug "neoway set lockband info" + config=$1 + + band_class=$(echo $config | jq -r '.band_class') + lock_band=$(echo $config | jq -r '.lock_band') + + if [ -z "$lock_band" ] || [ "$lock_band" = "null" ]; then + at_command="AT+NWSETBAND=0" + res=$(at $at_port $at_command) + json_select "result" + json_add_string "set_lockband" "$res" + json_close_object + return + fi + + local act + case "$band_class" in + "UMTS") act=2 ;; + "LTE") act=3 ;; + "NR") act=6 ;; + *) act=3 ;; # 默认LTE + esac + + IFS=','; set -- $lock_band + band_num=$# + at_command="AT+NWSETBAND=$act,$band_num" + for band in "$@"; do + at_command="$at_command,$band" + done + unset IFS + + res=$(at $at_port $at_command) + + json_select "result" + json_add_string "set_lockband" "$res" + json_add_string "config" "$config" + json_add_string "band_class" "$band_class" + json_add_string "lock_band" "$lock_band" + json_close_object +} + +#UL_bandwidth +# $1:上行带宽数字 +get_bandwidth() +{ + local network_type="$1" + local bandwidth_num="$2" + + local bandwidth + case $network_type in + "LTE") + case $bandwidth_num in + "0") bandwidth="1.4" ;; + "1") bandwidth="3" ;; + "2"|"3"|"4"|"5") bandwidth=$((($bandwidth_num - 1) * 5)) ;; + esac + ;; + "NR") + case $bandwidth_num in + "0"|"1"|"2"|"3"|"4"|"5") bandwidth=$((($bandwidth_num + 1) * 5)) ;; + "6"|"7"|"8"|"9"|"10"|"11"|"12") bandwidth=$((($bandwidth_num - 2) * 10)) ;; + "13") bandwidth="200" ;; + "14") bandwidth="400" ;; + esac + ;; + esac + echo "$bandwidth" +} + +#获取NR子载波间隔 +# $1:NR子载波间隔数字 +get_scs() +{ + local scs + case $1 in + "0") scs="15" ;; + "1") scs="30" ;; + "2") scs="60" ;; + "3") scs="120" ;; + "4") scs="240" ;; + *) scs=$(awk "BEGIN{ print 2^$1 * 15 }") ;; + esac + echo "$scs" +} + +#获取物理信道 +# $1:物理信道数字 +get_phych() +{ + local phych + case $1 in + "0") phych="DPCH" ;; + "1") phych="FDPCH" ;; + esac + echo "$phych" +} + +#获取扩频因子 +# $1:扩频因子数字 +get_sf() +{ + local sf + case $1 in + "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7") sf=$(awk "BEGIN{ print 2^$(($1+2)) }") ;; + "8") sf="UNKNOWN" ;; + esac + echo "$sf" +} + +#获取插槽格式 +# $1:插槽格式数字 +get_slot() +{ + local slot=$1 + # case $1 in + # "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"|"10"|"11"|"12"|"13"|"14"|"15"|"16") slot=$1 ;; + # "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9") slot=$1 ;; + # esac + echo "$slot" +} + +#小区信息 +cell_info() +{ + m_debug "Neoway cell info" + + at_command='AT+NETDMSGEX' + response=$(at $at_port $at_command) + + if [ -n "$(echo "$response" | grep "+NETDMSGEX:")" ]; then + m_debug "Using Neoway AT+NETDMSGEX command" + + net_mode=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $1}' | sed 's/+NETDMSGEX: "//g' | sed 's/"//g') + network_mode=$(get_network_mode "$net_mode") + + mcc_mnc=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $2}' | sed 's/"//g') + mcc=$(echo "$mcc_mnc" | cut -d'+' -f1) + mnc=$(echo "$mcc_mnc" | cut -d'+' -f2) + + band=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $3}' | sed 's/LTE BAND //g' | sed 's/NR BAND //g') + + arfcn=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $4}') + + case "$net_mode" in + "NR to 5GCN"|"NR to EPS"|"NR-LTE ENDC"|"NR-LTE NEDC") + + gnbid=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $5}') + pci=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $6}') + ss_rsrp=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $7}') + ss_rsrq=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $8}') + ss_sinr=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $9}') + + if [ "$(echo "$response" | grep -o ',' | wc -l)" -ge 12 ]; then + csi_rsrp=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $10}') + csi_rsrq=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $11}') + csi_sinr=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $12}' | sed 's/\r//g') + fi + + [ -n "$ss_rsrp" ] && ss_rsrp_actual=$(awk "BEGIN { printf \"%.1f\", $ss_rsrp/10 }") + [ -n "$ss_rsrq" ] && ss_rsrq_actual=$(awk "BEGIN { printf \"%.1f\", $ss_rsrq/10 }") + [ -n "$ss_sinr" ] && ss_sinr_actual=$(awk "BEGIN { printf \"%.1f\", $ss_sinr/10 }") + [ -n "$csi_rsrp" ] && csi_rsrp_actual=$(awk "BEGIN { printf \"%.1f\", $csi_rsrp/10 }") + [ -n "$csi_rsrq" ] && csi_rsrq_actual=$(awk "BEGIN { printf \"%.1f\", $csi_rsrq/10 }") + [ -n "$csi_sinr" ] && csi_sinr_actual=$(awk "BEGIN { printf \"%.1f\", $csi_sinr/10 }") + + network_mode="NR5G-SA Mode" + nr_mcc="$mcc" + nr_mnc="$mnc" + nr_cell_id="$gnbid" + nr_physical_cell_id="$pci" + nr_arfcn="$arfcn" + nr_band="$band" + nr_rsrp="$ss_rsrp_actual" + nr_rsrq="$ss_rsrq_actual" + nr_sinr="$ss_sinr_actual" + ;; + + "TDD LTE"|"FDD LTE") + + tac=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $5}') + cell_id=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $6}') + pci=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $7}') + rx_dbm=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $8}') + tx_dbm=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $9}') + rsrp=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $10}') + rsrq=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $11}') + sinr=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $12}') + rssi=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $13}') + + if [ "$(echo "$response" | grep -o ',' | wc -l)" -ge 17 ]; then + srxlev=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $14}') + squal=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $15}') + cqi=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $16}') + dl_bw_num=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $17}') + ul_bw_num=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $18}' | sed 's/\r//g') + + dl_bandwidth=$(get_bandwidth "LTE" "$dl_bw_num") + ul_bandwidth=$(get_bandwidth "LTE" "$ul_bw_num") + fi + + [ -n "$rsrp" ] && rsrp_actual=$(awk "BEGIN { printf \"%.1f\", $rsrp/10 }") + [ -n "$rsrq" ] && rsrq_actual=$(awk "BEGIN { printf \"%.1f\", $rsrq/10 }") + [ -n "$sinr" ] && sinr_actual=$(awk "BEGIN { printf \"%.1f\", $sinr/10 }") + [ -n "$rssi" ] && rssi_actual=$(awk "BEGIN { printf \"%.1f\", $rssi/10 }") + + network_mode="LTE Mode" + lte_mcc="$mcc" + lte_mnc="$mnc" + lte_cell_id="$cell_id" + lte_physical_cell_id="$pci" + lte_earfcn="$arfcn" + lte_freq_band_ind="$band" + lte_tac="$tac" + lte_rsrp="$rsrp_actual" + lte_rsrq="$rsrq_actual" + lte_sinr="$sinr_actual" + lte_rssi="$rssi_actual" + lte_cql="$cqi" + lte_srxlev="$srxlev" + lte_dl_bandwidth="$dl_bandwidth" + lte_ul_bandwidth="$ul_bandwidth" + lte_tx_power="$tx_dbm" + lte_rx_power="$rx_dbm" + ;; + + "WCDMA"|"HSDPA"|"HSUPA"|"HSDPA and HSUPA"|"HSDPA+"|"HSDPA+ and HSUPA") + + lac=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $5}') + cell_id=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $6}') + psc=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $7}') + rac=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $8}') + rx_dbm=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $9}') + tx_dbm=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $10}') + rscp=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $11}') + ecio=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $12}') + rssi=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $13}') + + if [ "$(echo "$response" | grep -o ',' | wc -l)" -ge 17 ]; then + srxlev=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $14}') + squal=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $15}') + phych_num=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $16}') + sf_num=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $17}') + slot_num=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $18}') + is_commod=$(echo "$response" | grep "+NETDMSGEX:" | awk -F',' '{print $19}' | sed 's/\r//g') + + phych=$(get_phych "$phych_num") + sf=$(get_sf "$sf_num") + slot=$(get_slot "$slot_num") + fi + + [ -n "$rscp" ] && rscp_actual=$(awk "BEGIN { printf \"%.1f\", $rscp/10 }") + [ -n "$ecio" ] && ecio_actual=$(awk "BEGIN { printf \"%.1f\", $ecio/10 }") + + network_mode="WCDMA Mode" + wcdma_mcc="$mcc" + wcdma_mnc="$mnc" + wcdma_lac="$lac" + wcdma_cell_id="$cell_id" + wcdma_uarfcn="$arfcn" + wcdma_psc="$psc" + wcdma_rac="$rac" + wcdma_band="$band" + wcdma_rscp="$rscp_actual" + wcdma_ecio="$ecio_actual" + wcdma_phych="$phych" + wcdma_sf="$sf" + wcdma_slot="$slot" + wcdma_com_mod="$is_commod" + wcdma_rx_dbm="$rx_dbm" + wcdma_tx_dbm="$tx_dbm" + ;; + + *) + network_mode="Unknown Mode" + ;; + esac + + class="Cell Information" + add_plain_info_entry "network_mode" "$network_mode" "Network Mode" + + case $network_mode in + "NR5G-SA Mode") + add_plain_info_entry "MCC" "$nr_mcc" "Mobile Country Code" + add_plain_info_entry "MNC" "$nr_mnc" "Mobile Network Code" + add_plain_info_entry "Cell ID" "$nr_cell_id" "Cell ID" + add_plain_info_entry "Physical Cell ID" "$nr_physical_cell_id" "Physical Cell ID" + add_plain_info_entry "ARFCN" "$nr_arfcn" "Absolute Radio-Frequency Channel Number" + add_plain_info_entry "Band" "$nr_band" "Band" + add_bar_info_entry "SS-RSRP" "$nr_rsrp" "Reference Signal Received Power (SS)" -187 -29 dBm + add_bar_info_entry "SS-RSRQ" "$nr_rsrq" "Reference Signal Received Quality (SS)" -43 20 dBm + add_bar_info_entry "SS-SINR" "$nr_sinr" "Signal to Interference plus Noise Ratio (SS)" -23 40 dB + + if [ -n "$csi_rsrp" ]; then + add_bar_info_entry "CSI-RSRP" "$csi_rsrp_actual" "Reference Signal Received Power (CSI)" -187 -29 dBm + add_bar_info_entry "CSI-RSRQ" "$csi_rsrq_actual" "Reference Signal Received Quality (CSI)" -43 20 dBm + add_bar_info_entry "CSI-SINR" "$csi_sinr_actual" "Signal to Interference plus Noise Ratio (CSI)" -23 40 dB + fi + ;; + + "LTE Mode") + add_plain_info_entry "MCC" "$lte_mcc" "Mobile Country Code" + add_plain_info_entry "MNC" "$lte_mnc" "Mobile Network Code" + add_plain_info_entry "Cell ID" "$lte_cell_id" "Cell ID" + add_plain_info_entry "Physical Cell ID" "$lte_physical_cell_id" "Physical Cell ID" + add_plain_info_entry "EARFCN" "$lte_earfcn" "E-UTRA Absolute Radio Frequency Channel Number" + add_plain_info_entry "Band" "$lte_freq_band_ind" "Band" + add_plain_info_entry "TAC" "$lte_tac" "Tracking Area Code" + add_plain_info_entry "RX Power" "$lte_rx_power" "RX Power (dBm)" + add_plain_info_entry "TX Power" "$lte_tx_power" "TX Power (dBm)" + add_bar_info_entry "RSRP" "$lte_rsrp" "Reference Signal Received Power" -140 -44 dBm + add_bar_info_entry "RSRQ" "$lte_rsrq" "Reference Signal Received Quality" -20 20 dBm + add_bar_info_entry "SINR" "$lte_sinr" "Signal to Interference plus Noise Ratio" -23 40 dB + add_bar_info_entry "RSSI" "$lte_rssi" "Received Signal Strength Indicator" -140 -44 dBm + + if [ -n "$lte_cql" ]; then + add_plain_info_entry "CQI" "$lte_cql" "Channel Quality Indicator" + add_plain_info_entry "DL Bandwidth" "$lte_dl_bandwidth" "DL Bandwidth" + add_plain_info_entry "UL Bandwidth" "$lte_ul_bandwidth" "UL Bandwidth" + add_plain_info_entry "Srxlev" "$lte_srxlev" "Serving Cell Receive Level" + fi + ;; + + "WCDMA Mode") + add_plain_info_entry "MCC" "$wcdma_mcc" "Mobile Country Code" + add_plain_info_entry "MNC" "$wcdma_mnc" "Mobile Network Code" + add_plain_info_entry "LAC" "$wcdma_lac" "Location Area Code" + add_plain_info_entry "Cell ID" "$wcdma_cell_id" "Cell ID" + add_plain_info_entry "UARFCN" "$wcdma_uarfcn" "UTRA Absolute Radio Frequency Channel Number" + add_plain_info_entry "PSC" "$wcdma_psc" "Primary Scrambling Code" + add_plain_info_entry "RAC" "$wcdma_rac" "Routing Area Code" + add_plain_info_entry "Band" "$wcdma_band" "Band" + add_plain_info_entry "RX Power" "$wcdma_rx_dbm" "RX Power (dBm)" + add_plain_info_entry "TX Power" "$wcdma_tx_dbm" "TX Power (dBm)" + add_bar_info_entry "RSCP" "$wcdma_rscp" "Received Signal Code Power" -120 -25 dBm + add_plain_info_entry "Ec/Io" "$wcdma_ecio" "Ec/Io" + + if [ -n "$wcdma_phych" ]; then + add_plain_info_entry "Physical Channel" "$wcdma_phych" "Physical Channel" + add_plain_info_entry "Spreading Factor" "$wcdma_sf" "Spreading Factor" + add_plain_info_entry "Slot" "$wcdma_slot" "Slot" + add_plain_info_entry "Compression Mode" "$wcdma_com_mod" "Compression Mode" + fi + ;; + + *) + add_plain_info_entry "Network Type" "$net_mode" "Network Type" + add_plain_info_entry "MCC" "$mcc" "Mobile Country Code" + add_plain_info_entry "MNC" "$mnc" "Mobile Network Code" + add_plain_info_entry "ARFCN" "$arfcn" "Absolute Radio-Frequency Channel Number" + add_plain_info_entry "Band" "$band" "Band" + ;; + esac + fi +} + +get_network_mode() +{ + local mode="$1" + case "$mode" in + "NR to 5GCN"|"NR-LTE ENDC"|"NR-LTE NEDC") echo "NR5G-SA Mode" ;; + "NR to EPS") echo "NR5G-SA Mode" ;; + "TDD LTE"|"FDD LTE") echo "LTE Mode" ;; + "WCDMA"|"HSDPA"|"HSUPA"|"HSDPA and HSUPA"|"HSDPA+"|"HSDPA+ and HSUPA") echo "WCDMA Mode" ;; + "GSM"|"GPRS"|"EDGE") echo "GSM Mode" ;; + *) echo "$mode Mode" ;; + esac +}