Skip to content

Instantly share code, notes, and snippets.

@vitouXY
Created March 8, 2021 17:41
Show Gist options
  • Save vitouXY/82dc1fe2177975785d447fffde41d517 to your computer and use it in GitHub Desktop.
Save vitouXY/82dc1fe2177975785d447fffde41d517 to your computer and use it in GitHub Desktop.
Modem 3G - PPP - USB Modeswitch

PPP

find /dev/ | grep ttyUSB
nano /etc/ppp/options-e303_USB0
/dev/ttyUSB0
#460800
9600
modem
crtscts
-detach
defaultroute
dump
noipdefault
#usepeerdns # Set DNS from PPP Connection
usehostname
ktune
logfd 2
noauth
name E303PPP
lock
maxfail 10

ipcp-restart 8
ipcp-max-configure 50
ipcp-max-failure 10
ipcp-accept-local
ipcp-accept-remote
persist
lcp-echo-failure 10
lcp-echo-interval 60
lcp-max-failure 10
holdoff 8

child-timeout 5
#logfile /tmp/_pppd.log
nano /etc/chatscripts/e303-modem.chat
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "BUSY"
ABORT "ERROR"
ABORT "NO ANSWER"
"" ATZ
OK 'AT+CGDCONT=1,"IP","internet.simple"'
OK 'ATD*99#'
nano /etc/ppp/peers/e303_USB0
# ln -s /etc/ppp/peers/e303_USB0 /etc/ppp/peers/provider
file /etc/ppp/options-e303_USB0
user 0
password 0
connect "/usr/sbin/chat -v -t15 -f /etc/chatscripts/e303-modem.chat"
nano /etc/ppp/wait-dialup-hardware
#!/bin/bash
# /etc/ppp/wait-dialup-hardware
for ((retry=0; retry < $((${1} * 10)); retry++)); do
[ -c /dev/ttyUSB0 ] && break || sleep 0.1s ;done # in $((retry/10)).$((100*(retry%10)/10)) secs
[ -c /dev/ttyUSB0 ] && setsid nohup pon e303_USB0
nano /etc/ppp/peers/e303_wait
# ln -s /etc/ppp/peers/e303_wait /etc/ppp/peers/provider
noauth
pty "/etc/ppp/wait-dialup-hardware 25" # sleep 25s && setsid nohup pon e303_USB0
# Huawei E303
[    7.694810] usb 1-1: New USB device found, idVendor=12d1, idProduct=14fe, bcdDevice= 1.02
[   34.154581] usb 1-1: New USB device found, idVendor=12d1, idProduct=1506, bcdDevice= 1.02


# usb_modeswitch
# https://github.com/garyybl/project/blob/master/3gdongle/
# usb_modeswitch -I -W -s 10 -c "/etc/usb_modeswitch/12d1:1f01" -v 12d1 -p 1f01
# usb_modeswitch -I -W -s 10 -v 12d1 -p 1f01 -M '55534243<...>000' -V 12d1 -P 14db

# Huawei E8372
# 12d1:1f01 -> 12d1:14db
TargetVendor= 0x12d1
TargetProduct= 0x14db
MessageContent="55534243123456780000000000000a11062000000000000100000000000000"
NoDriverLoading=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment