# Logitech k810 Bluetooth keyboard (updated 5/11/2014)



## sk8harddiefast (May 15, 2013)

Hi. Yesterday I bought a new Logitech keyboard (k810). This keyboard uses a Bluetooth connection. Today I tried to make it work with no success. At this moment I added these lines:
/etc/rc.conf

```
hcsecd_enable="YES"
sdpd_enable="YES"
```
/boot/loader.conf

```
ng_ubt_load="YES"
ng_l2cap_load="YES"
```

In /dev no ubt0 is showing.

Reading the Handbook, after loading the kernel I must run `service bluetooth start ubt0` but I get 
	
	



```
/etc/rc.d/bluetooth: ERROR: Unable to setup Bluetooth stack for device ubt0
```

Finally `hccontrol -n ubt0hci inquiry` returns me no device, but the Logitech is on.

How to make it connect?
My Bluetooth adapter is F8T016 - Mini Bluetooth Adapter

Any help here?

Also I forgot to mention that the Belkin mini *USB* Bluetooth adapter use*s* the BCM20702A0 chip*s*et w*hi*ch is supported by FreeBSD*.*


----------



## SirDice (May 17, 2013)

It's been a while since I played with Bluetooth on FreeBSD. But I can remember the device needs to be paired first.

32.4.6 Pairing of Devices

Most likely the keyboard will use a PIN of 0000.


----------



## sk8harddiefast (May 17, 2013)

But how can I find btaddr?

ÎŸk. Î™ am out. If you will not help me to do it, I will never made it. I tried everything.


----------



## jozze (May 18, 2013)

I never used Bluetooth at all, however, I have really good feedback to give from my experiences with the various mailing lists. Just recently one of the developers gave me a patch that restores my webcam support (one of the revisions in 9.1-STABLE this week broke it), so if you feel like you've tried everything, and you don't know where else to turn to, consider asking on freebsd-bluetooth@freebsd.org. Asking won't harm anyone 

By the way, what is the output of `# dmesg | tail` after you "plug in" the device?


----------



## sk8harddiefast (May 18, 2013)

Î™ am going to try it but first I want to see if anyone here will help me. I have some months to login but in my almost 2,5 years here always was people that helped me in gazillion problems


----------



## jozze (May 18, 2013)

OK 

Well, I'm no expert, but like  I said before, I'd check what `# dmesg | tail -20` gives, just to see if there are problems with modules and if your keyboard is being recognized by the system.


----------



## sk8harddiefast (May 18, 2013)

Returns me:

```
linux: pid 4665 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4684 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4697 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4716 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4746 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4763 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4833 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4846 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4874 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4887 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4905 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4933 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4952 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4968 (npviewer.bin): syscall pipe2 not implemented
linux: pid 4999 (npviewer.bin): syscall pipe2 not implemented
linux: pid 5028 (npviewer.bin): syscall pipe2 not implemented
linux: pid 5048 (npviewer.bin): syscall pipe2 not implemented
linux: pid 25258 (npviewer.bin): syscall pipe2 not implemented
linux: pid 25359 (npviewer.bin): syscall pipe2 not implemented
linux: pid 25640 (npviewer.bin): syscall pipe2 not implemented
```

And my complete `dmesg`

http://pastie.org/7924004


----------



## jozze (May 18, 2013)

OK, this doesn't seem normal. Do you have any special configuration in your /etc/src.conf or in your kernel config?

I am asking, because your complete [cmd=""]dmesg[/cmd], line 241, suggests you don't have either Bluetooth in your world or in your kernel, or, you don't have netgraph in either your world or kernel.

EDIT:
If you're using a custom kernel with a full world, try enabling


```
device         udbp
```

in your kernel.


----------



## sk8harddiefast (May 18, 2013)

But how is this possible? I use GENERIC kernel. I have my kernel configurstion but didn't build yet. Also on boot I load the Bluetooth module. In /etc I have no file named src.conf.

`kldstat` returns:

```
Id Refs Address            Size     Name
 1   48 0xffffffff80200000 1323408  kernel
 2    1 0xffffffff81524000 29e0     coretemp.ko
 3    1 0xffffffff81527000 70b8     acpi_video.ko
 4    1 0xffffffff8152f000 c824e0   nvidia.ko
 5    3 0xffffffff821b2000 484f8    linux.ko
 6    3 0xffffffff821fb000 59a80    vboxdrv.ko
 7    1 0xffffffff82255000 6668     sem.ko
 8    1 0xffffffff8225c000 8518     ng_ubt.ko
 9    7 0xffffffff82265000 15330    netgraph.ko
10    2 0xffffffff8227b000 13278    ng_hci.ko
11    4 0xffffffff8228f000 2f98     ng_bluetooth.ko
12    1 0xffffffff82292000 16538    ng_l2cap.ko
13    1 0xffffffff82412000 3dff     linprocfs.ko
14    1 0xffffffff82416000 697e     if_lagg.ko
15    2 0xffffffff8241d000 2951     vboxnetflt.ko
16    1 0xffffffff82420000 1579     ng_ether.ko
17    1 0xffffffff82422000 3fea     vboxnetadp.ko
18    1 0xffffffff82426000 1695e    ng_btsocket.ko
19    1 0xffffffff8243d000 a9bb     fuse.ko
```
According `kldstat` all the appropriate modules are loaded.

Ok. Now I build my kernel w*hi*ch I use always and to be sure `kldstat` returns me the same results. Ok. I am going to build it with this option.


----------



## jozze (May 18, 2013)

Oh, right, your `# dmesg` stated you have 9.1-RELEASE and are running GENERIC. I don't think rebuilding the kernel will help much, since GENERIC has these things working. Your Logitech is recognized, so that's OK too, and those `pipe 2' messages are from Flash.

So it's not the world/kernel, but the configuration.


----------



## sk8harddiefast (May 18, 2013)

W*hi*ch I have no idea how to configure it and handbook really not helping. But to be more sure I enable 
	
	



```
device udbp
```
 in my custom kernel. Nothing to lose.

Ok. Compiling my custom kernel with `device udbp` I get compile error.


```
udbp.o: In function `udbp_bulk_read_complete':
/usr/src/sys/dev/usb/misc/udbp.c:496: undefined reference to `ng_package_data'
/usr/src/sys/dev/usb/misc/udbp.c:496: undefined reference to `ng_address_hook'
/usr/src/sys/dev/usb/misc/udbp.c:496: undefined reference to `ng_snd_item'
udbp.o: In function `ng_udbp_rmnode':
/usr/src/sys/dev/usb/misc/udbp.c:755: undefined reference to `ng_unref_node'
/usr/src/sys/dev/usb/misc/udbp.c:761: undefined reference to `ng_make_node_common'
/usr/src/sys/dev/usb/misc/udbp.c:768: undefined reference to `ng_name_node'
/usr/src/sys/dev/usb/misc/udbp.c:771: undefined reference to `ng_unref_node'
udbp.o: In function `ng_udbp_rcvdata':
/usr/src/sys/dev/usb/misc/udbp.c:706: undefined reference to `ng_free_item'
/usr/src/sys/dev/usb/misc/udbp.c:710: undefined reference to `ng_free_item'
udbp.o: In function `ng_udbp_rcvmsg':
/usr/src/sys/dev/usb/misc/udbp.c:688: undefined reference to `ng_free_item'
/usr/src/sys/dev/usb/misc/udbp.c:689: undefined reference to `M_NETGRAPH_MSG'
/usr/src/sys/dev/usb/misc/udbp.c:657: undefined reference to `M_NETGRAPH_MSG'
/usr/src/sys/dev/usb/misc/udbp.c:688: undefined reference to `ng_address_ID'
/usr/src/sys/dev/usb/misc/udbp.c:688: undefined reference to `ng_snd_item'
udbp.o: In function `udbp_modload':
/usr/src/sys/dev/usb/misc/udbp.c:281: undefined reference to `ng_rmtype'
udbp.o:(.rodata+0x1d0): undefined reference to `ng_parse_int32_type'
udbp.o:(.rodata+0x200): undefined reference to `ng_parse_struct_type'
udbp.o:(.rodata+0x248): undefined reference to `ng_parse_int32_type'
udbp.o:(.rodata+0x260): undefined reference to `ng_parse_int32_type'
*** [kernel.debug] Error code 1

