James Gardner: Home > Blog > 2007 > Orange GPRS via Samsung Bluetooth...

Orange GPRS via Samsung Bluetooth on Debian

Posted:2007-08-26 23:16
Tags:Desktop Software, Debian, Hardware

I have a Samsung SHG-E250 mobile phone on Orange pay as you go in the UK. I've also got a Belkin USB bluetooth dongle model F8T013xx1 and I wanted to be able to access the internet from my Debian laptop over GPRS. This article is a working solution but there is a lot about the intricacies of what's going on that I don't understand so whilst I hope this is useful, I make no guarantees!

Paying a Provider

The first challenge is the cost. Standard tariffs is £4 per MB which is frankly outrageous. There is a handy trick you can use if you want to use GPRS on Orange. If you have Pay As You Go in the UK you get unlimited GPRS data until midnight that day for just £1. It is called an "Orange Extra" and you and rather than internet access it is called "Orange World". From your phone dial 450 free. Then choose options 3111 followed by:

  1. Unlimited data until midnight for £1
  2. 4Mb total valid for 30 days for £4
  3. A week's unlimited access for £5

The amount is taken off your Pay As You Go Balance immediately and you are asked to hold until the service has gone through and you are sent a txt after a few seconds confirming you can start using the service. You can check your remaining balance, including the Orange World access you just bought by dialing 453. You can use the unlimited data for £1 extra each day if you like.

Setting up Bluetooth on the Desktop

Once the financial side is sorted out you need to set up your connection. If you have installed the standard Gnome desktop then the "bluez" Bluetooth stack will already be set up. Just plug the dongle in and you can start pairing the devices. Right click the Bluetooth icon on the gnome panel which appears when you plug in the Bluetooth dongle. Choose preferences, give your computer a sensible name and choose "Visible and connectable for other devices". My computer is called dirac-0 which you'll see in some of the output later on.

On your phone turn on Bluetooth and select scan for devices to pair with the computer. You'll be asked to enter a 4 digit pin. Choose something memorable. A message box will pop up on the desktop. Click it, enter the PIN and the devices will be bonded. That's the easy bit, now time to test the connection.

Playing with Bluetooth

Scan for devices:

james@dirac:~$ sudo hcitool scan
Scanning ...
    00:1A:8A:86:6D:CE    SGH-E250</code>

Find out about a device:

james@dirac:~$ sudo hciconfig -a
hci0:   Type: USB
    BD Address: 00:0A:3A:7A:E6:53 ACL MTU: 1017:8 SCO MTU: 64:0
    UP RUNNING PSCAN
    RX bytes:10237 acl:210 sco:0 events:217 errors:0
    TX bytes:4609 acl:210 sco:0 commands:71 errors:0
    Features: 0xff 0xff 0x8d 0xfe 0x9b 0xf9 0x00 0x80
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
    Link policy: RSWITCH HOLD SNIFF PARK
    Link mode: SLAVE ACCEPT
    Name: 'dirac-0'
    Class: 0x3e0100
    Service Classes: Networking, Rendering, Capturing, Object Transfer, Audio
    Device Class: Computer, Uncategorized
    HCI Ver: 2.0 (0x3) HCI Rev: 0x4102 LMP Ver: 2.0 (0x3) LMP Subver: 0x430e
Manufacturer: Broadcom Corporation (15)

Ping a device:

james@dirac:~$ sudo l2ping 00:1A:8A:86:6D:CE
Ping: 00:1A:8A:86:6D:CE from 00:0A:3A:7A:E6:53 (data size 44) ...
44 bytes from 00:1A:8A:86:6D:CE id 0 time 37.50ms
44 bytes from 00:1A:8A:86:6D:CE id 1 time 75.61ms
44 bytes from 00:1A:8A:86:6D:CE id 2 time 66.62ms
3 sent, 3 received, 0% loss</code>

Connecting for Dial Up Networking

Once all that is working nicely it is time to search for a device with Dial Up Networking:

james@dirac:~$ sdptool search DUN
Inquiring ...
Searching for DUN on 00:1A:8A:86:6D:CE ...
Service Name: Dial-up Networking
Service RecHandle: 0x10002
Service Class ID List:
  "Dialup Networking" (0x1103)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 3
Profile Descriptor List:
  "Dialup Networking" (0x1103)
    Version: 0x0100</code>

