# Bluetooth keyboards - Can anyone make them work? (solved)

## robinmarlow

Please help I'm at my wits end!  I was given one of the nice apple mini aluminium keyboards as a birthday present.  However try as i might i can't get it to work in a useful way.

I've tried 3 different bluetooth dongles to see if one of them might see it as a native HID device on boot - but they don't...

So i'm stuck with HCI.  Foolishly i thought that newer versions of bluez would be better - how wrong was i?!

With gnome-bluetooth I can get the thing to pair - but then nothing happens.

I've set autostart=true in my input.conf but i certainly don't get an input created or anything in lshal output.

All the bluetooth guides are based on using the old daemons - but bluez seems to be trying to move away from that so i'd rather not.

What really grates are the pages saying that using the new services with DBUS,HAL & EVDEV will all just work..... if only!

I have a hunch that it could be to do with dbus/hal permissions but am not sure how to debug it & i'm doing this all as root so i guess it isn't likely.

I'm running:

hal-0.5.11-r8

dbus-1.2.3-r1

bluez-4.32

xorg-server-1.5.3-r5

Any help would be gratefully received!

failing that does anyone want an apple keyboard - only lightly used.Last edited by robinmarlow on Mon May 18, 2009 11:57 am; edited 1 time in total

----------

## paulbiz

This is for Ubuntu but maybe it can help:

http://ubuntuforums.org/showthread.php?t=224673

----------

## nicomat1000

hi,

i have the same problem and absolutely no clue how to auto-connect my keyboard at start-up or keyboard wake-up.

mouse works pretty fine, though. and with about five

```
hidd --connect <keyboard>
```

with a few

```
Host is down
```

messages, the keyboard connects too. but hey, that can't be it.

my software configuration is the same robinmarlow's, except for xorg-server 1.6.0.

i would particularly appreciate a tutorial on >=bluez-4 somewhere in the gentoo section.

cheers!

nico

----------

## robinmarlow

Ah! by jove i think i've got it!  Well the keyboard seems to work at the moment anyway.

I'm going to play around with it a bit to try & understand what changed then will report back.  There is hope!

----------

## MichaelLong

Hi robinmarlow,

nice to see that I'm not the only one facing a problem with the apple aluminum bt-keyboard.

I'm having the exact same problem here. After a lot of testing and playing around with the horrible bluez 3.x implementation,

I finally managed to get the keyboard paired. But unfortunately the kernel is not showing a new input-device so I still can't use the keyboard at all.

When I was using bluez 2.x (and older kernel versions) the keyboard worked like a charm.

So I'm very interested in what you have changed, especially in your kernel .config. Maybe I'm missing something relevant here.

Regards

MichaelLong

----------

## chojin

I also had problems connecting my keyboard with the new DBUS services method. not an apple keyboard, but a Logitech diNovo.

I found out the way to connect my keyboard to be:

- check the bluez sender with:

```
$ dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.bluez.Manager.ActivateService string:input

method return sender=:1.37 -> dest=:1.41 reply_serial=2

   string "org.bluez"

```

The above command shows "sender=:1.37". This differs every time you restart your system (or bluetooth services).