Stop in /usr/obj/usr/src/sys/MYKERNEL.
*** [buildkernel] Error code 1

Stop in /usr/src.
*** [buildkernel] Error code 1

Stop in /usr/src.
```

Is this option really necessary? If yes, why does it fail to build?


----------



## jozze (May 18, 2013)

Enabling [cmd=""]device udbp[/cmd] was a guess. In my opinion it's not the kernel, but the configuration of your Bluetooth device, that needs fixing.

Look what I found:
http://lists.freebsd.org/pipermail/freebsd-wireless/2012-December/002695.html,
http://freebsd.1045724.n5.nabble.com/problem-with-bluetooth-dongle-td4058134.html

Like the *seco*nd link suggested, try to find your device not as the /dev/ubt0, but try if it has a node in the netgraph(4) with `# ngctl list`. So, if the device node is there, I don't really know where to go from there. See ngctl(8), or nghook(8). With these two you should be able to make some sort of "physical" entry in the /dev, I hope.

EDIT: I would try to do that with nghook(8).


----------



## sk8harddiefast (May 18, 2013)

Reading this and all you send:


> In this how-to, I am using ubt0 as the name of your bluetooth device. Change that part if it something else (ubt1 for example). I am also using 00:0d:93:1b:89:75 as the device address. Change that to your own device(s). Note: I have only tested this with FreeBSD 7.0-stable.
> 
> you need to have the driver for the bluetooth hardware loaded. In my case, it is a usb-based bluetooth adapter, so I need to load the ng_ubt driver. Putting ng_ubt_load="YES" in /boot/loader.conf fixes that.
> Use hccontrol -n ubt0hci inquiry to list all the devices available
> ...



Everywhere I'm st*u*ck in the second step. Even with the Handbook


```
[ember@Unix ~]$ hccontrol inquiry
hccontrol: Could not find HCI nodes
[ember@Unix ~]$ hccontrol -n ubt0hci inquiry
hccontrol: Could not find HCI nodes
[ember@Unix ~]$ hccontrol read_node_list    
hccontrol: Could not find HCI nodes
```

Just refuses to get the list of the devices. In this case to see the keyboard. If I don't get the address of the keyboard I can't do the next step*.*


----------



## jozze (May 18, 2013)

I just checked some specs for your keyboard, and I must say, it looks really awesome in both looks and specifications! The keyboard uses bluetooth v3, while FreeBSD ng_ubt(4)() (also in handbook) supports v1.1. I think Bluetooth v3 should be backwards compatible with v1.1, but there has to be some trick behind it.

I'm sorry I couldn't be more helpful . Maybe someone else will be able to help you more.

Good luck!


----------



## sk8harddiefast (May 18, 2013)

It's ok. At least you made the best you could. Maybe someone else will help me too. Thanks @jozze.


----------



## jozze (May 18, 2013)

Oh, just one final word -- @baos had a similar problem, and managed to fix it in a very robust way. Check this out http://forums.freebsd.org/showthread.php?p=220294#post220294. His `# dmesg` however gave him a ubt entry, so it might not work for you. However, he also didn't get his ubt device listed in /dev.

Perhaps you can create a symbolic link, instead of copying it.


----------



## cpm@ (May 18, 2013)

ng_ubt(4)() driver supports BCM20702A0 chipset. See r244704.

You need apply the following patch to add support.

See also for detailed information:

http://lists.freebsd.org/pipermail/freebsd-bugs/2012-December/051280.html.

http://www.freebsd.org/cgi/query-pr.cgi?pr=174707&cat=.


----------



## sk8harddiefast (May 18, 2013)

http://www.freebsd.org/cgi/query-pr.cgi?pr=174707&cat=

According to this I must patch netgraph/bluetooth/drivers/ubt/ng_ubt.c. Right? How to do that?


----------



## cpm@ (May 18, 2013)

sk8harddiefast said:
			
		

> According this I must patch netgraph/bluetooth/drivers/ubt/ng_ubt.c
> Right? How to do that?



Do the following:

```
# cd /usr/src/sys/netgraph/bluetooth/drivers/ubt/
# fetch -o ng_ubt-bcm-entries.diff 'http://www.freebsd.org/cgi/query-pr.cgi?pr=174707;cat=&getpatch=1'
# patch -p0 < ng_ubt-bcm-entries.diff
# make
# make install clean
# kldload ng_ubt
```


----------



## sk8harddiefast (May 18, 2013)

```
cd /usr/src/sys/modules/netgraph/bluetooth/ubt && make && make install clean
```
I can't `make`

```
No target to make
```

Ok. ubt shown on `dmesg`. Thanks bro!


----------



## cpm@ (May 18, 2013)

As @jozze said in post #21, follows the thread to complete the installation.

You're welcome


----------



## sk8harddiefast (May 18, 2013)

Now I am going to try the rest of the steps*.*

`cp /etc/defaults/bluetooth.device.conf /etc/bluetooth/ubt0.conf` and `sudo service bluetooth start ubt0`. Now just run. But now `hccontrol -n ubt0hci inquiry` returns

```
Inquiry complete. Status: No error [00]
```

My keyboard is open. Scans but does not find it*.*


----------



## cpm@ (May 18, 2013)

Need be installed bthidcontrol(8)() and bthidd(8)()

```
# cd /usr/src/usr.sbin/bluetooth/bthidcontrol
# make && make install
# cd /usr/src/usr.sbin/bluetooth/bthidd
# make && make install
```

Probably you need load the vkbd(4)() driver.

Add these lines to /etc/rc.conf: 

```
hcsecd_enable="YES" 
sdpd_enable="YES"
```

Please, follow the Section 32.4 Bluetooth.


----------



## sk8harddiefast (May 18, 2013)

I have added this lines to /etc/rc.conf

```
hcsecd_enable="YES" 
sdpd_enable="YES"
```

Also 
	
	



```
device  atkbdc
```
 is enabled *i*n my kernel*.*. Returns the same result*.* I tried a lot and followed exactly that the handbook says. Just the commands return the wrong results.