As you can see the device 00:1A:8A:86:6D:CE (which you know is an SGH-E250 phone from the sudo hcitool scan command you ran above) supports RFCOMM and on channel 3. It is important to make a note of the channel because you'll need it for the next command:

james@dirac:~$ sudo rfcomm bind 0 00:1A:8A:86:6D:CE 3
james@dirac:~$ sudo rfcomm show 0
rfcomm0: 00:1A:8A:86:6D:CE channel 3 clean

This tells you that you now have your Bluetooth phone connected on /dev/rfcomm0. If you leave it too long after binding before trying the show command you might see this:

james@dirac:~$ sudo rfcomm show 0
rfcomm0: 03:00:00:00:00:00 channel 1 closed</code>

In which case release and then bind again:

james@dirac:~$ sudo rfcomm release 0
james@dirac:~$ sudo rfcomm bind 0 00:1A:8A:86:6D:CE 3
james@dirac:~$ sudo rfcomm show 0
rfcomm0: 00:1A:8A:86:6D:CE channel 3 clean

Now you have a Bluetooth connection you are ready to set up your GPRS connection.

Testing Your Connection Settings

If you already know all the settings you need to use you can skip this bit and go straight to setting up the GPRS connection via PPP. Installing and playing with minicom isn't strictly necessary, it will just help you track down problems more quickly.

First you'll need a tool such as minicom:

james@dirac:~$ sudo apt-get install minicom

You need to add your user to the dialout group to use minicom as a non-root user.

Then create a configuration file:

sudo minicom -s

You get shown an options screen. In the Serial port setup screen choose A to make the appropriate device:

A -    Serial Device      : /dev/rfcomm0

Then choose E to change the Bps/Par/Bits to 57600 8N1. You do this by pressing H and Q. You can try 115200 later if 57600 works. Press <Enter> to go back to the main menu and choose Save setup as.. to save the settings as bluetooth.dfl before exiting.

To use your new configuration type:

minicom bluetooth.dfl

If you have any problems it is worth running sudo rfcomm show 0 again to check you still have a clean connection. If not, release the connection and bind to the channel again first.

When you run this command for the first time the phone will ask you something like: "DUN connect with dirac-0". Choose yes.

Once you are connected you'll see a screen like the one below. Type the following to initialise GPRS:

at
ate1
at+cgdcont=1,"IP","orangeinternet","",0,0
atdt*99#</code>

After each line you should see an OK message except after the last line when you should see a CONNECT as shown below.

If you were able to connect successfully, great. If not you might need to search on the internet for the correct settings for your provider and phone. In particular the atdt*99# line might need changing.

Setting up PPP

If you want your phone to bind automatically you can edit your /etc/bluetooth/rfcomm.conf so it looks like this:

#
# RFCOMM configuration file.
#
rfcomm0 {
    bind yes;
    device  00:1A:8A:86:6D:CE;
    channel 3;
    comment "Bluetooth PPP Connection";
}

Obviously you'll need to enter the correct channel and device for your phone based on the output you received earlier from running sdptool search DUN. You'll then need to restart Bluetooth with:

/etc/init.d/bluetooth restart

I chose not to add the lines to rfcomm.conf because I want to always manually connect my phone to avoid the chance of running up any unwanted bills (of course just binding to the device doesn't mean I am connected to the internet but I'm just being paranoid).

If you want to bind manually you should do so now:

james@dirac:~$ sudo rfcomm bind 0 00:1A:8A:86:6D:CE 3
james@dirac:~$ sudo rfcomm show 0
rfcomm0: 00:1A:8A:86:6D:CE channel 3 clean

Next create the file /etc/ppp/peers/bluetooth and add the following content. I had to play around with this for a long time so if it doesn't work for you, take a look at other examples for your phone/provider and mix and match commands from different configurations until it does. This example is based on the one from here.

# File:
# gprs
#
# Description:
# Serial cable, IrDA, Bluetooth and USB pppd options for GPRS phones.

# Keep pppd attached to the terminal:
# Comment this to get daemon mode pppd
nodetach

# Debug info from pppd:
# Comment this off, if you don't need more info
debug

# Show password in debug messages
show-password

# Connect script:
connect '/usr/sbin/chat -v -f /etc/chatscripts/bluetooth'

# Disconnect script:
# AT commands used to 'hangup' the GPRS connection.
disconnect /etc/ppp/peers/gprs-disconnect-chat

# Serial device to which the GPRS phone is connected:
# /dev/ttyS0 for serial port (COM1 in Windows),
# /dev/ircomm0 for IrDA,
# /dev/ttyUB0 for Bluetooth (Bluez with rfcomm running) and
# /dev/ttyUSB0 for USB
#/dev/ttyS0     # serial port one
#/dev/ttyS1     # serial port two
#/dev/ircomm0   # IrDA serial port one
/dev/rfcomm0    # Bluetooth serial port one
#/dev/ttyUSB0   # USB serial device, for example Orange SPV

# Serial port line speed
115200  # fast enough
#57600  # perhaps usefull with IrDA

# Hardware flow control:
# Use hardware flow control with cable, Bluetooth and USB but not with IrDA.
crtscts  # serial cable, Bluetooth and USB
#nocrtscts # IrDA

# Ignore carrier detect signal from the modem:
local

# IP addresses:
# - accept peers idea of our local address and set address peer as 10.0.0.1
# (any address would do, since IPCP gives 0.0.0.0 to it)
# - if you use the 10. network at home or something and pppd rejects it,
# change the address to something else
:10.0.0.1

# pppd must not propose any IP address to the peer!
noipdefault

# Accept peers idea of our local address
ipcp-accept-local

# Add the ppp interface as default route to the IP routing table
defaultroute
# DNS servers from the phone:
# some phones support this, some don't.
usepeerdns

# ppp compression:
# ppp compression may be used between the phone and the pppd, but the
# serial connection is usually not the bottleneck in GPRS, so the
# compression is useless (and with some phones need to disabled before
# the LCP negotiations succeed).

#novj
#nobsdcomp
#novjccomp
#nopcomp
#noaccomp

# The phone is not required to authenticate:
noauth

# Username and password:
# If username and password are required by the APN, put here the username
# and put the username-password combination to the secrets file:
# /etc/ppp/pap-secrets for PAP and /etc/ppp/chap-secrets for CHAP
# authentication. See pppd man pages for details.
# Example, Radiolinja operator pap-secrets:
# "rlnet"         *       "internet"    *
#user "rlnet"
#user "Orange"

# Asyncmap:
# some phones may require this option.
#asyncmap 0xa0000

# No magic:
# some phones may require this option.
nomagic

# Require PAP authentication:
# some phones may require this option.
#require-pap

Now you'll need to create the /etc/chatscripts/bluetooth referenced in the file above:

TIMEOUT 35
ECHO    ON
ABORT   '\nBUSY\r'
ABORT   '\nERROR\r'
ABORT   '\nNO ANSWER\r'
ABORT   '\nNO CARRIER\r'
ABORT   '\nNO DIALTONE\r'
ABORT   '\nRINGING\r\n\r\nRINGING\r'
''      \rAT
OK     'AT+CGDCONT=1,"IP","orangeinternet","",0,0'
OK      'ATD*99#'
CONNECT ""

and also the /etc/ppp/peers/gprs-disconnect-chat script:

#!/bin/sh
#
# File:
# gprs-disconnect-chat
#
# send break
exec /usr/sbin/chat -V -s -S    \
ABORT           "BUSY"          \
ABORT           "ERROR"         \
ABORT           "NO DIALTONE"   \
SAY             "\nSending break to the modem\n"        \
""              "\K"            \
""              "+++ATH"        \
SAY             "\nPDP context detached\n"</code>

You'll need to make this one executable otherwise it won't be able to be executed when you disconnect (not that it seems to be a huge problem).

Finally, update /etc/resolve.conf to use the Orange nameservers:

nameserver 193.35.133.10
nameserver 193.35.134.10

That's pretty much it. Now bring down any other interfaces you have connected such as wirless or LAN connections so that when you connect over GPRS your routing tables will be set up correctly:

sudo ifdown eth0

Now check you are bound, cross your fingers and connect:

james@dirac:~$ sudo rfcomm bind 0 00:1A:8A:86:6D:CE 3
james@dirac:~$ sudo rfcomm show 0
rfcomm0: 00:1A:8A:86:6D:CE channel 3 clean
james@dirac:~$ sudo pon bluetooth</code>

The final line is what does the connecting. A message should pop up on your phone asking for permission to start DUN. Choose yes and a load of messages should fly by and you should find yourself connected!

