USB Bluetooth Adapters (Linux) - WORKING*

Bluetooth related questions

USB Bluetooth Adapters (Linux) - WORKING*

Postby linker3000 » Mon Aug 04, 2008 9:47 am

Last Edit: 18-Jan-2010 (Note about needed files)

The bluetooth.tgz and bluetooth2.tgz files are now attached to another post in this thread - see the note at the bottom of this one. In order to keep the files within the allowed 256KB attachment limit, I have removed the source code and object files - these files are not needed to install the Bluetooth modules and drivers. If you really want the source code, it can be obtained from places like http://www.kernel.org (FYI: The original Linpus linux shipped with the AA1 is based on kernel 2.6.23.9). The drivers and kernel modules supplied here are based on 100% unmodified original source code - I just compiled them to make them available for all of us.

I am glad that so many have found this thread useful and thanks to those who have added their appreciations and their own wisdom in the true spirit of an Open Source support community. Since originally posting this article, things have moved on and my AA1 is (July 2009) now running Fedora 11 so I can't really help much now with Linpus-related issues, but I encourage everyone to post their technical questions to this thread where some kind soul will no doubt help if they can. All the best - Linker3000.

These notes describe setting up a bluetooth adaptor for use with a mobile phone to connect to the Internet, but the initial setup and pairing procedure is also applicable to other devices such as keyboards and mouses - see the other posts in this thread for additional info from others.

*Everything is working except with Dial Up Networking (DUN) getting the ppp DNS servers to be used automatically. There's a few options to work around this:
Upgrading NetworkManager to the SVN version (see this post: viewtopic.php?f=16&t=1209) helps as it allows manual DNS entries to be specified so you can edit in your dial-up service's DNS servers after you have connected - or just use the OpenDNS DNS servers (208.67.222.222 and 208.67.220.220). Others have added the OpenDNS servers to /etc/resolv.conf, but you need to keep an eye on this as NetworkManager can overwrite the file later. You can also specify your service provider's DNS servers (or use OpenDNS) in the gnome-ppp app.

The developers of NetworkManager state that they will 'soon' implement improved support for Dial Up Networking (I'll update the notes here 'as and when'). As an alternative to DUN, some have implemented Personal Area Networks (PANs) via Bluetooth to their phones - see the other posts in this thread.


Useful reading: This PDF is chapter 7 of "Linux Unwired" from O'Reilly and it contains further notes on getting Bluetooth working, pairing devices, file transfers, OBEX, PAN and printing: http://www.devx.com/assets/download/10183.pdf

Happy Bluetoothing!

I hope you find these notes useful - just remember that it's up to you whether you decide to act upon them - they worked for me, but you use them at your own risk.

1) Use the Package Installer (having enabled the Advanced Menu as described here: viewtopic.php?f=13&t=28 ) or yum to install the following:

bluez-gnome, bluez-hcidump, bluez-libs, bluez-libs-devel, bluez-utils, gnome-ppp, gnome-bluetooth

Note: the above-referenced article also describes how you can open a terminal window using file manager and someone has added a note about doing the same with Alt-F2. You will need to be in a terminal window, with root (super user) permissions to issue the commands below. To do this, use the su command to elevate your permissions, or issue the commands with sudo - eg: sudo hciconfig -a

2) Plug in your USB dongle and see if it is recognised (here, I am already logged in as root):

Code: Select all
[root@localhost.net]$ lsusb
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)


If it's not recognised you may need to try a different make/model. Mine was a cheap 'Technika' one from Tesco in the UK.

3) Issuing the command /etc/init.d/bluetooth start gives:

Code: Select all
[root@localhost.net]$ /etc/init.d/bluetooth start
audit_log_user_command(): Connection refused
Can't open RFCOMM control socket: Address family not supported by protocol


We need some Kernel modules...

Download links are at the bottom of this post.

4) Download the kernel modules pack bluetooth.tgz (compiled using a vanilla 2.6.23.9 kernel), extract the files and copy them to the folder /lib/modules/2.6.23.9lw/kernel/drivers/net/bluetooth

5) Now download bluetooth2.tgz, extract and copy the drivers to /lib/modules/2.6.23.9lw/kernel/drivers/bluetooth

Note: Each tgz file expands into its own 'bluetooth' folder so the simplest way to install these files is to copy them into the .../drivers/net and .../kernel/drivers folder (one per location as per the above instructions) and then issue the command tar xvfz <filename>. If you get an error during the copy or extraction, make sure you are logged in as root.

then...

Code: Select all
[root@localhost.net]# depmod
[root@localhost.net]# /etc/init.d/bluetooth start
Starting Bluetooth Services:   [OK]

