Skip to content

Commit af0b772

Browse files
committed
feat: add support for Huawei MH5000-82M and add auto dial functionality
1 parent 46c96a1 commit af0b772

File tree

4 files changed

+201
-25
lines changed

4 files changed

+201
-25
lines changed

application/qmodem/files/usr/share/qmodem/modem_dial.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ update_config()
148148
config_get en_bridge $modem_config en_bridge
149149
config_get do_not_add_dns $modem_config do_not_add_dns
150150
config_get dns_list $modem_config dns_list
151+
config_get huawei_dial_mode $modem_config huawei_dial_mode
151152
config_get global_dial main enable_dial
152153
# config_get ethernet_5g u$modem_config ethernet 转往口获取命令更新,待测试
153154
config_foreach get_associate_ethernet_by_path modem-slot
@@ -590,6 +591,13 @@ wwan_hang()
590591

591592
ecm_hang()
592593
{
594+
m_debug "ecm_hang"
595+
auto_dial_hang_fail=0
596+
auto_dial_hang
597+
auto_dial_hang_fail=$?
598+
if [ $auto_dial_hang_fail -eq 0 ]; then
599+
return
600+
fi
593601
case "$manufacturer" in
594602
"quectel")
595603
at_command="AT+QNETDEVCTL=$pdp_index,2,1"
@@ -622,6 +630,19 @@ ecm_hang()
622630
[ -n "$delay" ] && sleep "$delay"
623631
}
624632

633+
auto_dial_stop(){
634+
m_debug "stop auto dial"
635+
case "$manufacturer" in
636+
"huawei")
637+
case "$platform" in
638+
"unisoc")
639+
;;
640+
esac
641+
;;
642+
esac
643+
}
644+
645+
625646
hang()
626647
{
627648
m_debug "hang up $modem_path driver $driver"
@@ -862,6 +883,82 @@ at_dial()
862883
esac
863884
}
864885

