Manually using GPRS

From Openmoko

Revision as of 00:24, 25 August 2008 by Ott-- (Talk | contribs)

Jump to: navigation, search

The GPRS connection is made using the PPP protocol to a server identified by an "APN" at the network operator. Once a GPRS connection is made, it is possible to share that connection with a connected computer, allowing that computer to access the internet through the phone!

Contents

Option 1: With GSM multiplexing and with a GUI

NOTE: The following does not appear to work if you have a SIM PIN. The dialog to enter your SIM PIN never pops up and the GSM multiplexing daemon continuous loops and runs into a SIM PIN error.


GSM multiplexing allows both a GPRS connection and a phone call to be handled at the same time. By default, Om 2008.8 does not multiplex the GSM device. The FSO distribution, however, introduces GSM multiplexing with a new service and a DBus API to that service. The instructions to modify the OM2008.8 distribution to make use of GSM multiplexing and allow you to start GPRS from a GUI can be found here: http://freeyourphone.de/portal_v1/viewtopic.php?f=21&t=295

However, using those instructions, you will encounter a few hurdles. Do not use the gsm0710muxd that is found in the OM2008.8 repository. It will not work, instead, use the one found here:

http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/gsm0710muxd_0.9.1+gitr6fecc78198dd821bbe29efd096bd8fecd855179d-r0_armv4t.ipk

In order to install that version of gsm0710muxd, however, you will also have to install a bunch of missing dependencies. Those can be found by clicking on the dependencies found here:

http://www.angstrom-distribution.org/repo/?action=details&pnm=gsm0710muxd

Make sure that you install the armv4t versions of all packages.

The APN Reference table may come in handy when you are looking for the required network specific information.

Once you follow through with all the instructions, you will notice that the "Services" GUI will crash. This has to do with this bug: http://docs.openmoko.org/trac/ticket/1718

The fix is to change the "init()" call on line 82 of /usr/lib/python2.5/site-packages/gtk-2.0/gtk/_init_.py to "_init()" (add an underscore).

You may also have to modify your /etc/resolv.conf file and add the nameserver (DNS Server) of your service provider if you have DNS resolution problems.

Then, hopefully, you should be up in running with GPRS and a GUI to turn it on and off.

Option 2: Without GSM multiplexing and without a GUI

The program that implements PPP on Linux is pppd, which we need to configure and run to get a connection. When that is working, we can configure pppd to wait until it's needed before it connects, and to disconnect if the connection becomes idle. Further, we can start pppd in the background during the boot process.

Configuring pppd for manual connections

You'll need /etc/ppp/peers/gprs:

# Uncomment the following if you want some debug.
#debug
#logfile /var/volatile/log/pppd.log
lock
/dev/ttySAC0 115200
crtscts 
connect /etc/ppp/gprs-connect-chat
disconnect /etc/ppp/gprs-disconnect-chat
hide-password
usepeerdns
ipcp-accept-local
noauth
noipdefault
novj
novjccomp
defaultroute
replacedefaultroute
# Reopen the connection if it fails, pausing for a while.
persist
holdoff 15
# Check the line every 20 seconds and presume
# the peer is gone if no replay for 4 times.
lcp-echo-interval 20
lcp-echo-failure 4

Depending on the APN, you may need password authentication using CHAP or PAP. In /etc/ppp/pap-secrets you can add the following default line for "password-less" connections:

# client        server  secret                  IP addresses
*               *       ""                      *

For CHAP, lines in /etc/ppp/chap-secrets are used. For PAP, the lines are in /etc/ppp/pap-secrets. The client should match the "user" option in pppd the config file (below). You can use * to mean any here, but the option user "" doesn't mean empty!

For example:

# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
"user"         *       "password"                  *  

For this you need the following options in /etc/ppp/peers/gprs:

# username to use for authentication, should match "client" in /etc/ppp/{chap,pap}-secrets
user "user"

gprs-connect-chat, version 1

You'll also need /etc/ppp/gprs-connect-chat (needs "chmod +x"):

#!/bin/sh -e
exec chat -v -S -s\
        TIMEOUT 15\
        "" "\K\K\K\d+++ATH"\
        OK-AT-OK ATZ\
        OK ATE1\
        ABORT BUSY\
        ABORT DELAYED\
        ABORT "NO ANSWER"\
        ABORT "NO DIALTONE"\
        ABORT VOICE\
        ABORT ERROR\
        ABORT RINGING\
        TIMEOUT 60\
        OK AT+CFUN=1\
        OK AT+COPS\
        OK AT+CGDCONT=1,\"IP\",\"internet\"\
        OK ATD*99#\
        CONNECT /n/d