6) Run the 'Bluetooth Applet' (/usr/bin/bluetooth-applet) to get a Bluetooth logo at the bottom of the screen. Here you can change Bluetooth properties (enable/disable audio, serial, echo and input service), but nothing else happens yet...

7) If your Bluetooth dongle seems dead - remove and re-insert it - OHMYGOD it's flashing! - and a little window should pop up telling you your device had been made 'connectable'!!

8) Scan for new Bluetooth devices on your phone - mine found 'localhost-0' - instruct the phone to pair with the device and enter a key. A 'pairing request' box should pop up on the Acer One asking for a key too. Note the MAC address of the device wishing to pair - you'll need it later. Enter the key on your Acer and you should be told you have bonded!

9) Right click on the Bluetooth logo and select 'Preferences': My bonded phone is listed and the Services tab shows Input and Serial services are available...

10) You can now try and ping your bluetooth device:

First - confirm device is there - it's probably hci0:

Code: Select all
hciconfig -a


Start your device (it may be already started - need to be root for this):

Code: Select all
hciconfig hci0 up


Ping your USB dongle:

Code: Select all
l2ping [MAC address of adapter]  eg: l2ping 00:11:33:55:77:AA


If all is well - ask your paired phone for what it can do - for internet connectivity we're looking for Dial Up Networking (DUN) - on my phone it's on channel 4. Issue the following command and find out:

Code: Select all
sdptool search dun [MAC Address]  eg sdptool search dun 00:17:83:9C:36:D6


If that command doesn't find anything, try the following, which is more comprehensive:

Code: Select all
sdptool records [MAC ADDRESS]



11) Edit /etc/bluetooth/rfcomm.conf to look like this:

Code: Select all
#
# RFCOMM configuration file.
#

rfcomm0 {
# Automatically bind the device at startup
bind yes;

# Bluetooth address of the device attached to the Acer
device [MAC ADDRESS - eg 00:11:22:33:44:55];

# RFCOMM channel for the connection - use the channel number
# for DUN found with the sdptool records command...
channel [CHANNELNO];

# Description of the connection
comment "My_Bluetooth";
}


Now bind the port - this creates /dev/rfcomm0 and connects it to your bluetooth device (if paired)

Code: Select all
rfcomm bind rfcomm0


12) Try and connect to the phone using gnome-ppp:

Code: Select all
gnome-ppp


I filled in gnome-ppp as follows for UK Vodafone - you will need to check what user name and password you need to use. The number *99# is the standard one to access a data connection from most phones:

Username: web
Password: web
Remember Password = ticked
Phone Number: *99#

SETUP:
Modem:
Device: /dev/rfcomm0
Type: Analog Modem
Speed: 115200
Phone line: Tone
Wait for dialtone: unticked

Init strings: (I don't seem to have an Init1!?)
Init 2: ATQ0 V1 E1 S0=0 &C1 &D2
Init 3: AT+CGDCONT=1,"IP","INTERNET"

NB: your Init3 string may be different - the word "INTERNET" is the APN (Access Point Name) for UK Vodafone Pay Monthly connections - look up the APN of your network here: http://franson.com/forum/topic.asp?TOPIC_ID=6669 or here (UK): http://www.filesaveas.com/gprs.html

NB2: Sooo many people get that last CGD... string wrong and put CDG instead, which will throw an error - check carefully!

OPTIONS:
Connections: I have nothing ticked.

Having entered all this, I closed the setup page and hit Connect. In the terminal window behind gnome-ppp I could see the dialog between the Acer and the phone and...

PPP Connected!!!! I

All that needs tidying up now is the DUN DNS issue as described at the top of this post.

NB: If a dial-up fails, or you cancel the ppp dial attempt you may need to issue the following to free the rfcomm connection before using gnome-pp again:

Code: Select all
rfcomm release 0
rfcomm bind 0



*******************************
BLUETOOTH MODULES AND DRIVERS

Well, the files were here, but they expired off the board! I have tried to put them back but the editing tools won't let me. Neva has kindly attached the files you need to his post here:

viewtopic.php?f=36&t=789&start=140#p106283

Read the notes in this post to see where the files need to be put.
Last edited by linker3000 on Mon Jan 18, 2010 2:44 pm, edited 26 times in total.
linker3000
 
Posts: 64
Joined: Fri Aug 01, 2008 1:35 am

Re: USB Bluetooth Adapters (Linux) - WORKING

Postby bug » Wed Aug 06, 2008 1:46 pm

I have this error when I try to run /usr/bin/gnome-applet

libnotify-Message: Unable to get session bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

Any help?
bug
 
Posts: 10
Joined: Thu Jul 24, 2008 9:43 am

Re: USB Bluetooth Adapters (Linux) - WORKING*

Postby linker3000 » Wed Aug 06, 2008 1:59 pm

Hi,

I get a similar message *sometimes* and then when I retry the command it works again - although having the applet running is not essential.

Edit: This may be caused by updating dbus - I am going to try and grab the original version and downgrade to see what happens.
Last edited by linker3000 on Thu Aug 07, 2008 8:59 pm, edited 1 time in total.
linker3000
 
Posts: 64
Joined: Fri Aug 01, 2008 1:35 am

Re: USB Bluetooth Adapters (Linux) - WORKING*

Postby bug » Wed Aug 06, 2008 6:51 pm

Finally flashing (I forget "depmod")

Now I have onother issue, I need bluez-PAN module. But is not available as a compiled module. Can you help me linker3000? ;)
bug
 
Posts: 10
Joined: Thu Jul 24, 2008 9:43 am

Re: USB Bluetooth Adapters (Linux) - WORKING*

Postby bug » Wed Aug 06, 2008 7:14 pm

PAN modules are in bluez-utils so I have it. Even I connect to the phone but no network interface is up... I'm afraid that is the networ-manager ... :roll: still researching
bug
 
Posts: 10
Joined: Thu Jul 24, 2008 9:43 am

Re: USB Bluetooth Adapters (Linux) - WORKING*

Postby bug » Thu Aug 07, 2008 10:03 am

Finally connected through BT PAN of my Windows mobile 6 phone.

I had to:

First of all pair the phone. Activate the PAN Bluetooth in the phone

Once: create /etc/sysconfig/network-scripts/ifcfg-bnep0 with

DEVICE=bnep0
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0

Each time I want to connect:

Start bluetooth service: /etc/init.d/bluetooth start
Activate PAN in the phone
connect to the phone: pand --connect phone-bt-mac-address(00:00:-----)
add the default gateway: route add default gw 192.168.0.1
And the DNS in /etc/resolv.conf: echo "nameserver 80.bla.bla.bla" > /etc/resolv.conf

It's a manual process but is working (at the moment ;) )

I'm sending this post by my BT PAN 3G connection :lol:
bug
 
Posts: 10
Joined: Thu Jul 24, 2008 9:43 am

Re: USB Bluetooth Adapters (Linux) - WORKING*

Postby linker3000 » Thu Aug 07, 2008 11:25 am

Nice work! I'll have to try PAN with my HTC Tytn II instead of DUN. I am glad that adding the DNS servers to resolv.conf manually worked - I will have to re-try that because it didn't for me - did you have to restart network services after editing resolv.conf? I tried that too without any success. Maybe it's a DUN thing?
linker3000
 
Posts: 64
Joined: Fri Aug 01, 2008 1:35 am

Re: USB Bluetooth Adapters (Linux) - WORKING*

Postby bug » Thu Aug 07, 2008 11:58 am

No I didn't. But I had the wifi off and no eth cable plugged. When I start wifi networkmanager deletes my resolv.conf... but after switch of wifi again (front button) you have to edit resolv.conf again to add DNS servers.

Now I am trying to start bluetooth service and gnome-applet automatically at boot time, but I'm not able yet...any help? :roll:
bug
 
Posts: 10
Joined: Thu Jul 24, 2008 9:43 am

Re: USB Bluetooth Adapters (Linux) - WORKING*

Postby linker3000 » Thu Aug 07, 2008 9:24 pm

This is strange - I have tried chkconfig bluetooth on and also added '/etc/init.d/bluetooth start to /etc/rc.d/rc.local and neither fires up the drivers on boot.

EDIT: It seems that autostart stuff needs to be put in /etc/rc.d/slim/nowait.sh, but this may not be necessary as Bluetooth seems to auto start when it first detects an adaptor - see bug's next post in this thread.
Last edited by linker3000 on Thu Aug 28, 2008 11:28 am, edited 2 times in total.
linker3000
 
Posts: 64
Joined: Fri Aug 01, 2008 1:35 am

Re: USB Bluetooth Adapters (Linux) - WORKING*

Postby bug » Fri Aug 08, 2008 8:50 am

I realize that without doing anything in the rc.local or wathever, only with the installation of the bluez- pkgs, if you boot with the BT dongle plugged, bluetooth start automatically.
But if you unplug and plug it againg nothing happens...

May be the auto discover of usb devices but i'm not familiar with this...
bug
 
Posts: 10
Joined: Thu Jul 24, 2008 9:43 am

Next

Return to Bluetooth

Who is online

Users browsing this forum: No registered users and 1 guest