886+
at_auto_dial()
887+
{
888+
case $manufacturer in
889+
"huawei")
890+
case $platform in
891+
"unisoc")
892+
huawei_auto_dial_unisoc
893+
return 0
894+
;;
895+
esac
896+
;;
897+
esac
898+
return 1
899+
}
900+
901+
huawei_auto_dial_unisoc()
902+
{
903+
m_debug "huawei_auto_dial: auto dial(no monitor)"
904+
m_debug "huawei_auto_dial: vendor:$manufacturer; platform:$platform; driver:$driver; apn:$apn; command:$at_command; pdp_index:$pdp_index; huawei_dial_mode:$huawei_dial_mode; at_port:$at_port"
905+
# dial prepare
906+
cgdcont_command="AT+CGDCONT=$pdp_index,\"$pdp_type\",\"$apn\""
907+
at "$at_port" "$cgdcont_command"
908+
# get current auto dial setting
909+
at_command='AT^SETAUTODIAL?'
910+
at_res=$(at "$at_port" "$at_command" | grep 'SETAUTO')
911+
# return ^SETAUTODAIL:1,x
912+
current_setting=${at_res##*:}
913+
dial_status=$(echo "$current_setting" | cut -d ',' -f 1)
914+
current_dial_mode=$(echo "$current_setting" | cut -d ',' -f 2)
915+
m_debug "current dial status: $dial_status, current dial mode: $current_dial_mode"
916+
# if dial stat is disabled, or when huawei_dial_mode is not empty and current dial mode is not equal to huawei_dial_mode, enable dial
917+
if [ "$dial_status" = "0" ] || [ ! -z "$huawei_dial_mode" ] && [ "$current_dial_mode" != "$huawei_dial_mode" ]; then
918+
[ -n "$huawei_dial_mode" ] && dial_mode=",$huawei_dial_mode" || dial_mode=",4"
919+
at_command="AT^SETAUTODIAL=1$dial_mode"
920+
at "$at_port" "$at_command"
921+
fi
922+
}
923+
924+
auto_dial_hang_huawei_unisoc()
925+
{
926+
m_debug "huawei_auto_hang"
927+
at_command='AT^SETAUTODIAL?'
928+
current_setting=$(at "$at_port" "$at_command" | grep 'SETAUTO')
929+
# return ^SETAUTODAIL:1,x
930+
current_setting=${current_setting##*:}
931+
dial_status=$(echo "$current_setting" | cut -d ',' -f 1)
932+
if [ "$dial_status" = "1" ]; then
933+
at_command="AT^SETAUTODIAL=0"
934+
at "$at_port" "$at_command"
935+
m_debug "huawei_at_hang: auto hang done"
936+
m_debug "huawei_at_hang: turning radio off"
937+
off_cmd="AT+CFUN=0"
938+
on_cmd="AT+CFUN=1"
939+
at "$at_port" "$off_cmd"
940+
m_debug "huawei_at_hang: turning radio on"
941+
at "$at_port" "$on_cmd"
942+
return 0
943+
fi
944+
return 1
945+
}
946+
947+
auto_dial_hang(){
948+
m_debug "auto_dial_hang"
949+
case "$manufacturer" in
950+
"huawei")
951+
case "$platform" in
952+
"unisoc")
953+
auto_dial_hang_huawei_unisoc
954+
return $?
955+
;;
956+
esac
957+
;;
958+
esac
959+
return 1
960+
}
961+
865962
ip_change_fm350()
866963
{
867964
m_debug "ip_change_fm350"
@@ -1016,6 +1113,16 @@ check_logfile_line()
10161113
unexpected_response_count=0
10171114
at_dial_monitor()
10181115
{
1116+
#check if support auto dial
1117+
auto_dial_support=0
1118+
at_auto_dial
1119+
auto_dial_support=$?
1120+
if [ $auto_dial_support -eq 0 ]; then
1121+
m_debug "dialing service is managed by modem(auto dial), do not need monitor"
1122+
while true; do
1123+
sleep 30
1124+
done
1125+
fi
10191126
at_dial
10201127
ipv4_cache=$ipv4
10211128
ipv6_cache=$ipv6

application/qmodem/files/usr/share/qmodem/modem_port_rule.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@
7272
"include": [
7373
"1.1"
7474
]
75+
},
76+
"1782:4058": {
77+
"name": "TDTECH MH5000-82M",
78+
"mode": "ecm",
79+
"option_driver": 1,
80+
"include": [
81+
"1.2"
82+
]
7583
}
7684
}
7785
}

application/qmodem/files/usr/share/qmodem/modem_support.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,22 @@
146146
"ecm"
147147
]
148148
},
149+
"mh5000-82m": {
150+
"manufacturer_id": "12d1",
151+
"manufacturer": "huawei",
152+
"platform": "unisoc",
153+
"data_interface": "usb",
154+
"pdp_index": "1",
155+
"wcdma_band": "1/8",
156+
"lte_band": "1/3/5/8/34/38/39/40/41",
157+
"nsa_band": "41/78/79",
158+
"sa_band": "1/41/78/79",
159+
"modes": [
160+
"ecm",
161+
"ncm",
162+
"rndis"
163+
]
164+
},
149165
"rg200u-cn": {
150166
"manufacturer_id": "2c7c",
151167
"manufacturer": "quectel",
@@ -1008,8 +1024,8 @@
10081024
"rndis"
10091025
]
10101026
},
1011-
"t77w968":{
1012-
"manufacturer_id": "413c",
1027+
"t77w968": {
1028+
"manufacturer_id": "413c",
10131029
"manufacturer": "foxconn",
10141030
"platform": "qualcomm",
10151031
"data_interface": "usb",
@@ -1045,7 +1061,7 @@
10451061
"rmnet"
10461062
]
10471063
},
1048-
"srm821": {
1064+
"srm821": {
10491065
"manufacturer_id": "1782",
10501066
"manufacturer": "meig",
10511067
"platform": "unisoc",

application/qmodem/files/usr/share/qmodem/vendor/huawei.sh

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ source /usr/share/qmodem/generic.sh
77
debug_subject="quectel_ctrl"
88

99
vendor_get_disabled_features(){
10-
json_add_string "" "LockBand"
10+
case "$platform" in
11+
*)
12+
json_add_string "" "LockBand"
13+
json_add_string "" "NeighborCell"
14+
;;
15+
esac
1116
}
1217

1318
function get_imei(){
@@ -23,15 +28,27 @@ function set_imei(){
2328
function get_mode(){
2429
cfg=$(at $at_port "AT^SETMODE?")
2530
local mode_num=`echo -e "$cfg" | sed -n '2p' | sed 's/\r//g'`
26-
27-
case "$mode_num" in
28-
"0"|"2") mode="ecm" ;;
29-
"1"|"3"|"4"|"5") mode="ncm" ;;
30-
"6") mode="rndis" ;;
31-
"7") mode="mbim" ;;
32-
"8") mode="ppp" ;;
33-
*) mode="rndis" ;;
31+
case $platform in
32+
"unisoc")
33+
case $mode_num in
34+
"0") mode="rndis" ;;
35+
"1") mode="ecm" ;;
36+
"2") mode="ncm" ;;
37+
*) mode="rndis" ;;
38+
esac
39+
;;
40+
*)
41+
case "$mode_num" in
42+
"0"|"2") mode="ecm" ;;
43+
"1"|"3"|"4"|"5") mode="ncm" ;;
44+
"6") mode="rndis" ;;
45+
"7") mode="mbim" ;;
46+
"8") mode="ppp" ;;
47+
*) mode="rndis" ;;
48+
esac
49+
;;
3450
esac
51+
3552