- check the registered input devices (replace ":1.37" by your own "sender":

```
# dbus-send --system --type=method_call --print-reply --dest=":1.37" /org/bluez/input org.bluez.input.Manager.ListDevices
```

this gives in my case:

```
method return sender=:1.37 -> dest=:1.42 reply_serial=2

   array [

      string "/org/bluez/input/keyboard0"

      string "/org/bluez/input/keyboard1"

      string "/org/bluez/input/pointing2"

   ]
```

This shows me that I have 2 keyboards (diNovo keyboard + mediapad) and one pointing device (diNovo laser mouse) registered.

If you don't have any device registered (which was never the case for me, as bluez seems to have remembered those registrations from previous bluez versions without the services architecture), I _think_ you will have to register them with:

```
#dbus-send --system --type=method_call --print-reply --dest=":1.37" /org/bluez/input org.bluez.input.Manager.CreateDevice string:00:07:61:34:A7:49
```

where :1.37 should be replaced your "sender" and "00:07:61:34:A7:49" by your BT device MAC address (check with hcitool scan after pressing the connect button of the device)

- in case of a mouse or other device where no pin authorization is required, try to connect your device by pressing the connect button and enter:

```
# dbus-send --system --type=method_call --print-reply --dest=":1.37" /org/bluez/input/pointing2 org.bluez.input.Device.Connect
```

This should return something similar to:

```
method return sender=:1.37 -> dest=:1.43 reply_serial=2
```

After that your mouse should be working, and in my case, it was remembered and keeps working after reboot.

- in case of a keyboard, you will probably have to enter a PIN code for a correct BT link:

For this step will need a BT paskey agent. Gentoo documentation states: 

 *Quote:*   

> "There are a few different graphical passkey agents available to help manage your PIN, such as bluez-gnome and kdebluetooth. You can also use passkey-agent (found in bluez-utils) from the command line. "

 

I used bluetooth-applet from bluez-gnome, (and I didn't find passkey-agent in the bluez-utils package) (be ware: bluetooth-applet segfaults on libGL for some reason if you have eselected nvidia as your OpenGL interface, switch it temporarly to x11 if this is the case.)

So be sure a passkey agent is running, press the connect button on your keyboard and execute:

```
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.CreateBonding string:00:07:61:34:A7:49
```

to start a pairing. The passkey agent should ask you a PIN code. Enter one and then enter the same one on your keyboard followed by enter

```
# dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.CreateBonding string:00:07:61:34:A7:49
```

You should see something like:

```
method return sender=:1.37 -> dest=:1.44 reply_serial=2
```

and the passkey agent should tell you the pairing was succesfull

I think the keyboard should be working now.

In my case it didn't, but did start to work after executing:

```
dbus-send --system --type=method_call --print-reply --dest=":1.14" /org/bluez/input/keyboard0 org.bluez.input.Device.Connect
```

which returns

```
Error org.bluez.Error.ConnectionAttemptFailed: Connection timed out
```

but subsequent executions of this command then give me

```
Error org.bluez.Error.ConnectionAttemptFailed: Connection refused
```

Then I restart /etc/init.d/bluetooth and as soon as I type something on my keyboard, it connects to my pc and I see this in /var/log/messages:

```
hcid[19897]: New input device 00:07:61:34:A7:49 (Logitech diNovo Keyboard)

input: Logitech diNovo Keyboard as /class/input/input7
```

and my keyboard works.. and keeps working upon reboot..

Also see the posts: https://forums.gentoo.org/viewtopic-t-746087.html and https://forums.gentoo.org/viewtopic-t-678056

This is not really the way how it should be.. but it seems the bluez services thing and/or the bluetooth-applet are not yet that user-friendly..  :Sad:  Bluetooth-applet just triggers some  HAL errors when trying to connect with my keyboard trough the GUI, also the registered input devices are not shown in it.. but it helps you entering the PIN code  :Smile: 

Hope this procedure is of any use for an apple keyboard.?

----------

## robinmarlow

Sadly i tried that method based on what the bluez wiki suggests - but it simply doesn't work.  I fail at the first hurdle:

```
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.bluez.Manager.ActivateService string:input

Error org.freedesktop.DBus.Error.UnknownMethod: Method "ActivateService" with signature "s" on interface "org.bluez.Manager" doesn't exist
```

I don't really understand dbus but could never get any further that this.

My keyboard now works with a combination of:

bluez-gnome-1.8

bluez-4.35 (renamed the 4.32 ebuild & put it in my local portage)

Interestingly however only with a bluetooth 2 module - an older one didn't work.

I haven't changed anything of the configuration files in /etc/bluetooth nor conf.d/bluetooth.conf

It was simply a matter of making sure i'd got rid of any old link information

```
del -R /var/lib/bluetooth/*
```

then running bluetooth-applet in the background

```
bluetooth-applet&
```

then running bluetooth wizard

```
bluetooth-wizard
```

It found my keyboard (after a few turnings on & off & holding down the power button until it blinked).  Asked me to type a code on the keyboard (and press enter) then just worked.

However with my old adaptor it didn't work after i turned off the computer - i got an error in the logs:

```
Apr 19 00:04:44 myth btusb_intr_complete: hci0 urb f6b354c0 failed to resubmit

Apr 19 00:04:44 myth btusb_send_frame: hci0 urb f6b354c0 submission failed
```

my new adaptor (£10 from pcworld) seems tro have cured this though & just reattaches by itself:

```
Apr 20 09:57:16 myth bluetoothd[3521]: link_key_request (sba=00:10:60:D2:B6:21, dba=00:1B:63:FC:2F:2D)

Apr 20 09:57:16 myth input: Apple Wireless Keyboard as /devices/pci0000:00/0000:00:02.0/usb2/2-3/2-3:1.0/bluetooth/hci0/hci0:42/input6

Apr 20 09:57:16 myth apple 0005:05AC:022D.0001: input,hidraw0: BLUETOOTH HID v1.36 Keyboard [Apple Wireless Keyboard] on 00:10:60:D2:B6:21
```

Good luck! - i'm going to mark this solved if no-one else posts with problems in the next few days.

Robin

----------

## MichaelLong

Thanks for your suggestions, I already played around with dbus-commands but without any luck.

My next steps are upgrading the kernel and bluez-stuff as well as trying another usb-bt-adaptor.

Greets

MichaelLong

----------

## jiri.tyr

If you have difficulties to get your mouse working with the net-wireless/bluez, have a look at this howto:

http://sidux.com/index.php?module=pnWikka&tag=hwBluetooth

You can find the script simple-agent and test-device in the package in distfiles (/usr/portage/distfiles/bluez-4.xx.tar.gz).

Once your mouse is working, it works even after the restart (it needs probably just the bluetooth init script started).

If you wanna use the latest version of bluez (4.41), you can download a patch for the ebuild here:

https://bugs.gentoo.org/attachment.cgi?id=192141

----------

