Skip to content

Commit

Permalink
modemband: Update to 20240616
Browse files Browse the repository at this point in the history
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
  • Loading branch information
1715173329 committed Jul 13, 2024
1 parent b798734 commit cc212ef
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 9 deletions.
2 changes: 1 addition & 1 deletion net/modemband/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=modemband
PKG_VERSION:=20240204
PKG_VERSION:=20240616
PKG_RELEASE:=1

PKG_LICENSE:=MIT
Expand Down
4 changes: 4 additions & 0 deletions net/modemband/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ Setting LTE/5G NSA/5G SA bands for selected modems.
Supported devices:
- BroadMobi BM806U
- Dell DW5821e Snapdragon X20 LTE (Foxconn T77W968)
- Fibocom FM350-GL
- Fibocom L850-GL
- Fibocom L850-GL in mbim mode
- Fibocom L860-GL
- Fibocom L860-GL-16
- HP lt4112 (Huawei ME906E)
- HP lt4132 LTE/HSPA+ 4G Module (Huawei ME906s-158)
- HP lt4220 (Foxconn T77W676)
Expand All @@ -23,6 +25,7 @@ Supported devices:
- Quectel RM500Q-GL
- Quectel RM500U-CNV
- Quectel RM502Q-AE
- Quectel RM502Q-GL
- Quectel RM505Q-AE
- Quectel RM520N-GL
- Sierra Wireless EM7455/MC7455/DW5811e
Expand All @@ -32,6 +35,7 @@ Supported devices:
- Telit LN940 (Foxconn T77W676) in mbim mode
- Telit LN960 (Foxconn T77W968)
- Telit LN960
- Yuge CLM920 NC_5
- ZTE MF286 (router)
- ZTE MF286A (router)
- ZTE MF286D (router)
Expand Down
2 changes: 2 additions & 0 deletions net/modemband/files/usr/bin/modemband.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#
# (c) 2022-2024 Cezary Jackiewicz <cezary@eko.one.pl>
#
# (c) 2022-2024 modified by Rafał Wabik - IceG - From eko.one.pl forum
#

