TODO forever when life runs faster than you can afford

11Feb/100

Using your bluetooth enabled phone with Sakis3G

Notice: This post provides links and instructions referring to an old version of Sakis3G script. Page is still available only for historical reasons.
Please visit www.sakis3g.org for latest Sakis3G script version.

Αυτό το άρθρο υπάρχει και στα Ελληνικά.

Sakis3G script is actually able to use any 3G modem, and not just USB ones. Good. Many of our bluetooth enabled cellular phones also offer their modem capabilities over bluetooth. It would be nice providing 3G internet on your laptop on the go, while keeping your phone hidden on your pocket.

Check video below (see it on YouTube) to motivate yourself going through this guide.

Contents

  1. Become root
  2. Install dependencies
  3. Check phone capabilities
  4. Setup bluetooth connection
  5. Install Sakis3G
  6. Test
  7. Uninstall

 

Become root

As with most setup procedures, you need a root terminal for initially setting up things. For sudo-based distributions (like Ubuntu), you need to "sudo bash". If not using a sudo-based distribution (like Debian), you need to "su -".

Sudo-based
$ sudo bash
Password:
#

Normal
$ su -
Password:
#

(Back to contents)
 

Install dependencies

Required packages, illustrated below, refer to Debian package names. Other distribution users have to work around package names to find appropriate ones for their distribution. If you are running a modern desktop-enabled distribution, it is likely that required packages are already installed.

  • We need "rfcomm", "hcitool" and "sdptool" to setup and establish connection with phone. They are all provided by bluez-utils package.

    # apt-get install bluez-utils

     
  • If your bluetooth adapter is based on Broadcom BCM203x chipset, you need to enable non-free repository and also install bluez-firmware package.

    # apt-get install bluez-firmware

     
  • You also need to install "chat" program for contacting modem residing on phone. On Debian systems, "chat" is provided, along with "pppd", from ppp:

    # apt-get install ppp

(Back to contents)
 

Check phone capabilities

This one is "hardest" step. Some of us will be disappointed to find out their mobile phone does not offer its modem capabilities over bluetooth. You may still be able to use it as a modem through direct USB connection (some phones provide menu options to affect cable USB connection, switching from mass-storage to modem), but this type of connection is not handled by this guide.

Have bluetooth in your cellular phone switched on, and make sure device is discoverable. Use your root terminal and type following command to find out your phones bluetooth address:

# hcitool scan
Scanning ...
       00:25:47:59:00:00       Myphone
#

Now that you know your mobile phone's bluetooth addess (mine is 00:25:47:59:00:00, you should exchange all occurrences with your own bluetooth address), you can check for its capabilities:

# sdptool browse 00:25:47:59:00:00

This will trigger list of available services on your phone to appear. Depending on phone model, this list can be short or be a really long list (long list, indicates a feature-rich phone). You should check output to discover one (or more) of services with the following class IDs:

  1. Dialup networking
  2. Serial Port

If more than one of those services appear, try those candidates in the order they are listed above (and not in the order presented by sdptool output). List above is sorted in the order you should evaluate them. You then have to repeat steps below, until you identify best one candidate to use.

This one is the correct service for my phone:

Service Name: Dial-up networking
Service RecHandle: 0x10003
Service Class ID List:
  "Dialup Networking" (0x1103)
  "Generic Networking" (0x1201)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Dialup Networking" (0x1103)
    Version: 0x0100

