11#! /bin/sh
22# Copyright (C) 2025 x-shark
3-
3+ _Vendor=" foxconn"
4+ _Author=" x-shark"
5+ _Maintainer=" x-shark <unknown>"
46source /usr/share/qmodem/generic.sh
5- debug_subject=" quectel_ctrl "
7+ debug_subject=" foxconn_ctrl "
68
79name=$( uci -q get qmodem.$config_section .name)
810case " $name " in
@@ -55,15 +57,15 @@ function get_mode(){
5557 config_type=` echo -e " $cfg " | grep -o ' [0-9]' `
5658 if [ " $config_type " = " 1" ]; then
5759 mode_num=" 0"
58- json_add_int disable_mode_btn 1
60+ json_add_int disable_mode_btn 1
5961
6062 else
61- ucfg=$( at $at_port $at_pre " USBSWITCH?" )
62- config_type=$( echo " $ucfg " | grep USBSWITCH: | cut -d' :' -f2| xargs)
63- if [ " $config_type " = " 9025" ]; then
64- mode_num=" 1"
65- elif [ " $config_type " = " 90D5" ]; then
66- mode_num=" 0"
63+ ucfg=$( at $at_port $at_pre " USBSWITCH?" )
64+ config_type=$( echo " $ucfg " | grep USBSWITCH: | cut -d' :' -f2| xargs)
65+ if [ " $config_type " = " 9025" ]; then
66+ mode_num=" 1"
67+ elif [ " $config_type " = " 90D5" ]; then
68+ mode_num=" 0"
6769 fi
6870 fi
6971 case " $platform " in
@@ -232,7 +234,7 @@ function sim_info()
232234
233235 # SIM Status(SIM状态)
234236 at_command=" AT+CPIN?"
235- sim_status=$( at $at_port $at_command | grep " +CPIN:" )
237+ sim_status=$( at $at_port $at_command | grep " +CPIN:" )
236238 sim_status=${sim_status: 7:- 1}
237239 # lowercase
238240 sim_status=$( echo $sim_status | tr A-Z a-z)
@@ -254,15 +256,15 @@ function sim_info()
254256 fi
255257
256258 at_command=" AT+CNUM"
257- sim_number=$( at $at_port $at_command | awk -F' "' ' {print $2}' | xargs)
259+ sim_number=$( at $at_port $at_command | awk -F' "' ' {print $2}' | xargs)
258260
259261 # IMSI(国际移动用户识别码)
260262 at_command=" AT+CIMI"
261- imsi=$( at $at_port $at_command | sed -n ' 2p' | sed ' s/\r//g' )
263+ imsi=$( at $at_port $at_command | sed -n ' 2p' | sed ' s/\r//g' )
262264
263265 # ICCID(集成电路卡识别码)
264266 at_command=" AT+ICCID"
265- iccid=$( at $at_port $at_command | sed -n ' 2p' | sed ' s/\r//g' | sed ' s/[^0-9]*//g' )
267+ iccid=$( at $at_port $at_command | sed -n ' 2p' | sed ' s/\r//g' | sed ' s/[^0-9]*//g' )
266268 case " $sim_status " in
267269 " ready" )
268270 add_plain_info_entry " SIM Status" " $sim_status " " SIM Status"
@@ -420,7 +422,7 @@ set_lockband_nr(){
420422 # lock_band=$(echo $lock_band | tr ',' ':')
421423 case " $band_class " in
422424 " UMTS" )
423- lock_band=$( echo $lock_band )
425+ lock_band=$( echo $lock_band )
424426 at_command=$at_pre " BAND_PREF=WCDMA,2,$lock_band "
425427 res=$( at $at_port $at_command )
426428 ;;
@@ -527,6 +529,24 @@ function _band_list_to_mask()
527529 echo " $low ,$high "
528530}
529531
532+ function process_signal_value() {
533+ local value=" $1 "
534+ local numbers=$( echo " $value " | grep -oE ' [-+]?[0-9]+(\.[0-9]+)?' )
535+ local count=0
536+ local total=0
537+
538+ for num in $numbers ; do
539+ total=$( echo " $total + $num " | bc -l)
540+ count=$(( count+ 1 ))
541+ done
542+
543+ if [ $count -gt 0 ]; then
544+ echo " scale=2; $total / $count " | bc -l | sed ' s/^\./0./' | sed ' s/^-\./-0./'
545+ else
546+ echo " "
547+ fi
548+ }
549+
530550cell_info (){
531551 class=" Cell Information"
532552 at_command=$at_pre " debug?"
@@ -536,19 +556,21 @@ cell_info(){
536556
537557 case $network_mode in
538558 " LTE" )
539- lte_mcc=$( echo " $response " | awk -F' mcc:' ' {print $2}' | awk -F' ,' ' {print $1}' | xargs)
540- lte_mnc=$( echo " $response " | awk -F' mnc:' ' {print $2}' | xargs)
541- lte_earfcn=$( echo " $response " | awk -F' channel:' ' {print $2}' | awk -F' ' ' {print $1}' | xargs)
542- lte_physical_cell_id=$( echo " $response " | awk -F' pci:' ' {print $2}' | awk -F' ' ' {print $1}' | xargs)
543- lte_cell_id=$( echo " $response " | awk -F' lte_cell_id:' ' {print $2}' | xargs)
544- lte_band=$( echo " $response " | awk -F' lte_band:' ' {print $2}' | awk -F' ' ' {print $1}' | xargs)
545- lte_freq_band_ind=$( echo " $response " | awk -F' lte_band_width:' ' {print $2}' | xargs)
546- lte_sinr=$( echo " $response " | awk -F' lte_snr:' ' {print $2}' | awk ' {print $1}' | sed -n ' s/[^0-9.-]*\([+-]*[0-9]*\.[0-9]*\)[^0-9.-]*/\1/p' | xargs)
547- lte_rsrq=$( echo " $response " | awk -F' rsrq:' ' {print $2}' | sed -n ' s/[^0-9.-]*\([+-]*[0-9]*\.[0-9]*\)[^0-9.-]*/\1/p' | xargs)
548- lte_rssi=$( echo " $response " | awk -F' lte_rssi:' ' {print $2}' | awk -F' ,' ' {print $1}' | sed -n ' s/[^0-9.-]*\([+-]*[0-9]*\.[0-9]*\)[^0-9.-]*/\1/p' | xargs)
549- # lte_rssnr=$(echo "$response"|
550- lte_tac=$( echo " $response " | awk -F' lte_tac:' ' {print $2}' | xargs)
551- lte_tx_power=$( echo " $response " | awk -F' lte_tx_pwr:' ' {print $2}' | xargs)
559+ lte_mcc=$( echo " $response " | awk -F' mcc:' ' {print $2}' | awk -F' ,' ' {print $1}' | xargs)
560+ lte_mnc=$( echo " $response " | awk -F' mnc:' ' {print $2}' | xargs)
561+ lte_earfcn=$( echo " $response " | awk -F' channel:' ' {print $2}' | awk -F' ' ' {print $1}' | xargs)
562+ lte_physical_cell_id=$( echo " $response " | awk -F' pci:' ' {print $2}' | awk -F' ' ' {print $1}' | xargs)
563+ lte_cell_id=$( echo " $response " | awk -F' lte_cell_id:' ' {print $2}' | xargs)
564+ lte_band=$( echo " $response " | awk -F' lte_band:' ' {print $2}' | awk -F' ' ' {print $1}' | xargs)
565+ lte_freq_band_ind=$( echo " $response " | awk -F' lte_band_width:' ' {print $2}' | xargs)
566+ lte_sinr=$( echo " $response " | awk -F' lte_snr:' ' {print $2}' | awk ' {print $1}' | xargs)
567+ lte_sinr=$( process_signal_value " $lte_sinr " )
568+ lte_rsrq=$( echo " $response " | awk -F' rsrq:' ' {print $2}' | xargs)
569+ lte_rsrq=$( process_signal_value " $lte_rsrq " )
570+ lte_rssi=$( echo " $response " | awk -F' lte_rssi:' ' {print $2}' | awk -F' ,' ' {print $1}' | xargs)
571+ lte_rssi=$( process_signal_value " $lte_rssi " )
572+ lte_tac=$( echo " $response " | awk -F' lte_tac:' ' {print $2}' | xargs)
573+ lte_tx_power=$( echo " $response " | awk -F' lte_tx_pwr:' ' {print $2}' | xargs)
552574
553575 add_plain_info_entry " MCC" " $lte_mcc " " Mobile Country Code"
554576 add_plain_info_entry " MNC" " $lte_mnc " " Mobile Network Code"
@@ -561,9 +583,9 @@ cell_info(){
561583 # add_plain_info_entry "UL Bandwidth" "$lte_ul_bandwidth" "UL Bandwidth"
562584 # add_plain_info_entry "DL Bandwidth" "$lte_dl_bandwidth" "DL Bandwidth"
563585 add_plain_info_entry " TAC" " $lte_tac " " Tracking area code of cell served by neighbor Enb"
564- add_bar_info_entry " RSRQ" " $lte_rsrq " " Reference Signal Received Quality" -20 20 dBm
565- add_bar_info_entry " RSSI" " $lte_rssi " " Received Signal Strength Indicator" -120 -44 dBm
566- add_bar_info_entry " SINR" " $lte_sinr " " Signal to Interference plus Noise Ratio Bandwidth" -23 40 dB
586+ add_bar_info_entry " RSRQ" " $lte_rsrq " " Reference Signal Received Quality" -19.5 -3 dB
587+ add_bar_info_entry " RSSI" " $lte_rssi " " Received Signal Strength Indicator" -120 -20 dBm
588+ add_bar_info_entry " SINR" " $lte_sinr " " Signal to Interference plus Noise Ratio Bandwidth" 0 30 dB
567589 # add_plain_info_entry "RxLev" "$lte_rxlev" "Received Signal Level"
568590 add_plain_info_entry " RSSNR" " $lte_rssnr " " Radio Signal Strength Noise Ratio"
569591 # add_plain_info_entry "CQI" "$lte_cql" "Channel Quality Indicator"
@@ -583,10 +605,15 @@ cell_info(){
583605 nr_band_width=$( echo " $response " | awk -F' nr_band_width:' ' {print $2}' | awk -F' ' ' {print $1}' | xargs)
584606 nr_freq_band_ind=$( echo " $response " | awk -F' lte_band_width:' ' {print $2}' | xargs)
585607 nr_sinr=$( echo " $response " | awk -F' nr_snr:' ' {print $2}' | awk ' {print $1}' | xargs)
608+ nr_sinr=$( process_signal_value " $nr_sinr " )
586609 nr_rsrq=$( echo " $response " | awk -F' rsrq:' ' {print $2}' | xargs)
610+ nr_rsrq=$( process_signal_value " $nr_rsrq " )
587611 nr_rsrp=$( echo " $response " | awk -F' rsrp:' ' {print $2}' | awk ' {print $1}' | xargs)
612+ nr_rsrp=$( process_signal_value " $nr_rsrp " )
588613 nr_rssi=$( echo " $response " | awk -F' nr_rssi:' ' {print $2}' | awk -F' ,' ' {print $1}' | xargs)
614+ nr_rssi=$( process_signal_value " $nr_rssi " )
589615 nr_tac=$( echo " $response " | awk -F' nr_tac:' ' {print $2}' | xargs)
616+ nr_tx_power=$( echo " $response " | awk -F' nr_tx_pwr:' ' {print $2}' | xargs)
590617
591618 if [ " $has_ca " -gt 0 ]; then
592619 nr_display_mode=" NR5G_SA-CA"
@@ -609,10 +636,9 @@ cell_info(){
609636 add_plain_info_entry " EARFCN" " $nr_earfcn " " E-UTRA Absolute Radio Frequency Channel Number"
610637 add_plain_info_entry " Freq band indicator" " $nr_freq_band_ind " " Freq band indicator"
611638 add_plain_info_entry " TAC" " $nr_tac " " Tracking area code of cell served by neighbor Enb"
612- add_bar_info_entry " RSRQ" " $nr_rsrq " " Reference Signal Received Quality" -43 20 dBm
613- add_bar_info_entry " RSRP" " $nr_rsrp " " Reference Signal Received Power" -187 -29 dBm
614- add_bar_info_entry " SINR" " $nr_sinr " " Signal to Interference plus Noise Ratio Bandwidth" -23 40 dB
615- add_plain_info_entry " RSSNR" " $nr_rssnr " " Radio Signal Strength Noise Ratio"
639+ add_bar_info_entry " RSRQ" " $nr_rsrq " " Reference Signal Received Quality" -19.5 -3 dB
640+ add_bar_info_entry " RSRP" " $nr_rsrp " " Reference Signal Received Power" -140 -44 dBm
641+ add_bar_info_entry " SINR" " $nr_sinr " " Signal to Interference plus Noise Ratio Bandwidth" 0 30 dB
616642 add_plain_info_entry " TX Power" " $nr_tx_power " " TX Power"
617643 ;;
618644 esac
0 commit comments