Ok. Next step, I add *i*n /etc/rc.conf

```
bthidd_enable="YES"
```
and I copied the configuration file, `cp /usr/src/usr.sbin/bluetooth/bthidd/bthidd.conf.sample /etc/bluetooth/bthidd.conf`.

And now on boot I get

```
May 18 18:51:52 Unix bthidd[2565]: Could not connect to 00:50:f2:e3:fb:e1. Host is down (64)
May 18 18:52:02 Unix bthidd[2565]: Could not connect to 00:50:f2:e5:68:84. Host is down (64)
kbd3 at vkbd1
May 18 18:52:22 Unix bthidd[2565]: Could not connect to 00:50:f2:e3:fb:e1. Host is down (64)
```
What?


----------



## cpm@ (May 18, 2013)

Show both outputs  `# service bluetooth start ubt0` and `% hccontrol -n ubt0hci inquiry`

*Note that your keyboard should be turned ON.


----------



## sk8harddiefast (May 18, 2013)

I get exactly this:

```
[ember@Unix /usr/home/ember]$ hccontrol -n ubt0hci inquiry
Inquiry complete. Status: No error [00]
[ember@Unix /usr/home/ember]$
```
and

```
[ember@Unix /usr/home/ember]$ sudo service bluetooth start ubt0
Password:
/etc/rc.d/bluetooth: ERROR: Unable to setup Bluetooth stack for device ubt0
[ember@Unix /usr/home/ember]$ sudo service bluetooth start ubt0
[ember@Unix /usr/home/ember]$
```

Works with the second try all the time*.* My keyboard is on.


----------



## cpm@ (May 18, 2013)

Add your device to /etc/bluetooth/hosts

```
BD_ADDR      lg-kbd
```

Add an entry to the /etc/bluetooth/hcsecd.conf file:

```
device {
        bdaddr  BD_ADDR;
        name    "lg-kbd";
        key     nokey;
        pin     "1234";
}
```

Edit /etc/bluetooth/ubt0.conf

```
authentication_enable="NO"
connectable="YES"
discoverable="YES"
hci_debug_level="4"
l2cap_debug_level="4"
local_name="lg"
role_switch="YES"
```

`# service bluetooth restart ubt0`
`# service hcsecd restart`

Note that BD_ADDR in the output are 6 hexadecimal bytes separated by colons.


----------



## sk8harddiefast (May 18, 2013)

I made it without success. On boot I get tons of errors:

```
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
kbd3 at vkbd7
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=4
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=12
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=4
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=4
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=4
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=4
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=4
ng_l2cap_lower_rcvmsg: ubt0l2cap - HCI node is up, bdaddr: 0:2:72:32:f1:29, pkt_size=1021 bytes, num_pkts=8
kbd3 at vkbd8
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
kbd3 at vkbd9
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
kbd3 at vkbd10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
kbd3 at vkbd11
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
kbd3 at vkbd12
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
kbd3 at vkbd13
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=4
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
ng_hci_process_event: ubt0hci - got HCI event=0x4, length=10
ng_hci_process_event: ubt0hci - got HCI event=0xf, length=4
ng_hci_process_event: ubt0hci - got HCI event=0x12, length=8
ng_hci_process_event: ubt0hci - got HCI event=0x3, length=11
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=6
ng_hci_process_event: ubt0hci - got HCI event=0x17, length=6
ng_hci_process_event: ubt0hci - got HCI event=0xe, length=10
ng_hci_process_event: ubt0hci - got HCI event=0x5, length=4
ng_l2cap_con_fail: ubt0l2cap - ACL connection failed, result=19
ng_hci_lp_discon_ind: ubt0hci - SCO hook is not connected or not valid, hook=0
```


----------



## cpm@ (May 18, 2013)

Comment this lines in /etc/bluetooth/ubt0.conf to hide those messages.

```
hci_debug_level="4"
l2cap_debug_level="4"
```


----------



## sk8harddiefast (May 18, 2013)

Ok. I Made it. Still the keyboard is not working. What's wrong?


----------



## cpm@ (May 18, 2013)

The problem is that you don't have configured bthidd.conf

To figure out the name of the bluetooth HCI node, running:
`# hccontrol read_node_list`

The node name will be something like 'ubt0hci', replace HCI_NODE_name below with this name.
`# hccontrol -n HCI_NODE_name inquiry`

If fails again try running `# hccontrol -n HCI_NODE_name read_BD_ADDR`

You need to register the device with bthidd(8)()
`# bthidcontrol -a BD_ADDR query >> /etc/bluetooth/bthidd.conf`

Modify too the BD_ADDR in the following files:
/etc/bluetooth/hosts
/etc/bluetooth/hcsecd.conf


----------



## sk8harddiefast (May 18, 2013)

Here is the problem. `hccontrol read_node_list` returns 
	
	



```
Name            ID       Num hooks
ubt0hci         00000033         3
```
 so *I* run `hccontrol -n ubt0hci inquiry` and this  returns 
	
	



```
Inquiry complete. Status: No error [00]
```

Finally I tried `hccontrol -n HCINODE Read_BD_ADDR` and the result was 
	
	



```
Could not execute command "Read_BD_ADDR". Operation timed out
```

It doesn't return the BD_ADDR


----------



## cpm@ (May 18, 2013)

Try `# hccontrol -n ubt0hci read_BD_ADDR`


----------



## sk8harddiefast (May 18, 2013)

Yes. Now I got it.

```
BD_ADDR: 00:02:72:32:f1:29
```


----------



## sk8harddiefast (May 18, 2013)

Running command as root. As user I get *Permission denied*

```
[CMD]bthidcontrol -a 00:02:72:32:f1:29 query >> /etc/bluetooth/bthidd.conf[/CMD]
Could not perform SDP query on the device 00:02:72:32:f1:29. No route to host (65)
```


----------



## cpm@ (May 18, 2013)

Run as root or using sudo(8). 

Be sure you have changed hosts and hcsecd.conf files and is loaded vkbd(4)().

Show output `# bthidcontrol -a lg-kbd query`


----------



## sk8harddiefast (May 18, 2013)

```
[ember@Unix /etc/bluetooth]$ sudo bthidcontrol -a 00:02:72:32:f1:29 query >> /etc/bluetooth/bthidd.conf
bash: /etc/bluetooth/bthidd.conf: Permission denied
```
and

```
[ember@Unix /etc/bluetooth]$ su root
Password:
You have mail.
root@Unix:/etc/bluetooth # bthidcontrol -a 00:02:72:32:f1:29 query >> /etc/bluetooth/bthidd.conf
Could not perform SDP query on the device 00:02:72:32:f1:29. No route to host (65)
root@Unix:/etc/bluetooth #
```
Tried both. How must I write? Just open the file and add the line. I have already changed both hosts and hcsecd.conf

hosts

```
00:02:72:32:f1:29 lg-kbd
```
and
hcsecd.conf

```
device {
        bdaddr  00:02:72:32:f1:29;
        name    "lg-kbd";
        key     nokey;
        pin     "1234";
}
```


----------



## cpm@ (May 18, 2013)

If it shows the following error message

```
Could not perform SDP query on the device 00:02:72:32:f1:29. No route to host (65)
```
this is because stack was not set properly and as far as system concerns you don't have active bluetooth devices. Let's ignore for now bthidd.conf because need be debugged with hcidump(1).

Restart bluetooth, hcsecd and sdpd:

`# service bluetooth restart ubt0`
`# service hcsecd restart`
`# service sdpd restart`
`# service bthidd restart`


----------



## sk8harddiefast (May 19, 2013)

```
[ember@Unix ~]$ sudo service bluetooth restart ubt0
Password:
[ember@Unix ~]$ sudo service hcsecd restart
Stopping hcsecd.
Waiting for PIDS: 4194.
Starting hcsecd.
[ember@Unix ~]$ sudo service sdpd restart
Stopping sdpd.
Starting sdpd.
[ember@Unix ~]$
```
Ok. Done! No errors


----------



## cpm@ (May 19, 2013)

Install comms/hcidump and see what is going on.

Run `# hcidump -x`, and then in a second terminal run `# bthidcontrol -a lg-kbd Query`

Please, show both outputs.


----------



## sk8harddiefast (May 19, 2013)

```
sudo bthidcontrol -a lg-kbd Query
Could not perform SDP query on the device 00:02:72:32:f1:29. No route to host (65)
```
*and*

```
[ember@Unix /usr/ports/comms/hcidump]$ sudo hcidump -x
HCIDump - HCI packet analyzer ver 1.5
device: any snap_len: 65535 filter: 0xffffffffffffffff
< HCI Command: Create Connection(0x01|0x0005) plen 13
  84 68 E5 F2 50 00 18 CC 00 00 00 00 01 
> HCI Event: Command Status(0x0f) plen 4
  00 01 05 04 
> HCI Event: Connect Complete(0x03) plen 11
  04 0C 00 84 68 E5 F2 50 00 01 00 
< HCI Command: Create Connection(0x01|0x0005) plen 13
  E1 FB E3 F2 50 00 18 CC 00 00 00 00 01 
> HCI Event: Command Status(0x0f) plen 4
  00 01 05 04 
> HCI Event: Connect Complete(0x03) plen 11
  04 0C 00 E1 FB E3 F2 50 00 01 00 
< HCI Command: Create Connection(0x01|0x0005) plen 13
  84 68 E5 F2 50 00 18 CC 00 00 00 00 01 
> HCI Event: Command Status(0x0f) plen 4
  00 01 05 04 
> HCI Event: Connect Complete(0x03) plen 11
  04 0C 00 84 68 E5 F2 50 00 01 00 
< HCI Command: Create Connection(0x01|0x0005) plen 13
  E1 FB E3 F2 50 00 18 CC 00 00 00 00 01 
> HCI Event: Command Status(0x0f) plen 4
  00 01 05 04
```


----------



## cpm@ (May 19, 2013)

I've seen that Logitech Bluetooth Keyboard K810 works on Linux. I recommend you to file a PR on freebsd-bluetooth mailing list to get support.


----------



## sk8harddiefast (May 21, 2013)

I sen*t* mail here: freebsd-bluetooth@freebsd.org, but no one answered me :/


----------



## sk8harddiefast (May 27, 2013)

@cpu82, do we have any news? I really love this keyboard but I hate that it works on Mac, Xoom, iPhone, but not on my FreeBSD. I still hope.


----------



## cpm@ (Jun 2, 2013)

Can you show me the output of `# sdpcontrol -a lg-kbd search hid`?


----------



## sk8harddiefast (Jun 3, 2013)

Good morning @cpu82. Here in Greece is 9:30 in the morning, I just woke up and I drink coffee  First of all, I spoke with the developer. I didn't make it but was not his mistake. I had no Xserver and I tried to troubleshot the keyboard, using the same keyboard and sending mail with him on tablet. But I have a big progress. Here is all we made:
/etc/rc.conf

```
hcsecd_enable="YES"
sdpd_enable="YES"
bthidd_enable="YES"
```

`kldstat`

```
Id Refs Address            Size     Name
 1   52 0xffffffff80200000 1323408  kernel
 2    1 0xffffffff81524000 29e0     coretemp.ko
 3    1 0xffffffff81527000 70b8     acpi_video.ko
 4    1 0xffffffff8152f000 c824e0   nvidia.ko
 5    3 0xffffffff821b2000 484f8    linux.ko
 6    3 0xffffffff821fb000 59a80    vboxdrv.ko
 7    1 0xffffffff82255000 6668     sem.ko
 8    1 0xffffffff8225c000 8538     ng_ubt.ko
 9    8 0xffffffff82265000 15330    netgraph.ko
10    2 0xffffffff8227b000 13278    ng_hci.ko
11    4 0xffffffff8228f000 2f98     ng_bluetooth.ko
12    1 0xffffffff82292000 16538    ng_l2cap.ko
13    1 0xffffffff82412000 3dff     linprocfs.ko
14    1 0xffffffff82416000 697e     if_lagg.ko
15    1 0xffffffff8241d000 1695e    ng_btsocket.ko
16    1 0xffffffff82434000 1e29     ng_socket.ko
17    2 0xffffffff82436000 2951     vboxnetflt.ko
18    1 0xffffffff82439000 1579     ng_ether.ko
19    1 0xffffffff8243b000 3fea     vboxnetadp.ko
20    1 0xffffffff8243f000 4fb9     vkbd.ko
21    1 0xffffffff82444000 a9bb     fuse.ko
```

`hccontrol inquiry`

```
Inquiry result, num_responses=1
Inquiry result #0
	BD_ADDR: lg-kbd
	Page Scan Rep. Mode: 0x1
	Page Scan Period Mode: 00
	Page Scan Mode: 00
	Class: 00:25:40
	Clock offset: 0x5d4a
Inquiry complete. Status: No error [00]
```

/etc/bluetooth/hosts

```
hcsecd.conf       hcsecd.conf_back  hosts             
[ember@Unix ~]$ more /etc/bluetooth/hosts 
# $Id: hosts,v 1.1 2003/05/21 17:48:40 max Exp $
# $FreeBSD: release/9.1.0/etc/bluetooth/hosts 152286 2005-11-10 19:09:22Z emax $
#
# Bluetooth Host Database
#
# This file should contain the Bluetooth addresses and aliases for hosts.
#
# BD_ADDR               Name [ alias0 alias1 ... ]

# 00:11:22:33:44:55     phone

00:1f:20:4d:f2:c5 lg-kbd
```

/etc/bluetooth/hcsecd.conf