Note down RFCOMM channel this service is provided from (mine resides on channel #1). Now call "rfcomm" utility, without arguments, to find out next available device (in case other devices already binded):

# rfcomm
rfcomm0: 00:1C:88:12:00:00 channel 1 clean
rfcomm1: 00:12:6F:02:00:00 channel 1 clean
#

On my case, next available device is "rfcomm2". If "rfcomm" returned nothing for you, your next available device is obviously "rfcomm0". Good. We will now try to bind that device (make sure you change with your own bluetooth address and RFCOMM channel):

Syntax is: rfcomm bind <next available number> <bluetooth address> <rfcomm channel>
# rfcomm bind 2 00:25:47:59:00:00 1
# rfcomm
rfcomm0: 00:1C:88:12:00:00 channel 1 clean
rfcomm1: 00:12:6F:02:00:00 channel 1 clean
rfcomm2: 00:25:47:59:00:00 channel 1 clean
# ls -l /dev/rfcomm*
crw-rw---- 1 root dialout 216, 0 2010-02-07 14:53 /dev/rfcomm0
crw-rw---- 1 root dialout 216, 1 2010-02-07 14:53 /dev/rfcomm1
crw-rw---- 1 root dialout 216, 2 2010-02-11 12:28 /dev/rfcomm2
#

If corresponding device (/dev/rfcomm2 on my case) did not appear on /dev/ directory, create that too using (where X is your own appropriate device):

# mknod /dev/rfcommX c 216 X       (e.g. mknod /dev/rfcomm0 c 216 0)
# chown root:dialout /dev/rfcommX  (e.g. chown root:dialout /dev/rfcomm0)
# chmod 660 /dev/rfcommX           (e.g. chmod 660 /dev/rfcomm0)

Everything is now setup for doing the test. Make sure, one more time, your phone still has its bluetooth active (you no longer need it to also be discoverable), and issue following command (at this point, your phone will ask for your authorization):

# chat -e ABORT ERROR '' ATZ OK ATI OK "AT+CGSN=?" OK AT OK "AT+CGSN" OK AT OK >> /dev/rfcomm2 < /dev/rfcomm2
ATZ
OK
ATI
Nokia
OK
AT+CGSN=?
OK
AT
OK
AT+CGSN
35xxxxxxxxxxxxx
OK
AT
OK
#

It is highly recommended to use this chance and set your computer as a "trusted" device to your mobile phone. This will relief you from authorizing each connection attempt to your phone.

If you managed to get any response, is good. If you also got "+CGSM" after "ATI" is even better (my phone did not report it). If you got response "OK" after "AT+CGSN=?", counts as a "better" also (response to AT+CGSN is your phone's IMEI number).

No matter if you got response or not, you now have to release captured device:

# rfcomm release 2   (Make sure you change "2" with your own device number)
#

Now proceed like this:

  1. If you got a response previously, then you have found correct RFCOMM channel. You may now proceed with next step.
  2. If no response, then you need to proceed with next RFCOMM channel candidate. Do "rfcomm bind" for that channel and repeat procedure.
  3. If you are unable to get a response, no matter RFCOMM channel specified, then seems your phone does provide such a way to access its modem capabilities. Too bad.

(Back to contents)
 

Setup bluetooth connection

Following previous steps, we have already gathered bluetooth address of mobile phone, RFCOMM channel of its modem and next available device number. On this step we will permanently setup connection, so that is not required to "rfcomm bind" after every computer restart. For this reason, you need to add new device into file /etc/bluetooth/rfcomm.conf. Make sure you append file with your own equivalent of the following paragraph:

rfcomm2 {
        bind yes;
        device 00:25:47:59:00:00;
        channel 1;
        comment "My phone";
}

Or, use this one long command (changing values appearing with bold):

# printf "\nrfcomm%d {\n\tbind yes;\n\tdevice %s;\n\tchanned %d;\n\tcomment \"%s\";\n}\n\n" "2" "00:25:47:59:00:00" "1" "My phone" >> "/etc/bluetooth/rfcomm.conf"

Then do a restart (just in case):

# /etc/init.d/bluetooth restart

(Back to contents)
 

Install Sakis3G

We now need to install Sakis3G script. Detailed installation instructions are available here. For this guide, we only need sharutils package more:

# apt-get install sharutils
# cd /usr/bin
# wget 'http://sakis.tel4u.gr/sakis3g/legacy/sakis3g.gz'
# gunzip sakis3g.gz
# chmod +x sakis3g

By default, Sakis3G script does not utilize bluetooth devices: we need to configure it. Edit /usr/bin/sakis3g and modify BLUETOOTH_PHONE_rfcomm variable, assigning appropriate rfcomm device name to it, or use following "long" command (changing rfcomm2 with your own device):

# vi -c ":1,$ s/^#BLUETOOTH_PHONE_rfcomm=\(.*\)$/BLUETOOTH_PHONE_rfcomm=\\/dev\\/rfcomm2/g" -c ":wq" /usr/bin/sakis3g

Seems like you have now finished setting up things. There is just one step remaining: test it!

(Back to contents)
 

Test

We can now test what we've done so far. Return to that terminal and issue:

# /usr/bin/sakis3g connect

If command returned flawlessly (with no output at all), you are now connected. Try pinging a destination or opening a web page (mind that Firefox might be in Offline mode, File->Work Offline to disable it). If command returned with an error (and error itself is not descriptive enough):

  1. Check this page if "Unknown operator XXXXX" is returned.
  2. Read here and here if your operator provides multiple APNs (Access Point Names).
  3. Try executing Sakis3G script without "connect" argument, in case menu interface can guide you through connection. Then you can replicate menu interface actions through command line variables.
  4. If none of these helped you, you may get help from troubleshoot section.

If you still can't help it into connecting it, you need to rollback installation following instructions on next section. If you can finally connect reliably using "sakis3g connect" command, as a user this time, issue following command (while still connected):

$ /usr/bin/sakis3g desktop

This will have a desktop shortcut created for your daily convinience.

(Back to contents)
 

Uninstall

I am really sorry if Sakis3G script failed to help you getting connected. You can consider contacting me through email (my email address is contained within first 10 lines of script) so that we work around your problem, or investigate some more by troubleshooting. If you are still determined to go through uninstall, follow these steps:

  1. Delete Sakis3G itself

    # rm -f /usr/bin/sakis3g

     
  2. Uninstall packages you installed so far (and they were not previously installed).
  3. Remove device paragraph we added within /etc/bluetooth/rfcomm.conf.

(Back to contents)
 

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.