(08/18/08) Note: I needed to add the command "AT+CMOD=2" (formatted as "OK AT+CMOD=2\" without the quotes) in order to get GPRS working with the above script (otherwise it would ERROR on the CFUN, COPS, or the ATD if the other two were removed). I have T-Mobile (US) with the $5.99 "tzones" addon, which works with Minimo as it supports HTTP proxy setups.

gprs-connect-chat, version 2

Update: On my freerunner the first AT+CFUN=1 always generated ERROR. I managed to get gprs work by using the following script from http://lists.openmoko.org/pipermail/community/2008-July/023246.html:

#!/bin/sh -e
exec /usr/sbin/chat -v \
        TIMEOUT 10 \
        OK-AT-'' ''\
        ABORT BUSY\
        ABORT DELAYED\
        ABORT "NO ANSWER"\
        ABORT "NO DIALTONE"\
        ABORT VOICE\
        ABORT ERROR\
        ABORT RINGING\
        TIMEOUT 30 \
        '' ATZ\
        OK ATE1\
        OK AT+CFUN=1\
        ERROR AT+CPIN=\"XXXX\"\         << USE YOUR OWN
        OK AT+COPS\
        OK AT+CGDCONT=1,\"IP\",\"internet\"\
        OK 'ATDT*99***1#'\
        CONNECT ''

The error seems to vary a bit, sometimes it's before AT+COPS, sometimes as above. I have two versions of the gprs-connect-chat, which I vary between depending on which is needed. Or is there a way to specify two acceptable answers like {OK,ERROR}?

You will need to adjust the APN name "internet" in at+cgdcont line and possibly the phone number in the ATD line to match what your network operator provides. See below in the table "Some APN names for reference" for the right settings for your operator.

gprs-disconnect-chat

Also good to have is /etc/ppp/gprs-disconnect-chat (needs "chmod +x"):

#!/bin/sh -e
/usr/sbin/chat -v\
	ABORT OK\
	ABORT BUSY\
	ABORT DELAYED\
	ABORT "NO ANSWER"\
	ABORT "NO CARRIER"\
	ABORT "NO DIALTONE"\
	ABORT VOICE\
	ABORT ERROR\
	ABORT RINGING\
	TIMEOUT 12\
	"" "\K\K\K\d+++ATH"\
	"NO CARRIER-AT-OK" "\c"

Starting PPP connection

The following script can be used to start the ppp connection. First it stops gsmd because gsmd may put the phone in a unknown state. It then turns on the power to the phone, modifies the ownership, and then creates a tty connection. Finally it starts pppd with the gprs settings.

/etc/init.d/gsmd stop
echo "1" > /sys/bus/platform/devices/neo1973-pm-gsm.0/power_on
chown uucp.uucp /dev/ttySAC0
stty -F /dev/ttySAC0 crtscts
pppd call gprs

If you are having problems connecting ensure you have a good GSM signal and replace the last line with the below line. This will allow you to see the details of the connection on the console.

pppd debug nodetach call gprs

The config above will establish a persistant link over gprs. The battery will run low in less than an hour. See an example for an on-demand config below.

Resolve.conf issues

The latest build seems to have solved the following issue, it should be automatically updated by pppd.

If you expeience DNS issues after connecting to DNS you may need a proper /etc/resolv.conf:

ln -sf /var/run/resolv.conf /etc

If needed put your nameserver for usb-net into /var/run/resolv.conf, not in /etc.

The image does not set a correct resolv.conf. i do so with an

echo  nameserver 192.168.0.201 > /var/run/resolv.conf

in the right place. because a post-up in /etc/network/interfaces is not supported i do that in /etc/network/if-up.d/08setupdns

another problem is pppd's /etc/ppp/ip-down.d/92removedns which does not properly remove the link when shuting down ppp. my fix is this script:

#!/bin/sh
ACTUALCONF=/var/run/resolv.conf
PPPCONF=/var/run/ppp/resolv.conf
if [ -f $PPPCONF ] ; then
        if [ -f $ACTUALCONF ] ; then
                if [ ! -h $ACTUALCONF -o ! "`readlink $ACTUALCONF 2>&1`" = "$PPPCONF" ] ; then
                        mv $ACTUALCONF $ACTUALCONF.ppporig
                fi
        fi

        ln -sf $PPPCONF $ACTUALCONF
fi


Some APN names for reference

Country Carrier Plan APN/Phone user/password if required Working pppd scripts
Australia Vodafone Any vfinternet.au
Canada Fido Any, behind NAT internet.fido.ca fido/fido mdbus -s org.freesmartphone.frameworkd /org/freesmartphone/GSM/Device

org.freesmartphone.GSM.PDP.ActivateContext internet.fido.ca fido fido

Canada Rogers Any, behind NAT internet.com wapuser1/wap nameserver 207.181.101.4
Denmark Telmore wap must be empty
Estonia Elisa Any, behind NAT internet
Estonia EMT Any, behind NAT internet.emt.ee
Finland Saunalahti Any internet.saunalahti
Finland Sonera Any, behind NAT internet
Finland Sonera Any, public IP prointernet
France SFR 10.x.x.x? websfr under tests
France SFR 10.x.x.x? wapsfr[1] under tests
France Orange  ??? orange.fr under tests
France Bouyges Telecom Web & Mail mmsbouygtel.com Work great under FSO. Just follow instructions at http://wiki.openmoko.org/wiki/GPRS_FSO. Proxy: 62.201.129.225:8080. For emails, only ports 25 (smtp) and 110 (pop) are allowed. (They use a transparent proxy ...)
Germany E-Plus BASE (and others?) internet.eplus.de eplus gprs Base pppd scripts
Germany E-Plus Simyo internet.eplus.de simyo simyo simyo pppd scripts
Germany T-Mobile internet.t-mobile
Germany Vodafone Any, behind NAT web.vodafone.de
India AirTel MobileOffice airtelgprs.com
Italy Wind Superinternet, public IP internet.wind / *99# wind/wind (any string) Wind pppd scripts
Netherlands Vodafone Any live.vodafone.com / *99***1# Vodafone pppd scripts
New Zealand Vodafone Any live.vodafone.com / *99***2#
Norway Netcom Any internet.netcom.no
Norway OneCall Any internet
Norway Telenor Any telenor
Sweden Parlino internet.parlino.se Works with FSO
Switzerland Swisscom e.g. Natel Basic Liberty, behind NAT gprs.swisscom.ch
UK T-Mobile general.t-mobile.uk
UK Virgin goto.virginmobile.uk user
UK other providers
USA AT&T Unlimited data plan (attached to pay-as-you-go voice plan) wap.cingular / *99***1# WAP@CINGULARGPRS.COM/CINGULAR1
USA Cincinnati Bell Wireless wap.gocbw.com cbw
USA Cingular (AT&T) Less than full internet wap.cingular / may require *99***1#
USA T-mobile Anything less than full internet wap.voicestream.com Need to set proxy to 216.155.165.50 T-Mobile docs say "216.155.165.050". 050 octal = 40 decimal and will *not* work. I think port is 8080 or 9100. No luck w/ pppd scripts. GPRS_FSO directions work under FSO though.
USA T-mobile Regular internet plan internet2.voicestream.com T-Mobile pppd scripts
USA T-mobile "VPN" internet plan internet3.voicestream.com
Venezuela Digitel Pre- y post-pago gprsweb.digitel.ve

[1] connected through a WAP proxy (slower, but the only way to access Vodafone live! and SFR portal)

[2] Unless stated otherwise the phone number to call is "*99#"

Also see Ross Barkman's page for a detailed list of more global GPRS providers APN details

Starting pppd automatically

Once you have finished debugging your gprs-connect-chat and gprs options files, you may wish to automatically connect whenever needed and hang up when finished. Make sure you understand the impact of this change to your carrier plan billing. This is not recommended unless you have a large-use or unlimited data plan. These scripts do NOT prompt you before connecting.

On-demand connection settings

Additional settings are needed if you want the actual connection to be up only while there is traffic. In the 'gprs' file above, insert the following, making sure 'nodetach' is commented out. If 'nodetach' is on, the boot process will stop when it starts pppd. Also remove the option 'persist' mentioned above.


# Wait until needed before connecting
demand

# Disconnect if idle for given amount of seconds
idle 20

Start on boot (method 1)

Add the following definition to /etc/network/interfaces:

auto ppp0
iface ppp0 inet ppp
        provider gprs

That should be it. Now you can use 'ifup ppp0' and 'ifdown ppp0' manually too.

Start on boot (method 2)

Create the following file as /etc/ppp/ppp_on_boot (needs chmod +x). The /etc/init.d/ppp script will call it to set up the daemon.

#!/bin/sh
#
#   Rename this file to ppp_on_boot and pppd will be fired up as
#   soon as the system comes up, connecting to `provider'.
#
#   If you also make this file executable, and replace the first line
#   with just "#!/bin/sh", the commands below will be executed instead.
#

# The location of the ppp daemon itself (shouldn't need to be changed)
PPPD=/usr/sbin/pppd

# The default provider to connect to
$PPPD call gprs

# Additional connections, which would just use settings from
# /etc/ppp/options.<tty>
#$PPPD ttyS0
#$PPPD ttyS1
#$PPPD ttyS2
#$PPPD ttyS3


Finally, you need to add the /etc/init.d/ppp script to the init process by creating symbolic links from the appropriate directories. I chose the following:

/etc/rc0.d/K25ppp
/etc/rc1.d/K45ppp
/etc/rc2.d/S45ppp
/etc/rc3.d/S45ppp
/etc/rc4.d/S45ppp
/etc/rc5.d/S45ppp
/etc/rc6.d/K25ppp

Sharing the GPRS connection with a computer

Once you successfully connect to your network operator, you can start sharing your data plan with your computer through USB or Bluetooth networking. The following describes how you can do so through USB networking.

Setting up your computer's network settings

I find it useful to have my computer automatically acquire it's network address, mask, gateway, and DNS servers from the FreeRunner instead of manually setting these up. In order to this, I installed busybox-udhcpd from the Angstrom repositories (see Repositories)

 opkg install busybox-udhcpd

Once it is installed, it needs to be configured. Edit the /etc/udhcpd.conf file. Mine looks like this:

# Sample udhcpd configuration file (/etc/udhcpd.conf)

# The start and end of the IP lease block

start           192.168.0.200   #default: 192.168.0.20
end             192.168.0.200   #default: 192.168.0.254


# The interface that udhcpd will use

interface       usb0            #default: eth0


# The maximim number of leases (includes addressesd reserved
# by OFFER's, DECLINE's, and ARP conficts

#max_leases     254             #default: 254


# If remaining is true (default), udhcpd will store the time
# remaining for each lease in the udhcpd leases file. This is
# for embedded systems that cannot keep time between reboots.
# If you set remaining to no, the absolute time that the lease
# expires at will be stored in the dhcpd.leases file.

#remaining      yes             #default: yes


# The time period at which udhcpd will write out a dhcpd.leases
# file. If this is 0, udhcpd will never automatically write a
# lease file. (specified in seconds)

#auto_time      7200            #default: 7200 (2 hours)


# The amount of time that an IP will be reserved (leased) for if a
# DHCP decline message is received (seconds).

#decline_time   3600            #default: 3600 (1 hour)


# The amount of time that an IP will be reserved (leased) for if an
# ARP conflct occurs. (seconds

#conflict_time  3600            #default: 3600 (1 hour)


# How long an offered address is reserved (leased) in seconds

#offer_time     60              #default: 60 (1 minute)

# If a lease to be given is below this value, the full lease time is
# instead used (seconds).

#min_lease      60              #defult: 60


# The location of the leases file

#lease_file     /var/lib/misc/udhcpd.leases     #defualt: /var/lib/misc/udhcpd.
leases

# The location of the pid file
#pidfile        /var/run/udhcpd.pid     #default: /var/run/udhcpd.pid

# Everytime udhcpd writes a leases file, the below script will be called.
# Useful for writing the lease file to flash every few hours.

#notify_file                            #default: (no script)

#notify_file    dumpleases      # <--- usefull for debugging

# The following are bootp specific options, setable by udhcpd.

#siaddr         192.168.0.22            #default: 0.0.0.0

#sname          zorak                   #default: (none)

#boot_file      /var/nfs_root           #default: (none)

# The remainer of options are DHCP options and can be specifed with the
# keyword 'opt' or 'option'. If an option can take multiple items, such
# as the dns option, they can be listed on the same line, or multiple
# lines. The only option with a default is 'lease'.

#Examles
opt     dns     192.168.0.202 <your APN's DNS server>
option  subnet  255.255.255.0
opt     router  192.168.0.202
opt     wins    192.168.0.202
#option dns     129.219.13.81   # appened to above DNS servers for a total of 3
option  domain  local
option  lease   864000          # 10 days of seconds


# Currently supported options, for more info, see options.c
#subnet
#timezone
#router
#timesvr
#namesvr
#dns
#logsvr
#cookiesvr
#lprsvr
#bootsize
#domain
#swapsvr
#rootpath
#ipttl
#mtu
#broadcast
#wins
#lease
#ntpsrv
#tftp
#bootfile

Notice that I set the start and end of the IP lease block to 192.168.0.200. If you follow the instructions at USB Networking, this is the address that it assumes the host to be and the /etc/resolv.conf file points to this address to allow name resolution from your phone.

The interface in this case is usb0. This will have to be set differently if you are using Bluetooth.

The dns is set to the FreeRunner's address, as well as my network operator's DNS server address. You don't have to use your network operator's DNS address if you can find a caching nameserver for the FreeRunner.

The router is set to the FreeRunner.

Turning your FreeRunner into a Network Address Translation (NAT) gateway

I set up my FreeRunner so that it acts as a NAT gateway so that all traffic that goes to my network operator appears to originate from the phone. I installed iptables to accomplish this:

 opkg install iptables iptables-utils kernel-module-ipt-masquerade kernel-module-iptable-nat

Once that is installed, I have the following script named firewall.sh that I use to set up the NAT once connected to the GPRS network:

#!/bin/sh
IPTABLES='/usr/sbin/iptables'

# Set interface values
EXTIF='ppp0'
INTIF='usb0'

# enable ip forwarding in the kernel
/bin/echo 1 > /proc/sys/net/ipv4/ip_forward

# flush rules and delete chains
$IPTABLES -F
$IPTABLES -X

#Enable masquerading to allow LAN internet access
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

#Forward LAN traffic from LAN $INTIF to Internet $EXTIF
$IPTABLES -A FORWARD -i $INTIF -o $EXTIF -m state --state NEW,ESTABLISHED -j ACCEPT

#Allowing access to the SSH server"
#$IPTABLES -A INPUT --protocol tcp --dport 22 -j ACCEPT

#Allowing access to the HTTP server"
#$IPTABLES -A INPUT --protocol tcp --dport 80 -j ACCEPT

# block out all other Internet access on $EXTIF
$IPTABLES -A INPUT -i $EXTIF -m state --state NEW,INVALID -j DROP
$IPTABLES -A FORWARD -i $EXTIF -m state --state NEW,INVALID -j DROP

so once connected through GPRS, I run:

 ./firewall.sh

and then you should be able to connect to the internet from your computer!

See also

Personal tools

The GPRS connection is made using the PPP protocol to a server identified by an "APN" at the network operator. Once a GPRS connection is made, it is possible to share that connection with a connected computer, allowing that computer to access the internet through the phone!

Option 1: With GSM multiplexing and with a GUI

NOTE: The following does not appear to work if you have a SIM PIN. The dialog to enter your SIM PIN never pops up and the GSM multiplexing daemon continuous loops and runs into a SIM PIN error.


GSM multiplexing allows both a GPRS connection and a phone call to be handled at the same time. By default, Om 2008.8 does not multiplex the GSM device. The FSO distribution, however, introduces GSM multiplexing with a new service and a DBus API to that service. The instructions to modify the OM2008.8 distribution to make use of GSM multiplexing and allow you to start GPRS from a GUI can be found here: http://freeyourphone.de/portal_v1/viewtopic.php?f=21&t=295

However, using those instructions, you will encounter a few hurdles. Do not use the gsm0710muxd that is found in the OM2008.8 repository. It will not work, instead, use the one found here:

http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/gsm0710muxd_0.9.1+gitr6fecc78198dd821bbe29efd096bd8fecd855179d-r0_armv4t.ipk

In order to install that version of gsm0710muxd, however, you will also have to install a bunch of missing dependencies. Those can be found by clicking on the dependencies found here:

http://www.angstrom-distribution.org/repo/?action=details&pnm=gsm0710muxd

Make sure that you install the armv4t versions of all packages.

The APN Reference table may come in handy when you are looking for the required network specific information.

Once you follow through with all the instructions, you will notice that the "Services" GUI will crash. This has to do with this bug: http://docs.openmoko.org/trac/ticket/1718

The fix is to change the "init()" call on line 82 of /usr/lib/python2.5/site-packages/gtk-2.0/gtk/_init_.py to "_init()" (add an underscore).

You may also have to modify your /etc/resolv.conf file and add the nameserver (DNS Server) of your service provider if you have DNS resolution problems.

Then, hopefully, you should be up in running with GPRS and a GUI to turn it on and off.

Option 2: Without GSM multiplexing and without a GUI

The program that implements PPP on Linux is pppd, which we need to configure and run to get a connection. When that is working, we can configure pppd to wait until it's needed before it connects, and to disconnect if the connection becomes idle. Further, we can start pppd in the background during the boot process.

Configuring pppd for manual connections

You'll need /etc/ppp/peers/gprs:

# Uncomment the following if you want some debug.
#debug
#logfile /var/volatile/log/pppd.log
lock
/dev/ttySAC0 115200
crtscts 
connect /etc/ppp/gprs-connect-chat
disconnect /etc/ppp/gprs-disconnect-chat
hide-password
usepeerdns
ipcp-accept-local
noauth
noipdefault
novj
novjccomp
defaultroute
replacedefaultroute
# Reopen the connection if it fails, pausing for a while.
persist
holdoff 15
# Check the line every 20 seconds and presume
# the peer is gone if no replay for 4 times.
lcp-echo-interval 20
lcp-echo-failure 4

Depending on the APN, you may need password authentication using CHAP or PAP. In /etc/ppp/pap-secrets you can add the following default line for "password-less" connections:

# client        server  secret                  IP addresses
*               *       ""                      *

For CHAP, lines in /etc/ppp/chap-secrets are used. For PAP, the lines are in /etc/ppp/pap-secrets. The client should match the "user" option in pppd the config file (below). You can use * to mean any here, but the option user "" doesn't mean empty!

For example:

# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
"user"         *       "password"                  *  

For this you need the following options in /etc/ppp/peers/gprs:

# username to use for authentication, should match "client" in /etc/ppp/{chap,pap}-secrets
user "user"

gprs-connect-chat, version 1

You'll also need /etc/ppp/gprs-connect-chat (needs "chmod +x"):

#!/bin/sh -e
exec chat -v -S -s\
        TIMEOUT 15\
        "" "\K\K\K\d+++ATH"\
        OK-AT-OK ATZ\
        OK ATE1\
        ABORT BUSY\
        ABORT DELAYED\
        ABORT "NO ANSWER"\
        ABORT "NO DIALTONE"\
        ABORT VOICE\
        ABORT ERROR\
        ABORT RINGING\
        TIMEOUT 60\
        OK AT+CFUN=1\
        OK AT+COPS\
        OK AT+CGDCONT=1,\"IP\",\"internet\"\
        OK ATD*99#\
        CONNECT /n/d

(08/18/08) Note: I needed to add the command "AT+CMOD=2" (formatted as "OK AT+CMOD=2\" without the quotes) in order to get GPRS working with the above script (otherwise it would ERROR on the CFUN, COPS, or the ATD if the other two were removed). I have T-Mobile (US) with the $5.99 "tzones" addon, which works with Minimo as it supports HTTP proxy setups.

gprs-connect-chat, version 2

Update: On my freerunner the first AT+CFUN=1 always generated ERROR. I managed to get gprs work by using the following script from http://lists.openmoko.org/pipermail/community/2008-July/023246.html:

#!/bin/sh -e
exec /usr/sbin/chat -v \
        TIMEOUT 10 \
        OK-AT-'' ''\
        ABORT BUSY\
        ABORT DELAYED\
        ABORT "NO ANSWER"\
        ABORT "NO DIALTONE"\
        ABORT VOICE\
        ABORT ERROR\
        ABORT RINGING\
        TIMEOUT 30 \
        '' ATZ\
        OK ATE1\
        OK AT+CFUN=1\
        ERROR AT+CPIN=\"XXXX\"\         << USE YOUR OWN
        OK AT+COPS\
        OK AT+CGDCONT=1,\"IP\",\"internet\"\
        OK 'ATDT*99***1#'\
        CONNECT ''

The error seems to vary a bit, sometimes it's before AT+COPS, sometimes as above. I have two versions of the gprs-connect-chat, which I vary between depending on which is needed. Or is there a way to specify two acceptable answers like {OK,ERROR}?

You will need to adjust the APN name "internet" in at+cgdcont line and possibly the phone number in the ATD line to match what your network operator provides. See below in the table "Some APN names for reference" for the right settings for your operator.

gprs-disconnect-chat

Also good to have is /etc/ppp/gprs-disconnect-chat (needs "chmod +x"):

#!/bin/sh -e
/usr/sbin/chat -v\
	ABORT OK\
	ABORT BUSY\
	ABORT DELAYED\
	ABORT "NO ANSWER"\
	ABORT "NO CARRIER"\
	ABORT "NO DIALTONE"\
	ABORT VOICE\
	ABORT ERROR\
	ABORT RINGING\
	TIMEOUT 12\
	"" "\K\K\K\d+++ATH"\
	"NO CARRIER-AT-OK" "\c"

Starting PPP connection

The following script can be used to start the ppp connection. First it stops gsmd because gsmd may put the phone in a unknown state. It then turns on the power to the phone, modifies the ownership, and then creates a tty connection. Finally it starts pppd with the gprs settings.

/etc/init.d/gsmd stop
echo "1" > /sys/bus/platform/devices/neo1973-pm-gsm.0/power_on
chown uucp.uucp /dev/ttySAC0
stty -F /dev/ttySAC0 crtscts
pppd call gprs

If you are having problems connecting ensure you have a good GSM signal and replace the last line with the below line. This will allow you to see the details of the connection on the console.

pppd debug nodetach call gprs

The config above will establish a persistant link over gprs. The battery will run low in less than an hour. See an example for an on-demand config below.

Resolve.conf issues

The latest build seems to have solved the following issue, it should be automatically updated by pppd.

If you expeience DNS issues after connecting to DNS you may need a proper /etc/resolv.conf:

ln -sf /var/run/resolv.conf /etc

If needed put your nameserver for usb-net into /var/run/resolv.conf, not in /etc.

The image does not set a correct resolv.conf. i do so with an

echo  nameserver 192.168.0.201 > /var/run/resolv.conf

in the right place. because a post-up in /etc/network/interfaces is not supported i do that in /etc/network/if-up.d/08setupdns

another problem is pppd's /etc/ppp/ip-down.d/92removedns which does not properly remove the link when shuting down ppp. my fix is this script:

#!/bin/sh
ACTUALCONF=/var/run/resolv.conf
PPPCONF=/var/run/ppp/resolv.conf
if [ -f $PPPCONF ] ; then
        if [ -f $ACTUALCONF ] ; then
                if [ ! -h $ACTUALCONF -o ! "`readlink $ACTUALCONF 2>&1`" = "$PPPCONF" ] ; then
                        mv $ACTUALCONF $ACTUALCONF.ppporig
                fi
        fi

        ln -sf $PPPCONF $ACTUALCONF
fi


Some APN names for reference

Country Carrier Plan APN/Phone user/password if required Working pppd scripts
Australia Vodafone Any vfinternet.au
Canada Fido Any, behind NAT internet.fido.ca fido/fido mdbus -s org.freesmartphone.frameworkd /org/freesmartphone/GSM/Device

org.freesmartphone.GSM.PDP.ActivateContext internet.fido.ca fido fido

Canada Rogers Any, behind NAT internet.com wapuser1/wap nameserver 207.181.101.4
Denmark Telmore wap must be empty
Estonia Elisa Any, behind NAT internet
Estonia EMT Any, behind NAT internet.emt.ee
Finland Saunalahti Any internet.saunalahti
Finland Sonera Any, behind NAT internet
Finland Sonera Any, public IP prointernet
France SFR 10.x.x.x? websfr under tests
France SFR 10.x.x.x? wapsfr[1] under tests
France Orange  ??? orange.fr under tests
France Bouyges Telecom Web & Mail mmsbouygtel.com Work great under FSO. Just follow instructions at http://wiki.openmoko.org/wiki/GPRS_FSO. Proxy: 62.201.129.225:8080. For emails, only ports 25 (smtp) and 110 (pop) are allowed. (They use a transparent proxy ...)
Germany E-Plus BASE (and others?) internet.eplus.de eplus gprs Base pppd scripts
Germany E-Plus Simyo internet.eplus.de simyo simyo simyo pppd scripts
Germany T-Mobile internet.t-mobile
Germany Vodafone Any, behind NAT web.vodafone.de
India AirTel MobileOffice airtelgprs.com
Italy Wind Superinternet, public IP internet.wind / *99# wind/wind (any string) Wind pppd scripts
Netherlands Vodafone Any live.vodafone.com / *99***1# Vodafone pppd scripts
New Zealand Vodafone Any live.vodafone.com / *99***2#
Norway Netcom Any internet.netcom.no
Norway OneCall Any internet
Norway Telenor Any telenor
Sweden Parlino internet.parlino.se Works with FSO
Switzerland Swisscom e.g. Natel Basic Liberty, behind NAT gprs.swisscom.ch
UK T-Mobile general.t-mobile.uk
UK Virgin goto.virginmobile.uk user
UK other providers
USA AT&T Unlimited data plan (attached to pay-as-you-go voice plan) wap.cingular / *99***1# WAP@CINGULARGPRS.COM/CINGULAR1
USA Cincinnati Bell Wireless wap.gocbw.com cbw
USA Cingular (AT&T) Less than full internet wap.cingular / may require *99***1#
USA T-mobile Anything less than full internet wap.voicestream.com Need to set proxy to 216.155.165.50 T-Mobile docs say "216.155.165.050". 050 octal = 40 decimal and will *not* work. I think port is 8080 or 9100. No luck w/ pppd scripts. GPRS_FSO directions work under FSO though.
USA T-mobile Regular internet plan internet2.voicestream.com T-Mobile pppd scripts
USA T-mobile "VPN" internet plan internet3.voicestream.com
Venezuela Digitel Pre- y post-pago gprsweb.digitel.ve

[1] connected through a WAP proxy (slower, but the only way to access Vodafone live! and SFR portal)

[2] Unless stated otherwise the phone number to call is "*99#"

Also see Ross Barkman's page for a detailed list of more global GPRS providers APN details

Starting pppd automatically

Once you have finished debugging your gprs-connect-chat and gprs options files, you may wish to automatically connect whenever needed and hang up when finished. Make sure you understand the impact of this change to your carrier plan billing. This is not recommended unless you have a large-use or unlimited data plan. These scripts do NOT prompt you before connecting.

On-demand connection settings

Additional settings are needed if you want the actual connection to be up only while there is traffic. In the 'gprs' file above, insert the following, making sure 'nodetach' is commented out. If 'nodetach' is on, the boot process will stop when it starts pppd. Also remove the option 'persist' mentioned above.


# Wait until needed before connecting
demand

# Disconnect if idle for given amount of seconds
idle 20

Start on boot (method 1)

Add the following definition to /etc/network/interfaces:

auto ppp0
iface ppp0 inet ppp
        provider gprs

That should be it. Now you can use 'ifup ppp0' and 'ifdown ppp0' manually too.

Start on boot (method 2)

Create the following file as /etc/ppp/ppp_on_boot (needs chmod +x). The /etc/init.d/ppp script will call it to set up the daemon.

#!/bin/sh
#
#   Rename this file to ppp_on_boot and pppd will be fired up as
#   soon as the system comes up, connecting to `provider'.
#
#   If you also make this file executable, and replace the first line
#   with just "#!/bin/sh", the commands below will be executed instead.
#

# The location of the ppp daemon itself (shouldn't need to be changed)
PPPD=/usr/sbin/pppd

# The default provider to connect to
$PPPD call gprs

# Additional connections, which would just use settings from
# /etc/ppp/options.<tty>
#$PPPD ttyS0
#$PPPD ttyS1
#$PPPD ttyS2
#$PPPD ttyS3


Finally, you need to add the /etc/init.d/ppp script to the init process by creating symbolic links from the appropriate directories. I chose the following:

/etc/rc0.d/K25ppp
/etc/rc1.d/K45ppp
/etc/rc2.d/S45ppp
/etc/rc3.d/S45ppp
/etc/rc4.d/S45ppp
/etc/rc5.d/S45ppp
/etc/rc6.d/K25ppp

Sharing the GPRS connection with a computer

Once you successfully connect to your network operator, you can start sharing your data plan with your computer through USB or Bluetooth networking. The following describes how you can do so through USB networking.

Setting up your computer's network settings

I find it useful to have my computer automatically acquire it's network address, mask, gateway, and DNS servers from the FreeRunner instead of manually setting these up. In order to this, I installed busybox-udhcpd from the Angstrom repositories (see Repositories)

 opkg install busybox-udhcpd

Once it is installed, it needs to be configured. Edit the /etc/udhcpd.conf file. Mine looks like this:

# Sample udhcpd configuration file (/etc/udhcpd.conf)

# The start and end of the IP lease block

start           192.168.0.200   #default: 192.168.0.20
end             192.168.0.200   #default: 192.168.0.254


# The interface that udhcpd will use

interface       usb0            #default: eth0


# The maximim number of leases (includes addressesd reserved
# by OFFER's, DECLINE's, and ARP conficts

#max_leases     254             #default: 254


# If remaining is true (default), udhcpd will store the time
# remaining for each lease in the udhcpd leases file. This is
# for embedded systems that cannot keep time between reboots.
# If you set remaining to no, the absolute time that the lease
# expires at will be stored in the dhcpd.leases file.

#remaining      yes             #default: yes


# The time period at which udhcpd will write out a dhcpd.leases
# file. If this is 0, udhcpd will never automatically write a
# lease file. (specified in seconds)

#auto_time      7200            #default: 7200 (2 hours)


# The amount of time that an IP will be reserved (leased) for if a
# DHCP decline message is received (seconds).

#decline_time   3600            #default: 3600 (1 hour)


# The amount of time that an IP will be reserved (leased) for if an
# ARP conflct occurs. (seconds

#conflict_time  3600            #default: 3600 (1 hour)


# How long an offered address is reserved (leased) in seconds

#offer_time     60              #default: 60 (1 minute)

# If a lease to be given is below this value, the full lease time is
# instead used (seconds).

#min_lease      60              #defult: 60


# The location of the leases file

#lease_file     /var/lib/misc/udhcpd.leases     #defualt: /var/lib/misc/udhcpd.
leases

# The location of the pid file
#pidfile        /var/run/udhcpd.pid     #default: /var/run/udhcpd.pid

# Everytime udhcpd writes a leases file, the below script will be called.
# Useful for writing the lease file to flash every few hours.

#notify_file                            #default: (no script)

#notify_file    dumpleases      # <--- usefull for debugging

# The following are bootp specific options, setable by udhcpd.

#siaddr         192.168.0.22            #default: 0.0.0.0

#sname          zorak                   #default: (none)

#boot_file      /var/nfs_root           #default: (none)

# The remainer of options are DHCP options and can be specifed with the
# keyword 'opt' or 'option'. If an option can take multiple items, such
# as the dns option, they can be listed on the same line, or multiple
# lines. The only option with a default is 'lease'.

#Examles
opt     dns     192.168.0.202 <your APN's DNS server>
option  subnet  255.255.255.0
opt     router  192.168.0.202
opt     wins    192.168.0.202
#option dns     129.219.13.81   # appened to above DNS servers for a total of 3
option  domain  local
option  lease   864000          # 10 days of seconds


# Currently supported options, for more info, see options.c
#subnet
#timezone
#router
#timesvr
#namesvr
#dns
#logsvr
#cookiesvr
#lprsvr
#bootsize
#domain
#swapsvr
#rootpath
#ipttl
#mtu
#broadcast
#wins
#lease
#ntpsrv
#tftp
#bootfile

Notice that I set the start and end of the IP lease block to 192.168.0.200. If you follow the instructions at USB Networking, this is the address that it assumes the host to be and the /etc/resolv.conf file points to this address to allow name resolution from your phone.

The interface in this case is usb0. This will have to be set differently if you are using Bluetooth.

The dns is set to the FreeRunner's address, as well as my network operator's DNS server address. You don't have to use your network operator's DNS address if you can find a caching nameserver for the FreeRunner.

The router is set to the FreeRunner.

Turning your FreeRunner into a Network Address Translation (NAT) gateway

I set up my FreeRunner so that it acts as a NAT gateway so that all traffic that goes to my network operator appears to originate from the phone. I installed iptables to accomplish this:

 opkg install iptables iptables-utils kernel-module-ipt-masquerade kernel-module-iptable-nat

Once that is installed, I have the following script named firewall.sh that I use to set up the NAT once connected to the GPRS network:

#!/bin/sh
IPTABLES='/usr/sbin/iptables'

# Set interface values
EXTIF='ppp0'
INTIF='usb0'

# enable ip forwarding in the kernel
/bin/echo 1 > /proc/sys/net/ipv4/ip_forward

# flush rules and delete chains
$IPTABLES -F
$IPTABLES -X

#Enable masquerading to allow LAN internet access
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

#Forward LAN traffic from LAN $INTIF to Internet $EXTIF
$IPTABLES -A FORWARD -i $INTIF -o $EXTIF -m state --state NEW,ESTABLISHED -j ACCEPT

#Allowing access to the SSH server"
#$IPTABLES -A INPUT --protocol tcp --dport 22 -j ACCEPT

#Allowing access to the HTTP server"
#$IPTABLES -A INPUT --protocol tcp --dport 80 -j ACCEPT

# block out all other Internet access on $EXTIF
$IPTABLES -A INPUT -i $EXTIF -m state --state NEW,INVALID -j DROP
$IPTABLES -A FORWARD -i $EXTIF -m state --state NEW,INVALID -j DROP

so once connected through GPRS, I run:

 ./firewall.sh

and then you should be able to connect to the internet from your computer!

See also