```
# $Id: hcsecd.conf,v 1.1 2003/05/26 22:50:47 max Exp $
# $FreeBSD: release/9.1.0/etc/bluetooth/hcsecd.conf 158726 2006-05-18 17:53:49Z emax $
#
# HCI security daemon configuration file
#
# Format:
#
# device {
#       option  value ;
# }
#
# Possible options and values
#
# Options       Values
# ----------------------------------
# bdaddr        xx:xx:xx:xx:xx:xx ;     - remote device BD_ADDR
# name          "any char" ;            - to set user friendly device name
# key           0x11223344 | nokey ;    - to set link key for the device
# pin           "secret" | nopin ;      - to PIN code for the device
#
# Notes:
#
#       Currently there is no way to select keys/PIN code based on which
#       local device received the request. Everything is based on remote
#       device BD_ADDR.
#
#       "nokey" means that no link key has been defined and we should
#               send Link_Key_Negative_Reply command to the device.
#
#       "nopin" means that no PIN code has been defined and we should
#               send PIN_Code_Negative_Reply command to the device
#

# Default entry is applied if no better match found
# It MUST have 00:00:00:00:00:00 as bdaddr
device {
        bdaddr  00:1f:20:4d:f2:c5;
        name    "lg-kbd";
        key     nokey;
        pin     "1234";
}
```

/etc/bluetooth/bthidd.conf

```
# $FreeBSD: release/9.1.0/usr.sbin/bluetooth/bthidd/bthidd.conf.sample 162128 2006-09-07 21:47:49Z emax $

bthidcontrol -a 00:1f:20:4d:f2:c5 Query
device {
	bdaddr			00:1f:20:4d:f2:c5;
	control_psm		0x11;
	interrupt_psm		0x13;
	reconnect_initiate	true;
	battery_power		true;
	normally_connectable	true;
	hid_descriptor		{
		0x05 0x01 0x09 0x06 0xa1 0x01 0x85 0x01 
		0x75 0x01 0x95 0x08 0x05 0x07 0x19 0xe0 
		0x29 0xe7 0x15 0x00 0x25 0x01 0x81 0x02 
		0x95 0x01 0x75 0x08 0x81 0x03 0x95 0x05 
		0x75 0x01 0x05 0x08 0x19 0x01 0x29 0x05 
		0x91 0x02 0x95 0x01 0x75 0x03 0x91 0x03 
		0x95 0x06 0x75 0x08 0x15 0x00 0x26 0xff 
		0x00 0x05 0x07 0x19 0x00 0x29 0xff 0x81 
		0x00 0xc0 0x05 0x0c 0x09 0x01 0xa1 0x01 
		0x85 0x02 0x15 0x00 0x25 0x01 0x75 0x01 
		0x95 0x14 0x0a 0x94 0x01 0x0a 0x92 0x01 
		0x0a 0x83 0x01 0x0a 0x23 0x02 0x0a 0x8a 
		0x01 0x0a 0x82 0x01 0x0a 0x21 0x02 0x0a 
		0x30 0x00 0x0a 0x25 0x02 0x0a 0x23 0x02 
		0x0a 0x27 0x02 0x09 0xb6 0x09 0xb5 0x09 
		0xb8 0x09 0xcd 0x09 0xe9 0x09 0xea 0x09 
		0xe2 0x0a 0x24 0x02 0x09 0x30 0x81 0x02 
		0x95 0x01 0x75 0x04 0x81 0x03 0xc0 0x05 
		0x0c 0x09 0x01 0xa1 0x01 0x85 0x03 0x05 
		0x01 0x09 0x06 0xa1 0x02 0x05 0x06 0x09 
		0x20 0x15 0x00 0x26 0x14 0x00 0x75 0x08 
		0x95 0x01 0x81 0x02 0xc0 0xc0 0x05 0x01 
		0x09 0x80 0xa1 0x01 0x85 0x04 0x15 0x00 
		0x25 0x01 0x75 0x01 0x95 0x02 0x09 0x81 
		0x09 0x82 0x81 0x02 0x95 0x01 0x75 0x06 
		0x81 0x03 0xc0 0x05 0x0c 0x09 0x01 0xa1 
		0x01 0x85 0x05 0x05 0x01 0x09 0x06 0xa1 
		0x02 0x06 0x00 0xff 0x25 0x01 0x75 0x01 
		0x95 0x02 0x0a 0x03 0xfe 0x0a 0x04 0xfe 
		0x81 0x02 0x95 0x06 0x81 0x03 0xc0 0xc0 
		0x05 0x0c 0x09 0x01 0xa1 0x01 0x85 0xff 
		0x05 0x06 0x95 0x01 0x75 0x02 0x19 0x24 
		0x29 0x26 0x81 0x02 0x75 0x06 0x81 0x01 
		0xc0 0x06 0x00 0xff 0x09 0x01 0xa1 0x01 
		0x85 0x10 0x75 0x08 0x95 0x06 0x15 0x00 
		0x26 0xff 0x00 0x09 0x01 0x81 0x00 0x09 
		0x01 0x91 0x00 0xc0 0x06 0x00 0xff 0x09 
		0x02 0xa1 0x01 0x85 0x11 0x75 0x08 0x95 
		0x13 0x15 0x00 0x26 0xff 0x00 0x09 0x02 
		0x81 0x00 0x09 0x02 0x91 0x00 0xc0 
	};
}
```

`bthidcontrol Known`

```
00:1f:20:4d:f2:c5 lg-kbd
```

`hcidump -x`

```
HCIDump - HCI packet analyzer ver 1.5
device: any snap_len: 65535 filter: 0xffffffffffffffff
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01 
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00 
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04 
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00 
> HCI Event: Connect Complete(0x03) plen 11
  00 0C 00 C5 F2 4D 20 1F 00 01 00 
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0C 00 05 00 
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0C 00 
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
> HCI Event: Disconn Complete(0x05) plen 4
  00 0C 00 13
```

Is pairing incomplete? I have no pin request on `hcidup`


----------



## cpm@ (Jun 3, 2013)

This look good 

Add this line in /boot/loader.conf

```
vkbd_load="YES"
```

Be sure you've added in /etc/rc.conf

```
devd_enable="YES"
hcsecd_enable="YES"
sdpd_enable="YES"
bthidd_enable="YES"
bthidd_config="/etc/bluetooth/bthidd.conf"
bthidd_hids="/var/db/bthidd.hids"
```

To pairing your BT device: turn on your keyboard (set discoverable), enter the PIN, then press ENTER. If it doesn't work the first time, try again.


----------



## sk8harddiefast (Jun 4, 2013)

Ok. I made it except the last one. The developer told me to remove /var/db/bthidd.hids
This is my `hcidump -x` now:


