Friday, December 12, 2008

Pairing bleutooth devices with the EeePC

In my last post, I told you how to get Bluez working. Having done that, we now want to connect devices like a mouse, keyboard and even a cellphone. Make sure Bluetooth is working, by using hcitool scan (you should see other devices, if the are discoverable)

So let's start with pairing devices and make them known by your computer. First let's get the address from the device we will be pairing. Press the connect button on your keyboard, mouse or other device.

sudo hcitool scan

You should see the address and name of all the devices that are in discovery mode. You'll have to remember them. The tricky part about bluetooth is the pairing between devices. The thing is, there is no pairing helper in Xandros on the Eeepc and that makes it almost impossible to pair. But, there is a solution. Someone compiled the passkey-agent for Xandros EeePC.

wget https://dl.getdropbox.com/u/19226/passkey-agent
chmod +x passkey-agent

You can put this application in what ever directory you like. Just don't remove it. Next we will need a small script that echo's the pin. Don't forget to replace the pin, by one your own one .

#!/bin/sh
echo "PIN:1234"

Put the code above in a script called givepin and make the script executable.

vim /etc/bluetooth/givepin
chmod +x /etc/bluetooth/givepin

We do need to change some entry's in /etc/bluetooth/hcid.conf (the Bluetooth Host Controller Interface daemon). I'll paste my code here. The bold parts are pieces that have been changed.
#
# HCI daemon configuration file.
#

# HCId options
options {
# Automatically initialize new devices
autoinit yes;

# Security Manager mode
# none - Security manager disabled
# auto - Use local PIN for incoming connections
# user - Always ask user for a PIN
#
security auto;

# Pairing mode
# none - Pairing disabled
# multi - Allow pairing with already paired devices
# once - Pair once and deny successive attempts
pairing multi;

# Default PIN code for incoming connections
pin_helper /etc/bluetooth/givepin;
# passkey "1234";

}

# Default settings for HCI devices
device {
# Local device name
# %d - device id
# %h - host name
name "%h-%d";

# Local device class
class 0x3e0100;

# Default packet type
#pkt_type DH1,DM1,HV1;

# Inquiry and Page scan
iscan enable; pscan enable;

# Default link mode
# none - no specific policy
# accept - always accept incoming connections
# master - become master on incoming connections,
# deny role switch on outgoing connections
lm accept;
discovto 0;

# Default link policy
# none - no specific policy
# rswitch - allow role switch
# hold - allow hold mode
# sniff - allow sniff mode
# park - allow park mode
lp rswitch,hold,sniff,park;

auth enable;
}

Now you only have to restart the bluetooth service and you can start pairing your devices.
/etc/init.d/dbus restart
/etc/init.d/bluetooth restart

So how do you pair? Well the only way is, by starting a service over bluetooth. This, I will explain in the next blog entry's. I'll show you how to connect a mouse, keyboard or other hidd device, how to mount your phone and how to set up a network with your phone (so you can use the phone to connect to the internet)


Share/Save/Bookmark

No comments: