DSL Tips and Tricks :: How to make a BT - mobile phone GPRS connection



This is part 4 of the DSL Bluetooth how-to. In order to proceed from here, you will need to have Bluetooth up and running on your DSL machine and be able to "pair" with a Bluetooth mobile phone as described in part 1 - "How to start Bluetooth & Pair with a remote device". You will also need to know how to discover which sdp channel your phone uses for dialup networking and bind this to a Bluetooth com port as described in part 2 - "How to dialup using a mobile phone via Bluetooth".

This might seem obvious, but you need to have GPRS enabled by your telecomms provider for your mobile phone and you will need to know if any special parameters are required to establish the connection. I believe most providers rely on your phone's SIM card for identification, so no addtional login or password is typically required.

I have not been able to make wvdial work with GPRS - it looks like it's working, data comes and goes from the phone but does not make it back to DSL. The problem might be that "apt-get install wvdial" over-writes the symlink from /etc/ppp to /opt/ppp in DSL, but anyway, after much Googling I found a different solution (mostly from http://home.comcast.net/~spearcd/gprsdun.html). Note I have little idea what several of these settings do - if anybody would like to suggest corrections, please feel free.

First we need to create 3 files, as root, in /opt/ppp/peers:

# File name: gprs-connect-chat
#
'' AT
# Replace "mnet" with the name of your GPRS service
OK AT+CGDCONT=1,"IP","mnet"
# This tells the phone to use the GPRS entry created above
OK ATD*99***1#
# If you have only one entry *99# will probably work.
CONNECT ''
# EOF

# File gprs-disconnect-chat
#
# This is called at <ctrl-c>, I have little idea what it does
exec /usr/sbin/chat -V -s -S                             \
ABORT                  "BUSY"                 \
ABORT                  "ERROR"                               \
ABORT                  "NO DIALTONE"                \
SAY                        "n\Sending break to the modem\n"                  \
""                            "\K"                                        \
""                            "\K"                                        \
""                            "\K"                                        \
""                            "+++ATH"                            \
""                            "+++ATH"                            \
""                            "+++ATH"                            \
SAY                "\nPDP context detached\n"
# EOF

# Filename: gprs
#
# Most GPRS-enabled wireless devices don't reply to LCP echo's
lcp-echo-failure 0
lcp-echo-interval 0
nodetach
# Connect script:
connect "/usr/sbin/chat -v -t3 -f /etc/ppp/peers/gprs-connect-chat"
# Disconnect script:
disconnect /etc/ppp/peers/gprs-disconnect-chat
# Connection method used to wireless device:
/dev/rfcomm0
115200    # Fast enough for GPRS and EDGE handsets.
# Hardware flow control:
crtscts
# Ignore carrier detect signal from the modem:
local
# IP addresses, etc:
:10.0.0.1
noipdefault
ipcp-accept-local
defaultroute
usepeerdns
# specifically addressed to the serial connection, not the GPRS connection)
novj
nobsdcomp
novjccomp
nopcomp
noaccomp
# This disables authentication
user "username"
persist
maxfail 99
# EOF

Once these files are saved (and added to .filetool.lst), we can get started:

# hcitool scan
Scanning ...
       00:0A:D9:E8:4A:65       .P900
# hcitool cc 00:0A:D9:E8:4A:65
# hcitool auth 00:0A:D9:E8:4A:65
# rfcomm bind 0 00:0A:D9:E8:4A:65 7
# mknod -m 666 /dev/rfcomm0 c 216 0
# sdpd
# sdptool add --channel=7 DUN
Dial-Up Networking service registered

Then all that remains is to dial. Although there are several error messages, it works:

# /usr/sbin/pppd call gprs
Serial connection established.
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
Cannot determine ethernet address for proxy ARP
local  IP address 217.164.89.221
remote IP address 10.0.0.1
primary   DNS address 195.229.241.222
secondary DNS address 213.42.20.20

The first terminal window will remain blocked whilst the connection is made so open a second terminal window to test the connection:

# ping damnsmalllinux.org
PING damnsmalllinux.org (65.254.46.177): 56 data bytes
64 bytes from 65.254.46.177: icmp_seq=0 ttl=49 time=1128.3 ms
64 bytes from 65.254.46.177: icmp_seq=1 ttl=49 time=1042.2 ms
64 bytes from 65.254.46.177: icmp_seq=2 ttl=49 time=902.9 ms
<ctrl-c>
--- damnsmalllinux.org ping statistics ---
4 packets transmitted, 3 packets received, 25% packet loss
round-trip min/avg/max = 902.9/1024.4/1128.3 ms

Return to the first terminal window to close the connection:

<ctrl-c>
Terminating on signal 2.
Connection terminated.
Connect time 7.3 minutes.
Sent 21380 bytes, received 248664 bytes.
sh: line 1: /etc/ppp/peers/gprs-disconnect-chat: Permission denied
disconnect script failed

I tried http://promos.mcafee.com/speedometer/test_0150.asp with Firefox which rated the connection at 45Kbit/s - this would certainly depend on the strength of the telecomms network signal but it also depends on how far the phone is from your DSL machine. Mine will still connect when the phone is 6-7 metres away but it is much slower.

When I first started with DSL, I would never have believed Bluetooth would work, let alone a GPRS connection, which shows the power of this software - I didn't see my phone bill yet though  :)

For anybody that might be interested, here are two simpler files that can be used for a bluetooth-gprs connection. In addition, the prompt returns in the terminal window that initiates the connection thus avoiding the need to open a second terminal window.

# cat /opt/ppp/peers/gprs_bt
# This optionfile was generated by pppconfig 2.1.
#
# /opt/peers/gprs_bt
#
defaultroute
noauth
connect "/usr/sbin/chat -v -f /opt/ppp/chatscripts/gprs_bt_chat"
debug
/dev/rfcomm0
115200  
updetach
#ipcp-accept-local
#ipcp-accept-remote
usepeerdns
# EOF

# cat /opt/ppp/chatscripts/gprs_bt_chat
# This chatfile was generated by pppconfig 2.1.
# Please do not delete any of the comments.  Pppconfig needs them.
#
# ispauth chat
# abortstring
ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT DELAYED
# modeminit
'' ATZ

#We add gprs specific stuff.
OK 'AT+CGDCONT=1,"IP","mnet"'

# ispnumber
OK-AT-OK "ATD*99***1#"
# ispconnect
CONNECT ''
# prelogin

# ispname
# isppassword
# postlogin
# end of pppconfig stuff

After saving the two files, open a terminal window and type the following command:

# pppd call gprs_bt
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x2d59b97> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <pcomp> <accomp>]
sent [LCP ConfAck id=0x1 <asyncmap 0x0> <pcomp> <accomp>]
rcvd [LCP ConfRej id=0x1 <magic 0x2d59b97>]
sent [LCP ConfReq id=0x2 <asyncmap 0x0> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x2 <asyncmap 0x0> <pcomp> <accomp>]
sent [LCP EchoReq id=0x0 magic=0x0]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <compress VJ 0f 01> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
rcvd [LCP CodeRej id=0x3 09 00 00 08 00 00 00 00]
LCP: Rcvd Code-Reject for code 9, id 0
rcvd [LCP ProtRej id=0x4 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
rcvd [IPCP ConfReq id=0x1 <addr 217.164.90.251>]
sent [IPCP ConfAck id=0x1 <addr 217.164.90.251>]
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>]
rcvd [IPCP ConfNak id=0x2 <addr 217.164.90.250> <ms-dns1 195.229.241.222> <ms-dns3 213.42.20.20>]
sent [IPCP ConfReq id=0x3 <addr 217.164.90.250> <ms-dns1 195.229.241.222> <ms-dns3 213.42.20.20>]
rcvd [IPCP ConfAck id=0x3 <addr 217.164.90.250> <ms-dns1 195.229.241.222> <ms-dns3 213.42.20.20>]
Cannot determine ethernet address for proxy ARP
local  IP address 217.164.90.250
remote IP address 217.164.90.251
primary   DNS address 195.229.241.222
secondary DNS address 213.42.20.20

# ping www.damnsmalllinux.org
PING www.damnsmalllinux.org (65.254.46.177): 56 data bytes
64 bytes from 65.254.46.177: icmp_seq=0 ttl=50 time=1040.6 ms
64 bytes from 65.254.46.177: icmp_seq=1 ttl=50 time=982.9 ms
64 bytes from 65.254.46.177: icmp_seq=2 ttl=49 time=1026.7 ms
64 bytes from 65.254.46.177: icmp_seq=3 ttl=50 time=970.6 ms
<ctrl-c>
--- www.damnsmalllinux.org ping statistics ---
5 packets transmitted, 4 packets received, 20% packet loss
round-trip min/avg/max = 970.6/1005.2/1040.6 ms