hextobands() {
BANDS=""
Expand Down
36 changes: 36 additions & 0 deletions net/modemband/files/usr/share/modemband/05c69625
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
_DEVICE=/dev/ttyUSB2
_DEFAULT_LTE_BANDS="1 3 5 8 38 39 40 41"

getinfo() {
echo "Yuge CLM920 NC_5"
}

getsupportedbands() {
echo "$_DEFAULT_LTE_BANDS"
}

getbands() {
O=$(sms_tool -d $_DEVICE at "as+bandcfg?")
HEXHI=$(echo "$O" | awk -F[,] '/^\+BANDCFG:3,/{print $2}' | xargs)
HEXLO=$(echo "$O" | awk -F[,] '/^\+BANDCFG:3,/{print $3}' | xargs)
hextobands $(printf "0x%x%08x" 0x${HEXHI:-0} 0x${HEXLO:-0})
}

setbands() {
BANDS="$1"
[ "$BANDS" = "default" ] && BANDS="$_DEFAULT_LTE_BANDS"

HEX=$(bandstohex "$BANDS")
LEN=${#HEX}
if [ $LEN -gt 8 ]; then
CNT=$((LEN - 8))
HEXHI=${HEX:0:CNT}
HEXLO=${HEX:CNT}
else
HEXLO=$HEX
HEXHI=0
fi
HEXHI=$(printf "%X" 0x$HEXHI)
HEXLO=$(printf "%X" 0x$HEXLO)
[ "$HEX" != "0" ] && sms_tool -d $_DEVICE at "at+bandcfg=$HEXHI,$HEXLO,3"
}
4 changes: 4 additions & 0 deletions net/modemband/files/usr/share/modemband/0e8d7126
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# +GTUSBMODE: 40
_DEVICE=/dev/ttyUSB2

. $RES/_fibocom_fm350_common
4 changes: 4 additions & 0 deletions net/modemband/files/usr/share/modemband/0e8d7127
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# +GTUSBMODE: 41
_DEVICE=/dev/ttyUSB4

. $RES/_fibocom_fm350_common
47 changes: 47 additions & 0 deletions net/modemband/files/usr/share/modemband/11999091
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
_DEVICE=/dev/ttyUSB2

getinfo() {
echo "Sierra Wireless EM7465"
}

getsupportedbands() {
sms_tool -d $_DEVICE at 'AT!ENTERCND="A710"' >/dev/null 2>&1
O=$(sms_tool -d $_DEVICE at 'AT!BAND=?')
HEX=$(echo "$O" | awk '/^00, All bands/{printf "0x%s%s\n", $6, $5}')
[ "$HEX" = "0x" ] || hextobands "$HEX"
}

getbands() {
sms_tool -d $_DEVICE at 'AT!ENTERCND="A710"' >/dev/null 2>&1
O=$(sms_tool -d $_DEVICE at 'AT!BAND?')
HEX=$(echo "$O" | awk -F, '/^[0-9a-fA-F][0-9a-fA-F],/{print $3}' | awk '{printf "0x%s%s\n", $3, $2}')
[ "$HEX" = "0x" ] || hextobands "$HEX"
}

setbands() {
BANDS="$1"

if [ "$BANDS" = "default" ]; then
sms_tool -d $_DEVICE at 'AT!ENTERCND="A710"' >/dev/null 2>&1
sms_tool -d $_DEVICE at 'AT!BAND=00' >/dev/null 2>&1
else
HEX=$(bandstohex "$BANDS")
if [ "$HEX" != "0" ]; then
sms_tool -d $_DEVICE at 'AT!ENTERCND="A710"' >/dev/null 2>&1
O=$(sms_tool -d $_DEVICE at 'AT!BAND?')
HEXGW=$(echo "$O" | awk -F, '/^[0-9a-fA-F][0-9a-fA-F],/{print $3}' | awk '{print $1}')
LEN=${#HEX}
if [ $LEN -gt 16 ]; then
CNT=$((LEN - 16))
HEXL2=${HEX:0:CNT}
HEXL1=${HEX:CNT}
else
HEXL1=$HEX
HEXL2=0
fi
sms_tool -d $_DEVICE at 'AT!BAND=10,"Custom bands",'$HEXGW','$HEXL1','$HEXL2
sms_tool -d $_DEVICE at 'AT!BAND=10'
sms_tool -d $_DEVICE at 'AT!RESET'
fi
fi
}
4 changes: 2 additions & 2 deletions net/modemband/files/usr/share/modemband/1e0e9001
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ getbands5gnsa() {

setbands5gnsa() {
BANDS="$1"
[ "$BANDS" = "default" ] && BANDS="$_DEFAULT_LTE_BANDS"
[ "$BANDS" = "default" ] && BANDS="$_DEFAULT_5GNSA_BANDS"

T=""
for BAND in $BANDS; do
Expand All @@ -68,7 +68,7 @@ getbands5gsa() {

setbands5gsa() {
BANDS="$1"
[ "$BANDS" = "default" ] && BANDS="$_DEFAULT_5GNSA_BANDS"
[ "$BANDS" = "default" ] && BANDS="$_DEFAULT_5GSA_BANDS"

T=""
for BAND in $BANDS; do
Expand Down
12 changes: 12 additions & 0 deletions net/modemband/files/usr/share/modemband/2c7c0800RM502Q-GL
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
_DEVICE=/dev/ttyUSB2
_DEFAULT_LTE_BANDS="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 43 48 66 71"
_DEFAULT_5GNSA_BANDS="38 41 77 78"
_DEFAULT_5GSA_BANDS="1 2 3 5 7 8 12 20 25 28 38 40 41 48 66 71 77 78"

getinfo() {
echo "Quectel RM502Q-GL"
}

# +QNWPREFCFG: "lte_band",1:3:7:8:20:28:38

. $RES/_quectel_common2
10 changes: 4 additions & 6 deletions net/modemband/files/usr/share/modemband/8087095a
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ _DEVICE=/dev/ttyACM2

getinfo() {
O=$(sms_tool -d $_DEVICE at "at+gmm")
if echo "$O" | grep -q "L850"; then
_NAME="Fibocom L850-GL"
fi
if echo "$O" | grep -q "L860"; then
_NAME="Fibocom L860-GL"
fi
_NAME="Fibocom $(echo "$O" | awk -F, '{print $2}')"
echo "$_NAME"
}

Expand All @@ -19,6 +14,9 @@ getsupportedbands() {
if echo "$O" | grep -q "L860"; then
_DEFAULT_LTE_BANDS="1 2 3 4 5 7 8 12 13 14 17 18 19 20 25 26 28 29 30 32 38 39 40 41 42 46 66"
fi
if echo "$O" | grep -q "L860-GL-16"; then
_DEFAULT_LTE_BANDS="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 43 46 48 66 71"
fi
echo "$_DEFAULT_LTE_BANDS"
}

Expand Down
87 changes: 87 additions & 0 deletions net/modemband/files/usr/share/modemband/_fibocom_fm350_common
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
getinfo() {
O=$(sms_tool -d $_DEVICE at "AT+CGMM?")
_NAME="Fibocom $(echo "$O" | awk -F[:,] '/^\+CGMM:/{gsub("\"","");print $2}' | xargs)"
echo "$_NAME"
}

getsupportedbands() {
_DEFAULT_LTE_BANDS="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 43 46 48 66 71"
echo "$_DEFAULT_LTE_BANDS"
}

getbands() {
# +GTACT: 20,6,3,101,102,103,104,105,107,108,112,113,114,117,118,119,120,125,126,128,129,130,132,134,138,139,140,141,142,143,146,148,166,171

O=$(sms_tool -d $_DEVICE at "AT+GTACT?")
BANDS=$(echo "$O" | awk -F: '/^\+GTACT:/{gsub(","," ");print $2}')
for BAND in $BANDS; do
if [ $BAND -gt 100 ] && [ $BAND -lt 200 ]; then
echo -n "$((BAND - 100)) "
fi
done
echo ""
}

setbands() {
BANDS="$1"

T=""
if [ "$BANDS" = "default" ]; then
T="0"
else
for BAND in $BANDS; do
case $BAND in
''|*[!0-9]*) continue ;;
esac
[ -n "$T" ] && T="${T},"
T="${T}$((BAND + 100))"
done
fi

if [ -n "$T" ]; then
O=$(sms_tool -d $_DEVICE at "AT+GTACT?")
MODE=$(echo "$O" | awk -F[:,] '/\+GTACT:/{print $2","$3","$4}'| xargs)
sms_tool -d $_DEVICE at "AT+GTACT=$MODE,$T"
fi
}

getsupportedbands5gsa() {
_DEFAULT_5GSA_BANDS="1 2 3 5 7 8 20 25 28 30 38 40 41 48 66 71 77 78 79"
echo "$_DEFAULT_5GSA_BANDS"
}

getbands5gsa() {
# +GTACT: 20,6,3,501,502,503,505,507,508,5020,5025,5028,5030,5038,5040,5041,5048,5066,5071,5077,5078,5079

O=$(sms_tool -d $_DEVICE at "AT+GTACT?")
BANDS=$(echo "$O" | awk -F: '/^\+GTACT:/{gsub(","," ");print $2}')
for BAND in $BANDS; do
if [ $BAND -gt 500 ] && [ $BAND -lt 5100 ]; then
echo -n "$(echo "$BAND" | sed 's/^50//g') "
fi
done
echo ""
}

setbands5gsa() {
BANDS="$1"

T=""
if [ "$BANDS" = "default" ]; then
T="0"
else
for BAND in $BANDS; do
case $BAND in
''|*[!0-9]*) continue ;;
esac
[ -n "$T" ] && T="${T},"
T="${T}50${BAND}"
done
fi

if [ -n "$T" ]; then
O=$(sms_tool -d $_DEVICE at "AT+GTACT?")
MODE=$(echo "$O" | awk -F[:,] '/\+GTACT:/{print $2","$3","$4}'| xargs)
sms_tool -d $_DEVICE at "AT+GTACT=$MODE,$T"
fi
}

0 comments on commit cc212ef

Please sign in to comment.