Rediscovering Bluetoothby Guylhem Aznar
Presenting Bluetooth in 2006 is hard. By all accounts, it should have emerged much sooner to be omnipresent by now. Yet it did not succeed as planned and therefore carries a bad reputation. Bluetooth is popular, but not as popular as WiFi. However, you can do a lot more with Bluetooth, especially with casual hacking.
Do you know Bluetooth? You may already be familiar with it, and even use it, perhaps with your cellphone and wireless headset. If so, you may wonder what more Bluetooth can do for you, especially if you have read only technical literature about its theoretical aspects--full of overused buzzwords such as "piconets" or "scatternets," but devoid of any real-world application or implementation.
Do not worry. This article shows you how to play with Bluetooth, not buzzwords. If you are not familiar with Bluetooth, I hope to introduce you to such a nifty technology, and guide you through my wonderful world of Bluetooth, with wireless gizmos everywhere!
This article demonstrates how to make your Bluetooth module work, scan for other Bluetooth devices and see which services they can offer, and connect to them. I provide a service named PAN, which can perform wireless IP networking with Bluetooth.
A future article will cover other services: file transfer, serial port export, wireless HID peripherals such as keyboards and mice, audio streaming, and music streaming. Then you can perform and understand fun hacks, such as adding Bluetooth to non-Bluetooth devices, using Bluetooth to automatically start/stop a screensaver, and using existing Bluetooth attacks.
What's the goal? You should be able to synchronize your devices wirelessly, export a serial port for faxing or dialup networking, exchange files with other Bluetooth-enabled hardware, replace your wired HID peripherals with Bluetooth peripherals, and more.
What exactly is Bluetooth? There are many definitions, but my favorite is that it is a generalization of WiFi with lesser power requirements.
With Bluetooth, you do not only have computers talking to other computers. You have wireless headsets streaming audio to cellphones, which you can synchronize with handhelds or computers, which can use peripherals such as mice or keyboards.
Because Bluetooth requires far less power than WiFi, and because it hides the networking complexity from the interface layer, Bluetooth has a lot of creative and interesting uses--more than WiFi.
Speaking of interfaces, you need Bluetooth hardware and software to use Bluetooth features. Some hardware hacks embed the software part directly into the hardware (for example, serial- or printer-cable replacement dongles). However, this removes some flexibility that a software stack provides. It also costs much more, yet introduces even greater complexity.
For the scope of this article, I prefer a light Bluetooth hardware and a large separate software stack.
The Linux kernel can use various software stacks. The best known are
affix. My preference here is
bluez, because it is now part of the Linux kernel.
To deploy a working Bluetooth software stack on your Linux computer, you need Bluetooth hardware!
There are three basic interfaces to Bluetooth hardware: USB, serial, and PCMCIA. Maybe your PC already has integrated Bluetooth? You may then find instructions online to enable that feature under Linux. There are far too many PCs with integrated Bluetooth to present them all within this article.
PCMCIA cards are usually only a PCMCIA-to-serial interface hooked to a Bluetooth chip, while being more expensive. Therefore, if you have a PC without integrated Bluetooth, you need a Bluetooth dongle, either serial or USB.
I recommend you purchase a D-Link DBT-120, as it includes handy special features which I will explain later, especially if you are considering a Bluetooth keyboard. If you cannot find that specific dongle, any cheap USB dongle will be fine. Serial RS-232 dongles are usually much more expensive and slower.
If you have something that's not really a general-purpose PC, and lacks any solution to easily plug in a Bluetooth solution, that's where it gets interesting. However, if you are using a standard USB module, you do not have to worry about all this and may go directly to the software section.
Remember--you need only a serial port to add Bluetooth to your device. Because most devices (such as handhelds) have unused serial ports on their motherboards, adding Bluetooth is very easy. It can be as "easy" as soldering four pins total to the motherboard. This is the bare minimum, requiring two for the serial port (Receive, Send) and two to bring power (Ground, Power) to the Bluetooth chip. Six pins are better (with four pins for the serial port), as this enables flow control.
Many websites present solutions to add Bluetooth to various handhelds, such as the Siemens Simpad, the Sharp Zaurus, or the Psion MX. You can also do that on PCs or laptops with an unused serial port on the motherboard, if you feel like experimenting with Bluetooth. Here are some references:
- Simpad Bluetooth Surgery
- Newton Bluetooth Surgery
- Zaurus C700 Bluetooth Surgery
- Titanium iBook Bluetooth Surgery
- NSLU2 Serial Port Surgery
Of course, you also need to connect these four or six wires to the Bluetooth chip some way or another. The easiest way is to pick up an "all-in-one" module: it features the Bluetooth chip and the antenna on a tiny board, along with the voltage converter you need (TTL 5V/CMOS 3.3V).
If you feel like saving some money, you can purchase cheap USB dongles and convert them into serial port dongles. If you prefer saving some time, you can purchase serial dongles online. Here are some references:
If you are purchasing serial dongles, and have a serial port with four pins (two additional pins for flow control), you do not have anything special to do.
Serial Protocols for Unusual Hardware
If you only have a serial port with two pins (receive/send), you must configure your dongle to use the BCSP protocol instead of H4. Basically, H4 is an industry standard that requires flow control, while BCSP is a CSR proprietary protocol that works just as well without flow control. Because the
bluez stack supports both, you can use either.
However, odds are that your chip will be preset to some protocol. To use the other one, you must change its configuration. For this, use the
pskey utility as documented in the
pskey README or the Opensimpad introduction to Pskey.
Please proceed carefully. It is quite easy to kill a module with a single
Depending on the Linux kernel configuration and your distribution's installed software, your system may work out of the box.
If you are using a distribution with automated package installation, such as Debian or Red Hat, you can get a precompiled version of
bluez without any dependency problem. Go directly to the "Starting
Recompiling a kernel is clearly outside the scope of this article, but may be necessary for some special features that the
bluez project has added after the release of the kernel version you use. This is especially true for my next article, which will introduce advanced features such as Bluetooth keyboard support.
I now assume that you either have a working kernel with
bluez statically compiled or modules with auto-load support.