james@dirac:~$ sudo pon bluetooth
AT
OK
AT+CGDCONT=1,"IP","orangeinternet","",0,0
OK
ATD*99#
CONNECT
Serial connection established.
using channel 3
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x1 <asyncmap 0xa0000> <auth pap>]
sent [LCP ConfAck id=0x1 <asyncmap 0xa0000> <auth pap>]
rcvd [LCP ConfRej id=0x1 <pcomp> <accomp>]
sent [LCP ConfReq id=0x2 <asyncmap 0x0>]
rcvd [LCP ConfAck id=0x2 <asyncmap 0x0>]
sent [LCP EchoReq id=0x0 magic=0x0]
sent [PAP AuthReq id=0x1 user="dirac" password=""]
rcvd [LCP EchoRep id=0x0 magic=0x0]
rcvd [PAP AuthAck id=0x1 "Login OK"]
Remote message: Login OK
PAP authentication succeeded
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> < ms-dns3 0.0.0.0>]
rcvd [LCP ProtRej id=0x2 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfReq id=0x1 <addr 194.33.25.158>]
sent [IPCP ConfNak id=0x1 <addr 10.0.0.1>]
rcvd [IPCP ConfNak id=0x2 <addr 10.34.152.3> <ms-dns1 193.35.133.10> <ms-dns3 19 3.35.134.10>]
sent [IPCP ConfReq id=0x3 <addr 10.34.152.3> <ms-dns1 193.35.133.10> <ms-dns3 19 3.35.134.10>]
rcvd [IPCP ConfReq id=0x2 <addr 194.33.25.158>]
sent [IPCP ConfNak id=0x2 <addr 10.0.0.1>]
rcvd [IPCP ConfAck id=0x3 <addr 10.34.152.3> <ms-dns1 193.35.133.10> <ms-dns3 19 3.35.134.10>]
rcvd [IPCP ConfReq id=0x3 <addr 194.33.25.158>]
sent [IPCP ConfNak id=0x3 <addr 10.0.0.1>]
rcvd [IPCP ConfReq id=0x4 <addr 194.33.25.158>]
sent [IPCP ConfNak id=0x4 <addr 10.0.0.1>]
rcvd [IPCP ConfReq id=0x5 <addr 194.33.25.158>]
sent [IPCP ConfNak id=0x5 <addr 10.0.0.1>]
rcvd [IPCP ConfReq id=0x6 <addr 194.33.25.158>]
sent [IPCP ConfRej id=0x6 <addr 194.33.25.158>]
rcvd [IPCP ConfReq id=0x7 <addrs 194.33.25.158 10.34.152.3>]
sent [IPCP ConfRej id=0x7 <addrs 194.33.25.158 10.34.152.3>]
rcvd [IPCP ConfReq id=0x8]
sent [IPCP ConfAck id=0x8]
Cannot determine ethernet address for proxy ARP
local  IP address 10.34.152.3
remote IP address 10.0.0.1
primary   DNS address 193.35.133.10
secondary DNS address 193.35.134.10
Script /etc/ppp/ip-up started (pid 7253)
Script /etc/ppp/ip-up finished (pid 7253), status = 0x0</code>

Disconnect by pressing Ctrl+C or as a last resort, turning off Bluetooth on your phone.

Terminating on signal 2
Connect time 2.2 minutes.
Sent 29700 bytes, received 2104 bytes.
Script /etc/ppp/ip-down started (pid 7324)
sent [LCP TermReq id=0x3 "User request"]
Script /etc/ppp/ip-down finished (pid 7324), status = 0x0
rcvd [LCP TermAck id=0x3]
Connection terminated.
Garbled time

Sending break to the modem

PDP context detached
Serial link disconnected.
james@dirac:~$

You can then connect again if you want to with:

james@dirac:~$ sudo pon bluetooth

If things don't work out first time my advice is to either try to work out properly what all the options mean in the PPP configuration or just use a bit of trial and error from other examples which have been written for your mobile provider, phone model or operating system. By the way, I'm using GPRS to write and save this blog entry now so it does work!

Update If you don't set the nameservers in /etc/resolve.conf they get set for you automatically and if you comment out the :10.0.0.1 line in the /etc/ppp/peers/bluetooth line it still all works.

(view source)

James Gardner: Home > Blog > 2007 > Orange GPRS via Samsung Bluetooth...