Chapter 1. Bluetooth, Mobile Phones, and GPS |
1.1. Hacks 122: Introduction
There is much talk in the communications industry of providing
last-mile
connectivity. Think of Bluetooth as providing connectivity for the last 10 feet. Bluetooth excels as a handy cable-replacement technology, helping to eliminate the need for cumbersome wires that you might find on headsets, remote controls, PDAs, and other small devices. Bluetooth aims to end the days of needing to carry a three-
If you can provide connectivity for the last 10 feet, how do you find yourself on this blue-green sphere we call Earth? The global positioning system (GPS) has
Mobile phones are everywhere. For many people, they have become the sole telephone of choice, enabling them to abandon land lines altogether. When you combine a mobile phone and Bluetooth, even more hacks become possible. |
Hack 1. Set Up Bluetooth on Linux
Linux
Prior to the release of the 2.6 Linux kernel, getting Bluetooth support involved compiling your own kernel as well as the necessary utilities. There were also multiple Bluetooth stacks available, each with their own features, adapter support, and
First, make sure you have a supported Bluetooth adapter. You used to be able to find a reasonably current list of BlueZ-supported hardware at http://www.holtmann.org/linux/bluetooth/devices.html. However, as of March 2005, this information has been removed because of threatened legal action from the Bluetooth SIG. What this basically means is that the association of companies who maintain the Bluetooth standard don't want
Red Hat and Fedora users should install these packages using yum or rpm . This assumes you're using GNOME as your window manager: yum install bluez-utils gnome-bluetooth Likewise, Debian and Ubuntu users should install using apt : apt-get install bluez-utils gnome-bluetooth
This next bit is for UART-based (that is, non-USB) devices only, so if you're using a USB Bluetooth adapter, you can skip ahead. Serial-style USB devices, which include serial
If you're using a UART-based device, you may see a reference to a
/dev/ttySn
serial device, where
n
is some integer. In any event, you can try attaching the device to the Bluetooth host controller device by running
/sbin/hciattach/dev/ttySn any
from the command line. Like any good Unix utility, you know that
hciattach
worked if it returns without printing anything. If it doesn't work, make sure you have the right device and check the
Assuming that the hciattach command did work, you will want to add a reference to this device to your /etc/bluetooth/uart file, so that the device can be appropriately attached to the Bluetooth host controller interface at boot time. If this file doesn't exist, create it. Add a single line to this file that reads /dev/ttySn any , replacing n with the appropriate serial device number.
Now that you have everything installed, plug in your Bluetooth adapter and try running
/etc/init.d/bluetooth start
as root. In Debian and Ubuntu, start Bluetooth with
/etc/init.d/bluez-utils start
. You should see some appropriate status messages in your
/var/log/messages
. Assuming everything works, you might want to add the Bluetooth script to the appropriate
rc.d
directory for your default run level with the
chkconfig
utility or via a manual
Now run hciconfig from the command line. You should see something like hci0: Type: USB BD Address: 00:11:22:33:44:55 ACL MTU: 192:8 SCO MTU: 64:8 UP RUNNING PSCAN ISCAN RX bytes:99 acl:0 sco:0 events:13 errors:0 TX bytes:296 acl:0 sco:0 commands:12 errors:0 If you don't see anything like this, make sure that hcid is running and that there aren't any error messages in /var/log/messages . The BD Address shown is the unique Bluetooth identifier for your adapter, much like an Ethernet MAC address.
Now, bring another Bluetooth device within range of your computer, and make sure that the device is visible to Bluetooth
$ hcitool scan Scanning … 00:99:88:77:66:55 Nokia3650 You can now test the device to see which services it supports, using sdptool browse 00:99:88:77:66:55 . You should see a lengthy list of supported services, providing information that can be used to configure access to those services. Schuyler Erle |