```
HCIDump - HCI packet analyzer ver 1.5
device: any snap_len: 65535 filter: 0xffffffffffffffff
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01 
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00 
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04 
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00 
> HCI Event: Connect Complete(0x03) plen 11
  00 0C 00 C5 F2 4D 20 1F 00 01 00 
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0C 00 05 00 
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0C 00 
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
> HCI Event: Disconn Complete(0x05) plen 4
  00 0C 00 13 
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01 
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00 
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04 
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00 
> HCI Event: Connect Complete(0x03) plen 11
  00 0B 00 C5 F2 4D 20 1F 00 01 00 
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0B 00 05 00 
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0B 00 
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
> HCI Event: Disconn Complete(0x05) plen 4
  00 0B 00 13 
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01 
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00 
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04 
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00 
> HCI Event: Connect Complete(0x03) plen 11
  00 0C 00 C5 F2 4D 20 1F 00 01 00 
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0C 00 05 00 
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0C 00 
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
> HCI Event: Disconn Complete(0x05) plen 4
  00 0C 00 13 
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01 
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00 
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04 
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00 
> HCI Event: Connect Complete(0x03) plen 11
  00 0B 00 C5 F2 4D 20 1F 00 01 00 
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0B 00 05 00 
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0B 00 
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
> HCI Event: Disconn Complete(0x05) plen 4
  00 0B 00 13 
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01 
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00 
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04 
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00 
> HCI Event: Connect Complete(0x03) plen 11
  00 0C 00 C5 F2 4D 20 1F 00 01 00 
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0C 00 05 00 
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0C 00 
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
> HCI Event: Disconn Complete(0x05) plen 4
  00 0C 00 13 
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01 
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00 
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04 
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00 
> HCI Event: Connect Complete(0x03) plen 11
  00 0B 00 C5 F2 4D 20 1F 00 01 00 
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0B 00 05 00 
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0B 00 
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
> HCI Event: Disconn Complete(0x05) plen 4
  00 0B 00 13 
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01 
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00 
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04 
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00 
> HCI Event: Connect Complete(0x03) plen 11
  00 0C 00 C5 F2 4D 20 1F 00 01 00 
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0C 00 05 00 
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0C 00 
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
> HCI Event: Disconn Complete(0x05) plen 4
  00 0C 00 13 
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01 
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00 
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04 
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00 
> HCI Event: Connect Complete(0x03) plen 11
  00 0B 00 C5 F2 4D 20 1F 00 01 00 
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0B 00 05 00 
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0B 00 
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00 
> HCI Event: Disconn Complete(0x05) plen 4
  00 0B 00 13
```

No pin request. This is the only think that I don't love on FreeBSD. You must die before some things going to work.


----------



## cpm@ (Jun 4, 2013)

As stated in the bluetooth specification document, the Link Key Request Negative Reply command is used to reply to a Link Key Request event from the controller if the host does not have a stored Link Key for the connection with the other Bluetooth device specified by BD_ADDR.

```
<snip>
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00 
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00 
<snip>
```

In order to perform authentication: if there is a match in the database, the key will be returned in the Link Key Request Reply command. In case there is no match in the database, the Link Key Request Negative Reply will be sent.

Try the following:

```
# service hcsecd stop
# rm /var/db/hcsecd.keys
# service hcsecd start
```


----------



## sk8harddiefast (Jun 4, 2013)

Still no difference.
`hcidup -x` returns the same


----------



## Anil-G (Jun 28, 2013)

Thanks @cpu82 and @sk8harddiefast for going through this.

I'd just like to note all worked for me to get Targus ACB75AU Bluetooth 4.0 dual-mode micro _USB_ adapt_e_r device recognised.

However, I found I had to change directories to get things working seamlessly. I patched from /usr/src/sys and I built (make) from /usr/src/sys/modules/netgraph/bluetooth/ubt.

On reboot the Targus USB adapter should be recognised as a Broadcom Bluetooth device without any problems:

```
> grep broadcom /var/run/dmesg.boot
  ugen0.2: <Broadcom Corp> at usbus0
  ubt0: <Broadcom Corp BCM20702A0, rev 2.00/1.12, addr 2> on usbus0
> dmesg | grep ubt
  ubt0: <Broadcom Corp BCM20702A0, rev 2.00/1.12, addr 2> on usbus0
> usbconfig -u 0 -a 2 dump_device_desc
  . . .
  ugen0.2: <BCM20702A0 Broadcom Corp> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
  idVendor = 0x0a5c
  idProduct = 0x21e8
  bcdDevice = 0x0112
  iManufacturer = 0x0001  <Broadcom Corp>
  iProduct = 0x0002  <BCM20702A0>
  iSerialNumber = 0x0003  <00190E11B461>
  . . .
```

References:

http://www.freebsd.org/doc/handbook/network-bluetooth.html
http://forums.freebsd.org/showthread.php?t=39679&highlight=bluetooth
http://forums.freebsd.org/showthread.php?p=220294#post220294

Some relevant paths:

/usr/src/sys/netgraph/bluetooth/drivers/ubt
/usr/src/sys/modules/netgraph/bluetooth/ubt

By the way, Targus Australia support stepped out and confirmed their device would be supported by FreeBSD (because of the chipset) pre sales. Well done, Targus.


----------



## Anil-G (Jul 9, 2013)

Thanks for working through this setup. I am now typing this message on my Logitech K810 Bluetooth keyboard thanks to this instruction. I didn't have to build anything though, and it worked with the GENERIC kernel.

I also had to buy a new Bluetooth USB adapter but the Targus ACB75AU BluetoothÂ® 4.0 Micro USB Adapter was only $23 from Officeworks. Targus Australia support also confirmed to me prior to purchase that the ACB75AU was a FreeBSD supported chipset, as well. Well done Targus Australia.

To finish off the thread above as well, several attempts at pairing failed and I was wondering if there was something else I needed to do. _The k_eyboard was obviously available for pairing but was not connecting. I rechecked the configuration files but all was good so I switched the keyboard off and on one more time and then typed the PIN and the Bluetooth light suddenly went solid: paired! So just try a few times if you're having trouble pairing.


----------



## Anil-G (Jul 11, 2013)

In case it helps anyone else, I was finding my keyboard did not pair now that I'd set up all the configuration files, even though I was typing on it a few days ago.

I stopped the Bluetooth service with `service bluetooth stop ubt0` and then restarted it with  `service bluetooth start ubt0` and found that hcsecd was no longer running. So I started hcsecd but using _the_ -d flag to keep it connected to the console to observe: `/usr/sbin/hcsecd -d -f /etc/bluetooth/hcsecd.conf`

I then found 
	
	



```
syntax error on line 45
```
 checked my hcsecd.conf and found that I had missed a semi-colon!


----------



## Anil-G (Jul 13, 2013)

I've posted in a separate thread because I thought I had a different problem http://forums.freebsd.org/showthread.php?t=40779 but I'll continue here.

I was finding that after all set up described in this thread my keyboard did pair _once_ but then stopped pairing.

I double and triple checked all my setup and it was just as described here. Some setting up was not required such as the /boot/loader.conf entry to load the vkbd module because `kldstat -v | grep vkbd` showed it was already there.

Eventually I ran `hcsecd` and `bthidd` in the foreground and found the following output when attempting to pair. I hope the following information is going to be useful here.

```
# service bthidd stop
# bthidcontrol -a 00:1f:20:75:7c:75 forget
# /usr/sbin/bthidd -d -c /etc/bluetooth/bthidd.conf -H /var/db/bthidd.hids -p /var/run/bthidd.pid

bthidd[2344]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
kbd3 at vkbd9
bthidd[2344]: Could not connect to 00:1f:20:75:7c:75. Host is down (64)
Jul 12 00:46:44 engine bthidd[2344]: Could not connect to 00:1f:20:75:7c:75. Host is down (64)
bthidd[2344]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
kbd3 at vkbd10
bthidd[2344]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 12 00:47:22 engine bthidd[2344]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
bthidd[2344]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
kbd3 at vkbd11
bthidd[2344]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 12 00:47:59 engine bthidd[2344]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
```

