Skip to content

Instantly share code, notes, and snippets.

@johngroves
Forked from 4rzael/sim908.md
Last active January 2, 2017 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johngroves/2ac7f2be190e5c29f3c36a35745cca97 to your computer and use it in GitHub Desktop.
Save johngroves/2ac7f2be190e5c29f3c36a35745cca97 to your computer and use it in GitHub Desktop.
Use the SIM908 on odroid U3
#!/bin/bash
# Config /etc/ppp/peers/fona
(test -e /etc/ppp/peers/fona && echo "/etc/ppp/peers/fona already exists") ||
(touch /etc/ppp/peers/fona &&
echo '# Example PPPD configuration for SIM908 on Archlinux-ARM.' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# MUST CHANGE: Change the -T parameter value **** to your networks APN value.' >> /etc/ppp/peers/fona;
echo '# For example if your APN is 'internet' (without quotes), the line would look like:' >> /etc/ppp/peers/fona;
echo '# connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T internet"' >> /etc/ppp/peers/fona;
echo '# I'm connecting via Ting's 2G cellular plan for IOT, which uses the APN "wholesale"'
echo 'connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T wholesale"' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# The Odroid U3 UART port is part of GPIO #1, and named "ttySAC0"' >> /etc/ppp/peers/fona;
echo '/dev/ttySAC0' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# Baud rate of the serial line. I am using 9600, but it can be increased as needed.' >> /etc/ppp/peers/fona;
echo '9600' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# Assumes that your IP address is allocated dynamically by the ISP.' >> /etc/ppp/peers/fona;
echo 'noipdefault' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# Try to get the name server addresses from the ISP.' >> /etc/ppp/peers/fona;
echo 'usepeerdns' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# Use this connection as the default route to the internet.' >> /etc/ppp/peers/fona;
echo 'defaultroute' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# Makes PPPD "dial again" when the connection is lost.' >> /etc/ppp/peers/fona;
echo 'persist' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# Do not ask the remote to authenticate.' >> /etc/ppp/peers/fona;
echo 'noauth' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# # No hardware flow control on the serial link' >> /etc/ppp/peers/fona;
echo 'nocrtscts' >> /etc/ppp/peers/fona;
echo '' >> /etc/ppp/peers/fona;
echo '# No modem control lines.' >> /etc/ppp/peers/fona;
echo 'local' >> /etc/ppp/peers/fona);
# Config /etc/chatscripts/gprs
(test -e /etc/chatscripts/gprs && echo "/etc/chatscripts.gprs already exists") ||
(mkdir /etc/chatscripts;
touch /etc/chatscripts/gprs &&
echo '#Abort the chat script on the following conditions' >> /etc/chatscripts/gprs;
echo ' ' >> /etc/chatscripts/gprs;
echo 'ABORT BUSY' >> /etc/chatscripts/gprs;
echo 'ABORT VOICE' >> /etc/chatscripts/gprs;
echo 'ABORT "NO CARRIER"' >> /etc/chatscripts/gprs;
echo 'ABORT "NO DIALTONE"' >> /etc/chatscripts/gprs;
echo 'ABORT "NO DIAL TONE"' >> /etc/chatscripts/gprs;
echo 'ABORT "NO ANSWER"' >> /etc/chatscripts/gprs;
echo 'ABORT "DELAYED"' >> /etc/chatscripts/gprs;
echo 'ABORT "ERROR"' >> /etc/chatscripts/gprs;
echo ' ' >> /etc/chatscripts/gprs;
echo '# Abort attempt to connect if the modem is not yet attached to the network.' >> /etc/chatscripts/gprs;
echo 'ABORT "+CGATT: 0"' >> /etc/chatscripts/gprs;
echo ' ' >> /etc/chatscripts/gprs;
echo '"" AAAAAA # init the baudrate' >> /etc/chatscripts/gprs;
echo '"" AT' >> /etc/chatscripts/gprs;
echo 'TIMEOUT 12' >> /etc/chatscripts/gprs;
echo 'OK ATH' >> /etc/chatscripts/gprs;
echo 'OK ATE1' >> /etc/chatscripts/gprs;
echo ' ' >> /etc/chatscripts/gprs;
echo '# Use +CPIN if you need to provide the SIM card PIN example uses code 1234.' >> /etc/chatscripts/gprs;
echo '#OK "AT+CPIN=1234"' >> /etc/chatscripts/gprs;
echo ' ' >> /etc/chatscripts/gprs;
echo '# Set the PDP context, continue on OK' >> /etc/chatscripts/gprs;
echo ' ' >> /etc/chatscripts/gprs;
echo 'OK AT+CGDCONT=1,"IP","\T","",0,0' >> /etc/chatscripts/gprs;
echo 'OK ATD*99#' >> /etc/chatscripts/gprs;
echo 'TIMEOUT 22' >> /etc/chatscripts/gprs;
echo 'CONNECT ""' >> /etc/chatscripts/gprs);
# Start PPP
pon fona;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment