Setting up a PPP interface with a GPRS shield on a Raspberry Pi
The steps, in order.
Hi friends,
This is my first technical post here. Getting a PPP interface up with a GPRS shield took me two full, painful weeks. I put the steps in one place so the next person can skip that.
Install PPP on the Raspberry Pi:
sudo apt-get install ppp
To use the GPRS shield as a dial-up modem you need two files.
- A configuration file that tells the PPP daemon where to find the shield, and parameters such as the baud rate.
- A chat script that talks to the GPRS modem.
Name the connection gprs. Create /etc/ppp/peers/gprs and copy this configuration. The shield here is a Telit GL868-Dual V3.
debug
/dev/ttyUSB0
9600
connect 'chat -f /etc/ppp/chat/gprs'
defaultroute
noauth
lock
passive
usepeerdns
The chat script lives at /etc/ppp/chat/gprs. This is the script for the Telit GL868 series:
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
REPORT CONNECT
TIMEOUT 10
"" "AT&F"
OK "ATE1"
OK 'AT#SCFG=1,1,1500,0,60,50'
OK 'AT+CGDCONT=1,"IP","internet"'
OK 'AT#ENS=1'
OK 'AT+CGACT=1,1'
TIMEOUT 100
OK "ATD*99***1#"
CONNECT ''
Once both files are in place, bring the link up:
sudo pppd call gprs
A few notes on chat scripts:
- If the script fails, adjust the timeouts, kill the process, and start again.
- A small script in
/etc/rc.local, or a cron job, can check the connection and restart the modem.
ppp0 is not the default route yet, so add it by hand:
sudo route add default ppp0
Further reading:
A stable device name
The peer file names a device such as /dev/ttyUSB0. That name can change every time the Pi restarts. You do not control the order. This is the USB enumeration problem.
To see which USB serial ports are present:
dmesg | grep ttyUSB
To read the vendor id and product id, walk the attributes of the port you actually have (the example uses ttyUSB1):
udevadm info --name=/dev/ttyUSB1 --attribute-walk
Create /etc/udev/rules.d/99-usb-serial.rules with a line like this. Put in the ids you found, and any symlink name you like:
SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", SYMLINK+="ttyGSM"
Load the new rule and check that the name appeared:
sudo udevadm trigger
ls -l /dev/ttyGSM
Point the peer file at that stable name instead of /dev/ttyUSB0.
First written in 2015 on virtual eye.