I gave up but today I attempted again by removing all Bluetooth related data in /var/db and setting the hcsecd.conf device entry to nopin. The keyboard still didn't pair. But I left the workstation for some minutes (maybe half an hour) and when I came back it was paired! Here are the messages I got:

```
Jul 13 20:21:29 engine bthidd[1987]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 13 20:21:29 engine kernel: kbd3 at vkbd53
Jul 13 20:21:30 engine bthidd[1987]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 13 20:21:49 engine bthidd[1987]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 13 20:21:49 engine kernel: kbd3 at vkbd54
Jul 13 20:21:50 engine bthidd[1987]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 13 20:22:09 engine bthidd[1987]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 13 20:22:09 engine kernel: kbd3 at vkbd55
Jul 13 20:22:10 engine bthidd[1987]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 13 20:22:29 engine bthidd[1987]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 13 20:22:29 engine kernel: kbd3 at vkbd56
Jul 13 20:22:30 engine bthidd[1987]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 13 20:22:49 engine bthidd[1987]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 13 20:22:49 engine kernel: kbd3 at vkbd57
Jul 13 20:22:51 engine bthidd[1987]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 13 20:23:09 engine bthidd[1987]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 13 20:23:09 engine kernel: kbd3 at vkbd58
Jul 13 20:23:09 engine bthidd[1987]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 13 20:23:29 engine bthidd[1987]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 13 20:23:29 engine kernel: kbd3 at vkbd59
Jul 13 20:23:34 engine bthidd[1987]: Could not connect to 00:1f:20:75:7c:75. Host is down (64)
Jul 13 20:23:49 engine bthidd[1987]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 13 20:23:49 engine kernel: kbd3 at vkbd60
Jul 13 20:23:51 engine bthidd[1987]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 13 20:24:09 engine bthidd[1987]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 13 20:24:09 engine kernel: kbd3 at vkbd61
```


----------



## cpm@ (Jul 14, 2013)

Hi @Anil-G,

After digging more I found this old-thread on the freebsd-bluetooth@ mailing list which explain the meaning of above log messages and how to proceed to mute it.


----------



## Anil-G (Jul 14, 2013)

*PR needed?*



			
				cpu82 said:
			
		

> After digging more I found this old-thread on the freebsd-bluetooth@ ML which explain the meaning of above log messages and how to proceed to mute it.



Thanks very much, @cpu82, you are a really helpful guy.

Actually, I'm not worried about the logging. As your thread points out, once it's paired there will be no more logging. I like the logging because it tells me how many times pairing has been attempted and confirms that pairing attempts are continuing.

This is how I use my Logitech Bluetooth K810 currently. I've configured it with no pin to make life easier. I log in using my old keyboard, delete /var/db/hcsecd.keys and /var/db/bthidd.hids and then restart services bluetooth, hcsecd and bthidd. Then I initiate a re-pair with the K810 - press connect and wait.

The K810 starts looking for a pair and I use my old keyboard to check that pair attempts are progressing in messages. When I can see the log lines showing "connection reset by peer" repeatedly I know pairing will happen eventually. I then start work on my old keyboard until reconnect happens (takes some minutes):


```
Jul 14 15:06:28 engine bthidd[2674]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 14 15:06:46 engine bthidd[2674]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 14 15:06:46 engine kernel: kbd3 at vkbd19
Jul 14 15:06:47 engine bthidd[2674]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 14 15:07:06 engine bthidd[2674]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 14 15:07:06 engine kernel: kbd3 at vkbd20
Jul 14 15:07:07 engine bthidd[2674]: Could not connect to 00:1f:20:75:7c:75. Connection reset by peer (54)
Jul 14 15:07:26 engine bthidd[2674]: Opening outbound session for 00:1f:20:75:7c:75 (new_device=1, reconnect_initiate=1)
Jul 14 15:07:26 engine kernel: kbd3 at vkbd21
```

After that I put my old keyboard back on the shelf and continue on the USB re-chargeable compact and comfortable K810 dished keys with helpful contrasting lit glyphs.

I'm not sure if I should submit a PR for this or developer already aware of the problem through @sk8harddiefast? I presume this is not just the K810 but other Bluetooth devices must suffer this?


----------



## Anil-G (Jul 22, 2013)

I have now submitted a PR
http://www.freebsd.org/cgi/query-pr.cgi?pr=180722


----------



## sk8harddiefast (Nov 5, 2014)

After long long time I want to share my setup hoping that somehow a way will be found.

1) `cp /etc/defaults/bluetooth.device.conf /etc/bluetooth/ubt0.conf`

   Edit ubt0 configuration file


```
authentication_enable="NO"
   connectable="YES"
   discoverable="YES"
   hci_debug_level="4"
   l2cap_debug_level="4"
   local_name="lg"
   role_switch="YES"
```

2) `sudo service bluetooth start ubt0`

3) /etc/rc.conf


```
hcsecd_enable="YES"
   hcsecd_config="/etc/bluetooth/hcsecd.conf"
   sdpd_enable="YES"
   bthidd_enable="YES"
   bthidd_config="/etc/bluetooth/bthidd.conf"
```

4) /boot/loader.conf


```
vkbd_load="YES"
   ng_ubt_load="YES"
   ng_l2cap_load="YES"
```

5) install hcidump from ports

6) /etc/bluetooth/bthidd.conf