To terminate the connection, type the following:

# poff

If anybody has any suggestions to improve the scripts, please feel free to add to this thead.

Hallo Juanito,

Thanks a lot for your Howtos, now I can aprofite my laptop when I travel with the bluetooth and my mobilphone.

With your notes and a little of work I have made a very easy connection. I put in the desktop 3 icons for the connection:
one icon "Bluetooth1"
second icon "Bluetup2"
third icon "BluetGPRS"

the first "Bluetooth1" links with /opt/mybtinsmod.sh:
----------
#!/bin/bash
sudo chown -R root.root /lib/modules/2.4.26/kernel/drivers/bluetooth/
sudo chown -R root.root /lib/modules/2.4.26/kernel/net/bluetooth/
sudo insmod bluez
sudo insmod hci_uart
sudo insmod sco
sudo insmod l2cap
sudo insmod rfcomm
-------------

the second "Bluetup2" links to the file /opt/mybtup.sh:
-------------
#!/bin/bash
cp /opt/myblue/hcid.conf /etc/bluetooth/hcid.conf
cp /opt/myblue/pin /etc/bluetooth/pin
sudo hcid
sleep 5 ; sudo hciattach -s 57600 /dev/ttyS17 bcsp
sudo hciconfig hci0 up
--------------

and the third "BluetGPRS" links to the file /opt/mybtgprs.sh:
--------------
#!/bin/bash
sudo hcid restart
sudo hcitool scan
sudo hcitool cc 00:0D:41:0C:D2:1A
sudo hcitool auth 00:0D:41:0C:D2:1A
sudo rfcomm bind 0 00:0D:41:0C:D2:1A 2
sudo rfcomm show
sudo mknod -m 666 /dev/rfcomm0 c 216 0
sudo sdpd
sudo sdptool add --channel=2 DUN
sudo /usr/sbin/pppd call gprs
--------------

the gprs file:
---------------
#File name: gprs
#
#Most GPRS-enabled wireless devices don't reply to LCP echo's
lcp-echo-failure 0
lcp-echo-interval 0
nodetach
#Connect script:
connect "/usr/sbin/chat -v -t3 -f /etc/ppp/peers/gprs-chat"
#Disconnect script:
#disconnect /etc/ppp/peers/gprs-disconnect-chat
#Connection method used to wireless device:
/dev/rfcomm0 115200
# Fast enough for GPRS and EDGE handsets.
# Hardware flow control:
crtscts
# Ignore carrier detect signal from the modem:
local
# IP addresses, etc:
:10.0.0.1
noipdefault
ipcp-accept-local
noauth
defaultroute
usepeerdns
# specifically addressed to the serial connection, not the GPRS connection)
novj
nobsdcomp
novjccomp
nopcomp
noaccomp
# This disables authentication
user "username"
persist
maxfail 99
# EOF
----------------------

and the gprs-chat file:
----------------
#File name: gprs-chat
#
TIMEOUT           5
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
TIMEOUT           12
OK                ATE1
OK                'AT+cgdcont=1,"IP","internet"'
OK-AT-OK          ATD*99***1#
CONNECT ""
#EOF
--------------

The outup is:
---------------
Serial connection established
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Cannot determine ethernet address for proxy ARP
local IP address 83.231.14.175
remote IP address 10.0.0.1
primary    DNS address 213.143.33.8
secondary  DNS address 213.143.32.20
-------------

after I read my e-mail, I close my bt in mobilphone:
------------
Modem hangup
Connection terminated.
Connect time 5.2 minutes.
Sent 2249 bytes, recived 3326 bytes.
-------------

and I finish with ctrl-C


And now with 3 clics of the mouse I have my GPRS connection enabled
between the laptop and the mobilphone

Hope it helps to someone!!

Quote (Onyarian @ Mar. 03 2007,11:45)
sudo chown -R root.root /lib/modules/2.4.26/kernel/drivers/bluetooth/
sudo chown -R root.root /lib/modules/2.4.26/kernel/net/bluetooth/

I guess from these two lines that I managed to put the Bluetooth modules in the unc owned by DSL instead of root...

I'll try to get around to posting a corrected version in a week or so.


original here.