3653
available_modes=$(uci -q get qmodem.$config_section.modes)
3754
json_add_object "mode"
@@ -48,17 +65,35 @@ function get_mode(){
4865
function set_mode(){
4966
local mode=$1
5067
local mode_num
51-
case $mode in
52-
"ecm")
53-
mode_num="0"
54-
;;
55-
"ncm")
56-
mode_num="4"
68+
case "$platform" in
69+
"unisoc")
70+
case $mode in
71+
"rndis")
72+
mode_num="0"
73+
;;
74+
"ecm")
75+
mode_num="1"
76+
;;
77+
"ncm")
78+
mode_num="0"
79+
;;
80+
esac
5781
;;
5882
*)
59-
mode_num="0"
60-
;;
83+
case $mode in
84+
"ecm")
85+
mode_num="0"
86+
;;
87+
"ncm")
88+
mode_num="4"
89+
;;
90+
*)
91+
mode_num="0"
92+
;;
93+
esac
94+
;;
6195
esac
96+
6297
at $at_port "AT^SETMODE=${mode_num}"
6398
}
6499

@@ -542,10 +577,21 @@ function _get_temperature(){
542577
response=$(at $at_port "AT^CHIPTEMP?" | grep "\^CHIPTEMP" | awk -F',' '{print $6}' | sed 's/\r//g' )
543578

544579
local temperature
545-
[ -n "$response" ] && {
546-
response=$(awk "BEGIN{ printf \"%.2f\", $response / 10 }" | sed 's/\.*0*$//')
547-
add_plain_info_entry "temperature" "$response $(printf "\xc2\xb0")C" "Temperature"
548-
}
580+
case $platform in
581+
"unisoc")
582+
[ -n "$response" ] && {
583+
response=$(awk "BEGIN{ printf \"%.2f\", $response }" | sed 's/\.*0*$//')
584+
add_plain_info_entry "temperature" "$response $(printf "\xc2\xb0")C" "Temperature"
585+
}
586+
;;
587+
*)
588+
[ -n "$response" ] && {
589+
response=$(awk "BEGIN{ printf \"%.2f\", $response / 10 }" | sed 's/\.*0*$//')
590+
add_plain_info_entry "temperature" "$response $(printf "\xc2\xb0")C" "Temperature"
591+
}
592+
;;
593+
esac
594+
549595
}
550596

551597
function _add_avalible_band(){
@@ -645,4 +691,3 @@ for line in $data;do
645691
done
646692
unset IFS
647693
}
648-

0 commit comments

Comments
 (0)