Google Search

Google

Thursday, March 13, 2008

My jabra finally working with bluez...

As I have hit the bottom on my coding task (a project I have been planning for the past 6 months and writing it for the last month), I needed to get my mind off of it and do something I'm good at - debugging - and what better thing to debug than getting my Jabra to work with Skype. As I gave a shot at it some time ago and wasn't happy with the results, so I tried again.

The distribution is Fedora 8 (i386) and headset is Jabra BT 500v.

The first thing I upgraded was Skype itself - from 2.0.0.27 to 2.0.0.43 (built under Fedora Core 5 - isn't it about a time to upgrade?!?!).

At first I tried with the Fedora default bluez packages (version 3.20), but no luck there. Same results as before. At least this time I was just playing with it - hoping that the Fedora team had patched something.

Oh well - back to the basics. The latest version of bluez-libs and bluez-utils is 3.28, so why not give it a try. As I'm a lazy person and the archives did not include a spec file I reused the 3.20 spec files. As I'm am apt user I used "apt-get source bluez-libs bluez-utils" but somehow it is also doable in yum. This should create 2 spec files in "/usr/src/redhat/SPECS" folder. All I need to do was to copy the source archives into "/usr/src/redhat/SOURCES" folder and mod the spec files.

Bluez-libs was pretty easy to rebuild - just edited the spec file and replaced the "Version:" from 3.20 to 3.28 and ran the "rpmbuild -ba bluez-libs.spec". This created:
Wrote: /usr/src/redhat/SRPMS/bluez-libs-3.28-1.fc8.src.rpm
Wrote: /usr/src/redhat/RPMS/i386/bluez-libs-3.28-1.fc8.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/bluez-libs-devel-3.28-1.fc8.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/bluez-libs-debuginfo-3.28-1.fc8.i386.rpm

Now a little "rpm -Uvh /usr/src/redhat/RPMS/i386/bluez-libs-3.28-1.fc8.i386.rpm /usr/src/redhat/RPMS/i386/bluez-libs-devel-3.28-1.fc8.i386.rpm" and we have a newer libs in place (the devel package is needed for building the utils packages).

The bluez-utils was a bit more complicated as I had a bad experience when building the 3.20 version last time. Namely the "--enable-all" flag did NOT work at that time so just in case I modified the configure parameters. The basics are the same - replace the "Version:" string from 3.20 to 3.28 and the "Release:" string from "6%{?dist}" to "1%{?dist}". Now for the "%configure" parameters - the first thing was to replace "--disable-obex" with "--enable-obex". I'm not sure as to why it is disabled, but just in case I need obex I have it. After the obex I also added "--enable-alsa --enable-oss --enable-hal --enable-usb --enable-glib --enable-gstreamer". Now all I needed to do was a "rpmbuild -ba bluez-utils.spec" and woala:
Wrote: /usr/src/redhat/SRPMS/bluez-utils-3.28-6.fc8.src.rpm
Wrote: /usr/src/redhat/RPMS/i386/bluez-utils-3.28-6.fc8.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/bluez-utils-cups-3.28-6.fc8.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/bluez-utils-gstreamer-3.28-6.fc8.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/bluez-utils-alsa-3.28-6.fc8.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/bluez-utils-debuginfo-3.28-6.fc8.i386.rpm

Now a little "rpm -Uvh /usr/src/redhat/RPMS/i386/bluez-utils-3.28-6.fc8.i386.rpm /usr/src/redhat/RPMS/i386/bluez-utils-alsa-3.28-6.fc8.i386.rpm" and bluez should work.

So to start the bluetooth audio service I have this script headset.py:
#!/usr/bin/python
import dbus
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'), 'org.bluez.Manager')
bus_id = manager.ActivateService('audio')
audio = dbus.Interface(bus.get_object(bus_id, '/org/bluez/audio'), 'org.bluez.audio.Manager')

In theory this could be done from command line, but some time ago I found this little snippet that works for me. Basically all it does is activate and register the service as root through the dbus and it works from regular user account.

Now for the last but not the least we have to define the headset that will be used in our home folder. The file is ~/.asoundrc and mine contains the following:
pcm.bluetooth {
type bluetooth
device "00:13:17:2B:0D:11"
profile "auto"
}

where the device is the mac address of the device.

Now - to use the headset with Skype. first I run the headset.py script from console and then run Skype and BINGO - the sound starts almost the same time Skype starts. not 40 seconds later like with version 3.20. Not bad considering the connection is crypted and wireless :)
So the next step was to try the test call - and it worked without a delay!!! Last time I had to wait up to 2 minutes for Skype to initialize the output and input and thats if the connection staid up that long.

So - my headset is working and hopefully it will continue to work with Fedora 9 when it will be available and I hope it will be helpful to someone else.

Blogged with Flock

1 comment:

Badi Morris said...

Is there any way you could post the spec files you used for bluez-lib and bluez-utils?