Skip to content

Instantly share code, notes, and snippets.

@oprietop
Last active April 12, 2017 08:52
Show Gist options
  • Save oprietop/2ec32261b2cf439c84c81c0a3b5b221f to your computer and use it in GitHub Desktop.
Save oprietop/2ec32261b2cf439c84c81c0a3b5b221f to your computer and use it in GitHub Desktop.
wdial wrapper for 3G orange modems
#!/bin/bash
# wdial wrapper for 3G orange modems
set +o posix
ok() { echo -ne "\e[32m#\n#\t$1\n#\e[m\n"; }
nk() { echo -ne "\e[31m#\n#\t$1\n#\e[m\n"; exit 1; }
[ -c /dev/ttyHS0 ] && [ -c /dev/ttyHS1 ] && {
USB1=/dev/ttyHS3 # Globetrotter HSUPA Modem (aka icon 451)
USB2=/dev/ttyHS3
PIN=
}
[ $USB1 ] || nk "Modem not detected!"
ok "Looking for wvdial pppd and grep binaries:"
which wvdial pppd grep || nk "Missing binaries!"
[ ${#PIN} -ne 4 ] && {
ok "Enter PIN:"
stty -echo # No echo
read -r PIN
stty echo
}
[ ${#PIN} -ne 4 ] && nk "PIN must be 4 chars"
ok "Introducing PIN on $USB1"
exec 3<<__EOF__
[Dialer Defaults]
Modem = $USB1
#Baud = 57600
Init1 = ATZ+CPIN=$PIN
Init2 = ATZ
Init3 = AT+CGDCONT=1,"IP","orangeworld","0.0.0.0",0,0;
__EOF__
wvdial -C /proc/$$/fd/3
ok "Connecting with PPP over $USB2"
exec 4<<__EOF__
[Dialer Defaults]
Modem = $USB2
#Baud = 460800
Stupid Mode = 1
#Auto DNS = 0
Phone = *99#
Username = orange
Password = orange
__EOF__
wvdial -C /proc/$$/fd/4
ok "Out!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment