<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Benny's Blog &#187; bluetooth</title>
	<atom:link href="http://blog.projectnibble.org/tag/bluetooth/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.projectnibble.org</link>
	<description>House Of Code</description>
	<lastBuildDate>Fri, 13 Aug 2010 15:06:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>How Ubuntu’s broken bluetooth support came to be</title>
		<link>http://blog.projectnibble.org/2010/08/08/how-ubuntus-broken-bluetooth-support-came-to-be/</link>
		<comments>http://blog.projectnibble.org/2010/08/08/how-ubuntus-broken-bluetooth-support-came-to-be/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 17:56:09 +0000</pubDate>
		<dc:creator>Benny Bottema</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[bluez]]></category>
		<category><![CDATA[jaunty]]></category>
		<category><![CDATA[karmic]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lynx]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.projectnibble.org/?p=560</guid>
		<description><![CDATA[A couple of years ago it happened, Linux land was getting a Bluetooth upgrade. However, everything was not well afterwards. CLI Bluetooth suicide by bluez: Bluetooth is dead! Long live Bluetooth!]]></description>
			<content:encoded><![CDATA[<p><img src="http://projectnibble.org/dump/blog/ubuntu/bluetoothquestion.jpg" alt="Bluetooth supported?" style="float:left;width:150px;height: 150px" /> Pairing up your Bluetooth device was relatively well documented, by the community anyway. It was mostly done using the bluez package from <a href="http://www.bluez.org/">bluez.com</a>. Ubuntu town and in fact all of Linux land was generally at peace and the trendy folk at the BlueTooth Bar were being all trendy-like.</p>
<p>Then it happened. Ubuntu went up one release: <strong>Jaunty came to be and subsequently Bluetooth support died</strong>. Even now the Internet is teeming with Bluetooth bug reports, problems and forums are filled with questions such as &#8216;my keyboard is not being paired&#8217;. In fact, Debian seemed to be hit as well as some other distributions that leveled up.</p>
<p><strong>What had happened?</strong></p>
<p><span id="more-560"></span></p>
<h2>Bluez changed is what happened</h2>
<p>The developers of bluez, once the nice Bluetooth package everyone could live with, decided <a href="http://www.bluez.org/bluez-40/">it was time for a major overhaul</a>: they merged the packages <em>bluez-libs</em> and <em>bluez-utils</em> and then some. And with &#8216;and then some&#8217; meaning completely changing the way Bluetooth devices are configured and thereby breaking backwards compatibility.</p>
<p>All of this shouldn&#8217;t really matter, except for one little detail: <strong>The Ubuntu dev team thought it was a good idea to drop the old Bluetooth support and go for the new version</strong>. They included bluez 4.0 and everybody broke in tears. That&#8217;s all there is to this little story, Bluetooth has been neglected since 2008 when Jaunty came about and <strong>things have not improved</strong>.</p>
<p><strong>Why is that?</strong></p>
<h2>Bluez is a bunch of cowboy coders is why</h2>
<p>Actually, I know nothing of the team except that <a href="http://git.kernel.org/?s=bluetooth">it seemingly has about one active developer</a>. Bluez arguably is an awesome team: they have these coders, stomping away on probably wireless keyboards to create utterly thorough Bluetooth support for Linux. They&#8217;re awesome right? Perhaps not.</p>
<p><strong>Bluez doesn&#8217;t document anything</strong>. At all. It&#8217;s a <a href="http://forums.gentoo.org/viewtopic-t-833038-highlight-.html">widely acknowledged fact</a> (Gentoo too?) they didn&#8217;t document the legacy Bluetooth support and they didn&#8217;t document the new support. If you read the <a href="http://www.bluez.org/bluez-40/">bluez 4.0 release notes</a> you still don&#8217;t know anything and you won&#8217;t either. Nobody will, because there is no documentation! Oh, they&#8217;ll completely overhaul Bluetooth support but they&#8217;ll never tell how it works now. That&#8217;s for you to find out. I&#8217;ve even glanced over the source code only to find out that they don&#8217;t like to comment their code either.</p>
<p style="background-color: rgb(225,225,225);padding: 5px;text-align: center;">
<a href="http://c2.com/cgi/wiki?CowboyCoder">Definition of a Cowboy Coder</a><br />
Although normally I couldn&#8217;t care less about some random piece of software, but if you include a significant framework in your operating system, there have got to be <i>some</i> kind of set of standards that includes documentation, right?
</p>
<p>That&#8217;s why everyone is still dealing with the same problems it did in 2008: <strong>the old <a href="https://help.ubuntu.com/community/BluetoothSetup">community documentation</a> is still there, but it isn&#8217;t getting updated</strong>. That page is just one of hundreds ofcourse. Here&#8217;s the <a href="http://forums.overclockers.com.au/showthread.php?t=875957">typical research process</a> one goes through figuring out how to get Bluetooth working (notice how he&#8217;s constantly confronted with conflicting guides and ultimately didn&#8217;t find a solution). The problem again is that nobody <i>can</i> update those pages. If you are feeling particularly masochistic, try reading <a href="http://www.linuxquestions.org/questions/debian-26/bluetooth-problems-715839/#post3512495">this thread</a> (especially the last post where it says &#8216;SOLVED&#8217;).</p>
<p>Let&#8217;s discuss what must be one of the most encountered problem: &#8216;hcid.conf is missing!&#8217;. <a href="http://ubuntuforums.org/showthread.php?t=594624">Old documentation</a> will tell you how to configure your Bluetooth device in Ubuntu so that it connects when your pc boots. That is to say, how you need to edit a <em>/etc/bluetooth/hcid.conf</em> configuration file. Well, that file was removed by the bluez team in bluez 4.0. Reread the <a href="http://www.bluez.org/bluez-40/">bluez 4.0 release notes</a>:</p>
<blockquote><p>With this new major version a lot of things have been changed:<br />
   &#8211; The main daemon is now called bluetoothd (instead of hcid)<br />
   &#8211; The main configuration file is /etc/bluetooth/main.conf and follows INI-style syntax</p></blockquote>
<p>And indeed, scanning the source files reveal that the hcid.conf is no longer used, but other configuration files instead. It appears to me that hcid.conf has become main.conf, except that scanning the code doesn&#8217;t confirm this. Instead, main.conf and input.conf are only used to read the options already provided. Changing the names of configuration files ofcourse isn&#8217;t the only thing that changed, since just using main.conf or whatever doesn&#8217;t seem to magically do the trick. I still can&#8217;t figure out how to enumerate devices in the new configuration files, it&#8217;s not like you can&#8217;t just say, <i>&#8216;Well, instead of hcid.conf just use blah.conf&#8217;</i>. I did get a long way <a href="http://hoyhabloyo.wordpress.com/2009/10/04/howto-using-your-mobile-phone-as-a-bluetooth-modem/">configuring my keyboard in rfcomm.conf</a>, but since my keyboard doesn&#8217;t seem to support SMP (Session Multiplex Protocol, I got errors reporting this to me), I assume it is used mainly for pairing phones.</p>
<p>Even now, everyone still uses the deprecated but still supported <a href="http://manpages.ubuntu.com/manpages/lucid/en/man1/hidd.1.html">hidd</a>, primitive but effective bluetooth adapter tool. You can install it using the command <i>sudo apt-get install bluez-compat</i> and then use it they way I used it to <a href="http://blog.projectnibble.org/2010/01/28/how-to-connect-a-bluetooth-keyboard-in-ubuntu-9-04-jaunty-and-9-10-karmic-workaround/">connect my keyboard</a>. You just can&#8217;t use it to reconnect devices with from reboot, wake up, or the device coming out of suspension. The hcid.conf was used for this, but now it is dead.</p>
<h2>About hidd being deprecated anyway</h2>
<p>If hidd has become deprecated, I wonder what replaced it. Searching the internet revealed <em>nothing</em>. Until I found this <a href="http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/2f27aa10c60ef1c4?pli=1">deeply hidden gem</a>. In this Debian bug report, this guy &#8216;Phil&#8217; mentions how a guy on the bluez mailing list mentioned that a wiki mentioned something about hidd being replaced with a more generic so called &#8216;&#8221;input service&#8221; over <a href="http://www.freedesktop.org/wiki/Software/dbus">dbus</a>&#8216; approach? Woh, have I just found a vague piece of information about how things changed? Let&#8217;s see this Wiki! Oh wait! IT DOESN&#8217;T EXIST! Sigh.</p>
<blockquote><p>I had set up my bluetooth keyboard based on the instructions in /usr/share/doc/bluez-utils/README.Debian, i.e. starting hidd &#8211;server by enabling it in /etc/default/bluetooth, running hcitool scan, and then hidd &#8211;conect <addr>.  This method is now deprecated; instead we should use something called the &#8220;input service&#8221; over dbus.  See the following page, which contains examples of dbus-send commands to do this: http://wiki.bluez.org/wiki/HOWTO/InputDevices</p></blockquote>
<p>Ofcourse I just *had* to know what was on that Wiki, so I turned to the ever so awesome Wayback Machine. <a href="http://web.archive.org/web/20080420100303/http://wiki.bluez.org/wiki/HOWTO/InputDevices">Here&#8217;s what I found</a>. Read it yourself. Hint: you won&#8217;t get anywhere, but here&#8217;s what I get from it. It seems the new approach is a more generic ultra obfuscated command that accepts an instruction class or identifier such as &#8216;org.bluez.input.Manager.RemoveDevice&#8217;. No manual and certainly nothing about configuring your connections for auto-connect during boot.</p>
<p>I don&#8217;t know why they took down the wiki, but from the looks of it, most of it was about the API anyway, useful for developers, not end-users using the command-line.</p>
<p>Also, there&#8217;s an <a href="https://bbs.archlinux.org/viewtopic.php?pid=563760">interesting discussion on bluez 4.0 in Arch Linux</a> I found, the first one I&#8217;ve encountered where the participants actually try to get the new &#8216;dbus&#8217; way working. Nothing we can use in Ubuntu though. I&#8217;ve tried to get bluez talking to me using dbus, but I couldn&#8217;t get it to do anything but spout a range of errors.</p>
<p>Finally, a guide I found on <a href="http://wiki.openmoko.org/wiki/Manually_using_Bluetooth">using Bluetooth with bluez 3 and 4</a> not related to a particular Linux distribution. Unfortunately, the dbus keeps barfing up on everything I throw at it, so no dice for Ubuntu I guess.</p>
<h2>Current state of Ubuntu&#8217;s Bluetooth support</h2>
<p>Technically the title of this blog post is wrong: <strong>Ubuntu&#8217;s Bluetooth support is probably better now than it ever was, it&#8217;s just that nobody knows how to use it</strong>. To be fair, it&#8217;s not an entirely lost cause; people still get their devices to work properly after many people have tried to fix some variation of a given problem and people figured out how to connect a mouse or a phone using the new Bluetooth support for example, often with obscure workarounds. But a lot of people, including me, <a href="http://blog.projectnibble.org/2010/01/28/how-to-connect-a-bluetooth-keyboard-in-ubuntu-9-04-jaunty-and-9-10-karmic-workaround/">still can&#8217;t get a Bluetooth keyboard to connect and pair during boot</a>.</p>
<p>Also there is a solution if you happen to use some desktop, using the <a href="http://library.gnome.org/users/gnome-bluetooth/stable/gnome-bluetooth-applet.html.en">Bluetooth Applet</a>. It handles everything for you and reportedly it generally works. It&#8217;s no use to me however as I&#8217;m only running a server, but I might check out the applet&#8217;s source code to see how it works, hopefully using bluez&#8217; command line API.</p>
<p>As of yet, there has been no answer from the dev team on the number one <a href="http://www.google.com/search?hl=en&#038;q=hcid.conf+missing+OR+gone">search result for &#8216;missing hcid.conf&#8217;</a> bug report: <a href="https://bugs.launchpad.net/ubuntu/+source/bluez-utils/+bug/365779">Bug 365779</a>. Technically it&#8217;s not a bug, but the fact that it hasn&#8217;t been closed, deferred to another bug or had a dev on it since May 2009 indicates it either has no priority or nobody had the balls to fix it. Notice though there are literally hundreds of bluez related bug reports for numrous distro&#8217;s.</p>
<p>Also a search on the original writers of the <a href="http://manpages.ubuntu.com/manpages/hardy/en/man5/hcid.conf.5.html">last hcid.conf man page</a> didn&#8217;t reveal a comment on how things changed and how things now work.</p>
<p>So what needs to be done to get some clarity on the matter? If you know, please shout out, because yes, I&#8217;m currently still looking to fix my keyboard under Ubuntu 10.04. </p>
<p>Meanwhile, try <strong><a href="http://vikashazrati.wordpress.com/2008/06/11/bluetooth-problems-ubuntu-804/">downgrading the bluez package to its previous version</a></strong> (note: I couldn&#8217;t get the bluetooth package to work with the older bluez packages in Ubuntu 10.04, good luck and have fun).</p>
<p><a href="http://blog.projectnibble.org/2010/08/08/how-ubuntus-broken-bluetooth-support-came-to-be/trackback/">trackback</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.projectnibble.org/2010/08/08/how-ubuntus-broken-bluetooth-support-came-to-be/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to connect a bluetooth keyboard in Ubuntu 9.04 Jaunty and 9.10 Karmic (workaround)</title>
		<link>http://blog.projectnibble.org/2010/01/28/how-to-connect-a-bluetooth-keyboard-in-ubuntu-9-04-jaunty-and-9-10-karmic-workaround/</link>
		<comments>http://blog.projectnibble.org/2010/01/28/how-to-connect-a-bluetooth-keyboard-in-ubuntu-9-04-jaunty-and-9-10-karmic-workaround/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 21:54:57 +0000</pubDate>
		<dc:creator>Benny Bottema</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[jaunty]]></category>
		<category><![CDATA[karmic]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.projectnibble.org/?p=374</guid>
		<description><![CDATA[Here&#8217;s a quick workaround for connecting and reconnecting a bluetooth keyboard (or any bluetooth device for that matter) in Ubuntu Jaunty and Karmic, even after rebooting. In short it&#8217;s a shell script that keeps connecting to your device in the background on a regular interval. Dirty? Absolutely. Does it work? Absolutely, no bluetooth configuration required [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick workaround for connecting and reconnecting a bluetooth keyboard (or any bluetooth device for that matter) in Ubuntu Jaunty and Karmic, even after rebooting. In short it&#8217;s a shell script that keeps connecting to your device in the background on a regular interval. Dirty? Absolutely. Does it work? Absolutely, no bluetooth configuration required at all.</p>
<p><span id="more-374"></span></p>
<p>Originally, this whole workaround came from a <a href="http://ubuntuforums.org/showthread.php?p=8739447#post8174091">post on ubuntuforums.org</a> by Unkie, which I modified only slightly (I&#8217;m plantface there). This workaround revolves around <a href="http://linuxcommand.org/man_pages/hidd1.html">hidd</a>, which was removed in Ubuntu 9.04 which you can get back as follows:</p>
<pre  name="code">sudo apt-get install bluez-compat</pre>
<p>Hidd is a tool that works like a charm for scanning and connecting to bluetooth devices. It&#8217;s still used these days because  the Ubuntu dev team somehow manages to kill bluetooth support  every new version. There are so many tutorials and flavors floating around to get a bluetooth device working and apparently with so little success that hidd remains popular. With 9.04 they gave bluetooth an <a href="http://ubuntuforums.org/showthread.php?t=952168">overhaul</a> and deprecated hidd.</p>
<p>Anyway, here&#8217;s the shell script that keeps connecting your keyboard. There&#8217;s one catch though: I haven&#8217;t figured out how to let the keyboard sleep, awake and reconnect itself, so you&#8217;ll need to hit the reset button on the keyboard to reveal itself to the bluetooth adapter looking for it. Reconnecting this way requires thus one extra manual action before it reconnects (same thing goes for when you rebooted). But it reconnects when you want it to, which is what I&#8217;m content with for the moment, considering the alternative.</p>
<ol>
<li>
First create a new file for the script:</p>
<pre  name="code">sudo nano /etc/keyboard.sh</pre>
<p>Add the following script:</p>
<pre  name="code">
while (sleep 10)
do
sudo hidd --connect AA:BB:CC:DD:EE:FF > /dev/null 2>&#038;1
done
</pre>
<p>Close and save. </p>
<p style="font-size: 4pt; background-color: rgb(225,225,225);"><strong>Note</strong>: that AA:BB address should be the MAC address of your keyboard. You can find it using the new bluetooth tool <i>hcitool scan</i> (make sure your keyboard is findable by hitting its reset switch) or with <i>hidd &#8211;search</i>, which coincidently will automatically attempt to connect your device while scanning it.</p>
<p style="font-size: 4pt; background-color: rgb(225,150,150);"><strong>EDIT: August 8th, 2010</strong><br />
I updated the above script to react much more quickly and avoid unnecessary connect attempts:</p>
<pre  name="code">

#! /bin/bash

address="AA:BB:CC:DD:EE:FF"

while (sleep 1)
do
 connected=`sudo hidd --show` > /dev/null
 if [[ ! $connected =~ .*${address}.* ]] ; then
  sudo hidd --connect ${address} > /dev/null 2>&#038;1
 fi
done
</pre>
</li>
<li>
Next we&#8217;ll make sure it&#8217;ll run in the background when booted. Create a new boot entry:</p>
<pre  name="code">sudo nano /etc/init.d/keyboard</pre>
<p>Add the following script:</p>
<pre  name="code">
#!/bin/sh

/etc/keyboard.sh &#038;

exit 0
</pre>
<p>Close and save.
</li>
<li>
Give both files execution rights with <i>chmod +x {filename}</i>
</li>
<li>
Now run the following command to get the script executing during boot:</p>
<pre  name="code">sudo update-rc.d keyboard defaults</pre>
</li>
</ol>
<p>Reboot and check if it works. Remember to hit your keyboard&#8217;s reset switch when you want Ubuntu to connect your keyboard.</p>
<p><a href="http://blog.projectnibble.org/2010/01/28/how-to-connect-bluetooth-keyboard-in-ubuntu-9-04-jaunty-workaround/trackback/">trackback</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.projectnibble.org/2010/01/28/how-to-connect-a-bluetooth-keyboard-in-ubuntu-9-04-jaunty-and-9-10-karmic-workaround/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