```
device {
  bdaddr  00:1f:20:4d:f2:c5;
  control_psm  0x11;
  interrupt_psm  0x13;
  reconnect_initiate  true;
  battery_power  true;
  normally_connectable  true;
  hid_descriptor  {
  0x05 0x01 0x09 0x06 0xa1 0x01 0x85 0x01
  0x75 0x01 0x95 0x08 0x05 0x07 0x19 0xe0
  0x29 0xe7 0x15 0x00 0x25 0x01 0x81 0x02
  0x95 0x01 0x75 0x08 0x81 0x03 0x95 0x05
  0x75 0x01 0x05 0x08 0x19 0x01 0x29 0x05
  0x91 0x02 0x95 0x01 0x75 0x03 0x91 0x03
  0x95 0x06 0x75 0x08 0x15 0x00 0x26 0xff
  0x00 0x05 0x07 0x19 0x00 0x29 0xff 0x81
  0x00 0xc0 0x05 0x0c 0x09 0x01 0xa1 0x01
  0x85 0x02 0x15 0x00 0x25 0x01 0x75 0x01
  0x95 0x14 0x0a 0x94 0x01 0x0a 0x92 0x01
  0x0a 0x83 0x01 0x0a 0x23 0x02 0x0a 0x8a
  0x01 0x0a 0x82 0x01 0x0a 0x21 0x02 0x0a
  0x30 0x00 0x0a 0x25 0x02 0x0a 0x23 0x02
  0x0a 0x27 0x02 0x09 0xb6 0x09 0xb5 0x09
  0xb8 0x09 0xcd 0x09 0xe9 0x09 0xea 0x09
  0xe2 0x0a 0x24 0x02 0x09 0x30 0x81 0x02
  0x95 0x01 0x75 0x04 0x81 0x03 0xc0 0x05
  0x0c 0x09 0x01 0xa1 0x01 0x85 0x03 0x05
  0x01 0x09 0x06 0xa1 0x02 0x05 0x06 0x09
  0x20 0x15 0x00 0x26 0x14 0x00 0x75 0x08
  0x95 0x01 0x81 0x02 0xc0 0xc0 0x05 0x01
  0x09 0x80 0xa1 0x01 0x85 0x04 0x15 0x00
  0x25 0x01 0x75 0x01 0x95 0x02 0x09 0x81
  0x09 0x82 0x81 0x02 0x95 0x01 0x75 0x06
  0x81 0x03 0xc0 0x05 0x0c 0x09 0x01 0xa1
  0x01 0x85 0x05 0x05 0x01 0x09 0x06 0xa1
  0x02 0x06 0x00 0xff 0x25 0x01 0x75 0x01
  0x95 0x02 0x0a 0x03 0xfe 0x0a 0x04 0xfe
  0x81 0x02 0x95 0x06 0x81 0x03 0xc0 0xc0
  0x05 0x0c 0x09 0x01 0xa1 0x01 0x85 0xff
  0x05 0x06 0x95 0x01 0x75 0x02 0x19 0x24
  0x29 0x26 0x81 0x02 0x75 0x06 0x81 0x01
  0xc0 0x06 0x00 0xff 0x09 0x01 0xa1 0x01
  0x85 0x10 0x75 0x08 0x95 0x06 0x15 0x00
  0x26 0xff 0x00 0x09 0x01 0x81 0x00 0x09
  0x01 0x91 0x00 0xc0 0x06 0x00 0xff 0x09
  0x02 0xa1 0x01 0x85 0x11 0x75 0x08 0x95
  0x13 0x15 0x00 0x26 0xff 0x00 0x09 0x02
  0x81 0x00 0x09 0x02 0x91 0x00 0xc0
  };
}
```

6) /etc/bluetooth/hcsecd.conf


```
device {
   bdaddr  00:1f:20:4d:f2:c5;
   name  "Logitech K810";
   key  nokey;
   pin  "702312";
   }
```

7) /etc/bluetooth/hosts


```
00:1f:20:4d:f2:c5 lg-kbd
```

8) `cp /dev/null /var/db/bthidd.hids`

After reboot my keyboard pairs and looking with `hcibump -x`
I get this on every click:


```
ember@FreeBSD ~ $ sudo hcidump -x
Password:
HCIDump - HCI packet analyzer ver 1.5
device: any snap_len: 65535 filter: 0xffffffffffffffff
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00
> HCI Event: Connect Complete(0x03) plen 11
  00 0B 00 C5 F2 4D 20 1F 00 01 00
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0B 00 05 00
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0B 00
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00
> HCI Event: Disconn Complete(0x05) plen 4
  00 0B 00 13
> HCI Event: Connect Request(0x04) plen 10
  C5 F2 4D 20 1F 00 40 05 00 01
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
  C5 F2 4D 20 1F 00 00
> HCI Event: Command Status(0x0f) plen 4
  00 01 09 04
> HCI Event: Role Change(0x12) plen 8
  00 C5 F2 4D 20 1F 00 00
> HCI Event: Connect Complete(0x03) plen 11
  00 0C 00 C5 F2 4D 20 1F 00 01 00
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
  0C 00 05 00
> HCI Event: Command Complete(0x0e) plen 6
  01 0D 08 00 0C 00
> HCI Event: Link Key Request(0x17) plen 6
  C5 F2 4D 20 1F 00
< HCI Command: Link Key Request Negative Reply(0x01|0x000c) plen 6
  C5 F2 4D 20 1F 00
> HCI Event: Command Complete(0x0e) plen 10
  01 0C 04 00 C5 F2 4D 20 1F 00
> HCI Event: Disconn Complete(0x05) plen 4
  00 0C 00 1
```

But the keyboard writes nothing. There is communication between keyboard and computer but it doesn't write. Sometimes randomly start working and writes!


----------



## sk8harddiefast (Nov 5, 2014)

After almost two hours finally now my keyboard connected! This post is from my Logitech K810!

The bad news is that the pair will be lost again in the next reboot.
There are three problems:

Creates a file /var/db/bthidd.conf file
Creates a file /var/db/hcsecd.keys file (I must delete them and restart the services)
Takes a long long time to pair the device
The only way I found is to set no pin option. There is still a delay but is more acceptable


----------



## lme@ (Nov 7, 2014)

Could you please report this on the freebsd-bluetooth@freebsd.org mailing list? Maybe things can get improved.


----------



## Anil-G (Nov 10, 2014)

lme@ said:


> Could you please report this on the freebsd-bluetooth@freebsd.org mailing list?



I have the same issue and use the same workaround as sk8harddiefast. Note my post in this thread where I report the PR I created: http://www.freebsd.org/cgi/query-pr.cgi?pr=180722

This is not a result of dual boot / multiple pairings confusing the keyboard. See the log messages I got as posted in this thread.


----------



## Anil-G (Jan 12, 2015)

I originally had the same bluetooth behaviour and workaround as sk8harddiefast started Thread 40779 and Thread 226685 and continued here.
But I've just got a fresh FreeBSD 10.1-RELEASE on AMD64 running and the behaviour of my bluetooth pairing has changed now. Although I still have to restart the services on every boot it reliably pairs first or second attempt (using no PIN).
I can share set up if anyone wants but I believe it's pretty much as specified here and probably the solution is in release 10.1? This is what I run on start up:
	
	



```
rm -f /var/db/bthidd.hids /var/db/hcsecd.keys
service bluetooth restart ubt0
service hcsecd restart
service bthidd restart
```


----------



## sk8harddiefast (Jan 12, 2015)

Same here. My keyboard works but after every reboot I must delete /var/db/bthidd.hids and /var/db/hcsecd.keys
and restart hcsecd and bthidd service
Also pairing to other Os makes the keyboard to lose his mind!


----------



## Anil-G (Jan 12, 2015)

I regularly pair my K810 to a Mac Mini OS X 10.6 using the F1 pairing. I don't let any other OS or device use the F3 pairing which I always switch to for FreeBSD. I don't have any problems (related to multiple OSs). I don't press the reset / connect button on the back of the keyboard.


----------



## claudiuschan (Feb 9, 2015)

Hi guys,
I also having the same issue. My mouse is logitech T630. I have to do the same thing as mentioned to remove the files and restart those processes.

According to the http://ralphm.net/blog/2013/10

Seems like logitech mouse or maybe keyboard required repairing  every time reconnect.

so my suspect is that what we have done is to force repairing, that is why the mouse will work again for second time. I hope maybe Anil-G can highlight that in your PR.


----------



## Anil-G (Feb 9, 2015)

I don't think I understand enough to comment.

Now at FreeBSD 10.1 I find that I usually don't have to wait for pairing using the workaround described.

I'd like to find some time to do a test for normal operation, in case that's working better than it used to.

I'd like to actually understand the "bluetooth handshake" better as well, and be able to trace the various servers through logs or running in foreground so I could troubleshoot the process and try to identify cause, but I don't know where to start.


----------

