Bluetooth GPRS Howto: Difference between revisions

From ArchWiki
mNo edit summary
(archive page)
 
(31 intermediate revisions by 21 users not shown)
Line 1: Line 1:
[[Category:Other hardware (English)]]
#redirect [[ArchWiki:Archive]]
 
[[Category:Archive]]
This Howto will describe, how to set up a GPRS Internet connection using bluetooth device and compatible mobile phone.
 
==Requirements==
# Linux compatible bluetooth device
# Bluetooth enabled mobile phone - I'm using Nokia N70
 
==Instructions==
<ol>
<li>Install bluez-utils, bluez-libs and dbus (install also ppp if you havent): <pre>pacman -S bluez-utils bluez-libs dbus</pre></li>
<li>Start dbus and bluetooth service: <pre>/etc/rc.d/dbus start
/etc/rc.d/bluetooth start</pre></li>
<li>Scan for nearby bluetooth devices: <pre>hcitool scan
Scanning ...
        00:19:79:89:13:8E      Penpen N70</pre>
Now, mark that above address, it's the bluetooth hardware address of your mobile phone (provided that the name in the right matches what you have written in the phone).</li>
<li>Scan, which channel is used for Dial-Up Networking: <pre>sdptool search DUN
Inquiring ...
Searching for DUN on 00:19:79:89:13:8E ...
Service Name: Dial-Up Networking
Service RecHandle: 0x10007
Service Class ID List:
  "Dialup Networking" (0x1103)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 3
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Dialup Networking" (0x1103)
    Version: 0x0100
</pre>Now check the line beginning with "Channel:" - it contains the channel which is used for Dial-Up Network and it is <strong>not necessarily</strong> 1 and so is the case with my Nokia N70; my phone uses channel 3. Check also that you are reading the right results; the bluetooth hardware address must match your phone's.</li>
<li>Next, edit /etc/bluetooth/hcid.conf . Set the following in options section: <pre>autoinit yes;
security auto;</pre> Editing the same file, comment out passkey, as it is not used actually. Also, in the device section change
the line beginning with name to: <pre>name "BlueZ (%h)";</pre></li>
<li>Now edit /etc/rfcomm.conf , first uncomment the rfcomm0 device section. Then add/change the lines as this (if necessary): <pre>bind yes;
device 00:19:79:89:13:8E;
channel 3;
comment "GPRS dialup";</pre>Of course, you should use your device address and the appropriate channel.</li>
<li>Edit the bluetooth script in /etc/rc.d/bluetooth to make the rfcomm start when bluetooth system is started: <pre>RFCOMM_ENABLE="true"</pre></li>
<li>Restart the bluetooth service: <pre>/etc/rc.d/bluetooth restart</pre></li>
<li>Look, whether the bluetooth device is bound to the phone. ll should look like this: <pre>ll /dev/rfcomm0
crw-rw---- 1 root tty 216, 0 2007-08-10 21:32 /dev/rfcomm0</pre></li>
<li>Now comes the interesting part. You see, there must be an agreed password for connecting to the phone's modem. And this password is set up in an awkward way. First decide a password. Then open another root console, type there (subsitute your phone's hardware address and password accordingly) <pre>passkey-agent 8922 00:19:79:89:13:8E</pre> , but don't press enter yet. On another root window, issue
<pre>cat /dev/rfcomm0</pre> and immediately after that execute the typed passkey-agent command in other window. Situation is like this http://asuka.fi/u/jpaalija/tmp/catting_passkey-agent_ready.png The phone should now show something like this: http://asuka.fi/u/jpaalija/tmp/passcode_dialog.jpg . Quickly, enter the passcode and press "Ok". If the passkey-agent prints something like <pre>Passkey request for device 00:19:79:89:13:8E
Passkey service has been released</pre> you have no need to hurry anymore as you are almost set.
Next, go to Menu->Connectivity->Bluetooth, select right for paired devices, select Options->Set as authorized, confirm and you are done!</li>
<li>Edit the bottom of /etc/ppp/ip-up as following: <pre>echo -e "#generated by ip-up\nsearch local\nnameserver $DNS1\nnameserver $DNS2" > /etc/resolv.conf
chmod a+r /etc/resolv.conf</pre>This change is used to set correct DNS settings after connection.</li>
<li>Now you need scripts to actually use the phone's modem and call your ISP. My ISP is the Finnish saunalahti, mainly because of it's predefined fee for unlimited data access. You must substitute saunalahti for your ISP accordingly through the rest of the document. First we edit the modem setup script for my isp. I'm using script named /etc/ppp/peers/saunalahti and having the following content: <pre>show-password
noauth
/dev/rfcomm0
115200
connect /etc/ppp/peers/saunalahti-connect
disconnect /etc/ppp/peers/saunalahti-disconnect
defaultroute
#replacedefaultroute
noipdefault
#nodetach
usepeerdns
crtscts
local
ipcp-accept-local
#lcp-echo-interval 0
maxfail 10
lcp-echo-failure 0
lcp-echo-interval 0
#lcp-max-configure 0
#lcp-max-failure 10000
#lcp-max-terminate 0
#lcp-restart 30000
novj
nobsdcomp
novjccomp
nopcomp
noaccomp
linkname saunalahti
mtu 1500
mru 1500</pre> Some remarks: You should possibly first uncomment the nodetach-option, so you can track, whether the call succeeds. Without the option you just get no confirmation. The lines starting with "connect" and "disconnect" are locations for connect and disconnect chat scripts. Chat scripts are used to "talk" with the modem. Lets take a look at them next. </li>
<li>Now, we edit the connect script. Mine is as the following: <pre>#!/bin/sh
exec 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                              \
        SAY            "Press CTRL-C to close the connection at any stage!"    \
        SAY            "\ndefining PDP context...\n"  \
        OK              ATH                            \
        OK              ATE1                            \
        OK              'AT+CGDCONT=1,"IP","internet.saunalahti","",0,0'        \
        OK              ATD*99#                        \
        TIMEOUT        22                              \
        SAY            "\nwaiting for connect...\n"    \
        CONNECT        ""                              \
        SAY            "\nConnected." \
        SAY            "\nIf the following ppp negotiations fail,\n"  \
        SAY            "try restarting the phone.\n"</pre>Also some remarks about these: In the place of internet.saunalahti you should have your mobile operators access point name. That can be checked from Settings->Connection->Access points . Hilight the Internet access point and select edit. Go down to section "Access point name". There you have it. One more thing. The modem command "ATD*99#"'s number "*99#" is a special number (at least in Nokia phones) which is used to "call to Internet access point". Pretty clever I'd say; no fiddling around with actual numbers, let the phone handle everything behind the scenes.</li>
<li>Edit the disconnect script (mine's is in /etc/ppp/peers/saunalahti-disconnect). You should have something like this: <pre>#!/bin/sh
exec /usr/sbin/chat -V -s -S    \
ABORT          "BUSY"          \
ABORT          "ERROR"        \
ABORT          "NO DIALTONE"  \
SAY            "\nSending break to the modem\n"        \
""              "\K"            \
""              "\K"            \
""              "\K"            \
""              "+++ATH"        \
""              "+++ATH"        \
""              "+++ATH"        \
SAY            "\nPDP context detached\n"</pre></li>
<li>Ok, you have completely set up bluetooth + gprs connection. Yay! Next thing to do is to test it. If you let the "nodetach" option uncommented in section 12, running (again, substitute yourisp for, well your ISP :) <pre>pon yourisp</pre> should return something like this: <pre>Press CTRL-C to close the connection at any stage!
defining PDP context...
rAT
OK
ATH
OK
ATE1
OK
AT+CGDCONT=1,"IP","internet.saunalahti","",0,0
OK
waiting for connect...
 
ATD*99#
CONNECT
Connected.
If the following ppp negotiations fail,
try restarting the phone.
 
Serial connection established.
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
kernel does not support PPP filtering
Cannot determine ethernet address for proxy ARP
local  IP address 85.77.231.188
remote IP address 10.6.6.6
primary  DNS address 195.197.54.100
secondary DNS address 195.74.0.47</pre> If the output is something similiar, you have a working connection . If this is the case, you can press ctrl-c to abort the connection and uncomment the "nodetach" option from section 12. Later when you want connection, you can just run <pre>pon yourisp</pre> and when disconnecting <pre>poff yourisp</pre>.
<li>Add "dbus bluetooth" to the DAEMONS section in /etc/rc.conf so you can connect more easily after reboot.</li>
<li>All done, enjoy!</li>
</ol>

Latest revision as of 10:12, 9 January 2018

Redirect to: