Skip to contentSkip to conversation

Pairing a bluetooth keyboard

Bluez-users Benjamin Eikel 1 participant 4 messages Feb 2, 2006 – Feb 12, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hello!

I am trying to pair a Bluetooth keyboard (Logitech Cordless Elite Keyboard for Bluetooth, address XX:XX:XX:XX:XX:XX in the following text) with my laptop (Bluetooth USB adapter: Belkin F8T008, , address ZZ:ZZ:ZZ:ZZ:ZZ:ZZ in the following text) for some time now.

I am using a Bluetooth mouse (Logitech MX900, address YY:YY:YY:YY:YY:YY in the following text) too. I am running Debian GNU/Linux unstable, self-compiled Linux kernel 2.6.15.2, bluez-utils package 2.24-1.

My config file '/etc/bluetooth/hcid.conf':
#
# 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 user;

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

# PIN helper
#pin_helper /usr/bin/bluez-pin; pin_helper /usr/lib/kdebluetooth/kbluepin;

# D-Bus PIN helper
#dbus_pin_helper;
}

# 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;

# 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;

# Authentication and Encryption (Security Mode 3) #auth enable;
#encrypt enable;
}

What I am doing:

1. I press the "connect" button on the bottom of the keyboard.

2. I run 'hidd --connect XX:XX:XX:XX:XX:XX'.
Output in '/var/log/syslog':

Feb  2 21:21:37 host hidd: New HID device XX:XX:XX:XX:XX:XX (Logitech 
Bluetooth Keyboard)
Feb  2 21:21:37 host kernel: input: Bluetooth HID Boot Protocol Device 

as /class/input/input9

3. I run 'hcitool con'.
Output:
Connections:
< ACL XX:XX:XX:XX:XX:XX handle 7 state 1 lm MASTER > ACL YY:YY:YY:YY:YY:YY handle 6 state 1 lm MASTER

I can use the keyboard now. Everything works.

4. I run 'hcitool auth XX:XX:XX:XX:XX:XX'. Output:
0000
HCI authentication request failed: Connection timed out

When I enter this command my pinhelper kbluepin shows up and I enter the pin 0000. I enter the same pin on the keyboard. But as you can see at the output above the pin is not used in the correct way but send as keyboard input to the laptop. Somehow the keyboard seems not be in pin entry mode.

So I change my approach. I remove the comment in the last lines of my '/etc/bluetooth/hcid.conf' so that I have:
auth enable;
encrypt enable;

Then I run '/etc/init.d/bluetooth restart'.
Output: Restarting bluetooth: hidd hcid sdpd hidd rfcomm.

When I enter something on the Bluetooth keyboard now, kbluepin shows up again and I enter the same pin on my laptop keyboard and the bluetooth keyboard (I tried the normal numeric keys and the keypad). But this does not work somehow.
Output from '/var/log/syslog':

Feb  2 21:42:30 belt hcid[9127]: link_key_request (sba=ZZ:ZZ:ZZ:ZZ:ZZ:ZZ, 
dba=XX:XX:XX:XX:XX:XX)
Feb  2 21:42:30 belt hcid[9127]: pin_code_request (sba=ZZ:ZZ:ZZ:ZZ:ZZ:ZZ, 

dba=XX:XX:XX:XX:XX:XX)

Of course the mouse is not working too, because I get the pin entry window every time I move it. I already tried another pin helpers, i.e. a script which echoes 'PIN:pin'.

What am I doing wrong? Can you please give me some hints? If you need more data, please tell me.

Regards,
Benjamin Eikel

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#1 lore raw

I have an addition: I tried to set up the encryption at my desktop system. There I have a Logitech diNovo Media Desktop 2.0. I first connected all three devices (mouse, keyboard, media pad). Then I called the 'hcitool auth <address>' command for the media pad. On the display of the media pad I was asked for the pin number and after I entered it on the pad and the computer, 'hcitool con' showed that the connection had the flag AUTH. After that I called 'hcitool enc <address>' and the media pad connection got the additional flag ENC. So I think I succeeded in setting up an encrypted connection for it.
After that I tried the same procedure with the keyboard, but I got the same error output and log as on my notebook.
I use the same operating system and the same versions of the utils and libs on my desktop. The configuration file was the same too. I am using the Logitech bluetooth hub which came with the set there.

Does anybody has an explanation for it? I have not found any HOWTO or documentation about setting up encryption with Bluez. Perhaps you have a hint or can tell my what I am doing wrong.

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#2 lore raw
Quoted 1 line

Hello again,

I am wondering why nobody responds to my questions. If I am doing anything wrong please tell me. I really do not know why this is not working and I did not find anything about that on this mailing list or in the BlueZ documentation files.

Maybe you need more information so I logged some data with 'hcidump -X -V'. I uploaded the log files because I do not want to post such a long text on this mailing list. If this behaviour is not right, please tell me and I will post the logs here.
I am using the same laptop, Bluetooth dongle and keyboard as in my first post. First I did:

root@host:~# hcitool scan
Scanning ...
        00:KE:YB:OA:RD:00       Logitech Elite Keyboard
root@host:~# hidd --connect 00:KE:YB:OA:RD:00

The log is here: http://www.eikel.org/temp/hcidump-connect.log
After that I was able to type on the Bluetooth keyboard and everything was working. Then I wanted to authorize and encrypt the connection:

root@host:~# hcitool auth 00:KE:YB:OA:RD:00
0000
HCI authentication request failed: Connection timed out

Same problem as in my first post, but I have logged it. Here is the file:
http://www.eikel.org/temp/hcidump-auth.log

Of course I have read these logs but I do not get any useful information from it. There are two errors in the second log.
First:

Quoted 1 line

HCI Event: Command Complete (0x0e) plen 10

    PIN Code Request Reply (0x01|0x000d) ncmd 1
    status 0x02 bdaddr 00:KE:YB:OA:RD:00
    Error: Unknown Connection Identifier

Second:

Quoted 1 line

HCI Event: Connection Packet Type Changed (0x1d) plen 5

status 0x1f handle 7 ptype 0x0008
Error: Unspecified Error

But I do not know what these error messages want to tell me and what I could do to get this working.

Maybe someone of you could be so friendly to tell me what I should do to get this encryption working. Or tell me that it is impossible. Or tell me that I am wrong here and where I should ask instead.

Regards,
Benjamin Eikel

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#3 lore raw
Quoted 1 line

With some hints from Patrik Kullman (his page: http://linux.yes.nu/diNovo/) I got it working. It was easier than expected. I just enabled authentication and encryption in the 'hcid.conf'. After that I restarted the Bluetooth system (Debian: '/etc/init.d/bluetooth restart'). I had a ssh connection from another computer to be able to change the pin in '/etc/bluetooth/pin'. I used a script as pin helper which just outputs the content of this file with the prefix 'PIN:'. I wrote a random number into the pin file and hit a button on the bluetooth keyboard. The keyboard tried to connect to the computer and I typed the random pin from the pin file on the keyboard and hit enter. Then the keyboard was connected. I did the same with the keypad. At last I did it with the mouse and used the pin '0000'. At first this did not seem to work with the mouse. I pressed the connect button under the mouse and did a 'hidd --connect <mouseaddr>' by hand and then it worked too. Now 'hcitool con' shows that all three connections are authorized and encrypted. Nice! :-)

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users