Recently Added

Notes & Bookmarks

  1. Quasars; power and metrics beyond all comprehension. Staggeringly beautiful information... and very well written.
  2. "I'm sorry. I can't come in today. Religious holiday. The feast of...Maximum Occupancy."pic.twitter.com/mkgxPWfNj2
  3. Verifying myself: I am sgnls on Keybase.io. UJa01G4v3YRJYB1LFjDRSf1Nh0bh1sOykCbq / https://keybase.io/sgnls/sigs/UJa01G4v3YRJYB1LFjDRSf1Nh0bh1sOykCbq
  4. Be sure to take care of your own infrastructure(s); purge dumps, tunnel and lock-down egress transit, encrypt and permission CORRECTLY!
  5. It really doesn't matter what else gets released; Sikth's 'The Future in Whose Eyes?' is THE album of 2017. #albumoftheyear @SikthOfficialpic.twitter.com/P5houdf1yx

Automatically Connect Bluetooth Device (Linux / Logitech K810)

Updated : 16:45:21pm, 2nd Dec 2016

So, recently I got myself a new keyboard. Ultimately, I wanted something wireless and, considering I can (and do) now pair my Xperia Z1 Compact and Nexus 7 to my TV too, something I could ideally use with all three. Step up the Logitech K810.

So, all things considered, the biggest issue is the lack of a NumPad. Additionally, there is no shortcut 'key' for PgUp or PgDn (both I use heavily), but checking out this surprisingly thorough summary, I was reminded Fn+Down is a more than suitable substitute (though, less so when you have to use Shift+Fn+Down). Other than that though, it's actually a very nice keyboard to use. There's a great response to the keys and they are built so that pressure on any part of the key registers the keystroke; superb for quick touch-typing. Without question, the proximity back-light is a very smart feature too.

All gloss and fanfare aside, my main concern was getting it to pair automatically with my Asus U36SG running Fedora (3.11.10-100.fc18.x86_64) with an on-board Bluetooth chipset (of which I am yet to determine the actual model ¬¬), that the below suggests is an Intel;

[alduin@odin ~]# usb-devices 
[...]
T:  Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=8086 ProdID=0189 Rev=69.19
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
[...]

Within X, where I first connected and tested the device, it was painless. Fired up bluetoothd and used blueman-applet to do the necessary. Searching around, some people have been having issues getting their device to pair even at this stage, though in my experience (especially with this K810) it's mostly down to the device specific 'broadcast' behaviour (i.e. do you need to put the device in 'Discovery' mode each time, idle time-out etc.). Getting it to pair pre-login, especially outside of X (i.e. init 3) was more of a ballache...

I initially focused on some Bash calls in /etc/rc.d/rc.local (which I had to create and mark as executable manually) in variations such as below (the device MAC had been gauged by putting the K810 into 'Discovery' mode and running hcitool scan);

#!/bin/bash

/usr/bin/hidd server 
/usr/bin/hidd --connect 00:1F:20:EA:D5:98

exit 0

This script worked exactly as intended and would pair my device without any input but it did need the device in 'Discovery' mode (understandable as it's not 'trusted') but would not initiate on boot. I scoured /var/log/messages and subsequently tinkered with /etc/bluetooth/rfcomm.conf;

rfcomm0 {
	bind yes;
	device 00:1F:20:EA:D5:98; # k810
	channel	1;
	comment "K810 KB";
}

Yet, nothing changed and I certainly didn't see any adjustment to what I was seeing in dmesg... I'll do some further research, but it would seem that the rfcomm.conf file, despite my beliefs, is possibly overlooked? (Additionally, an update to the bluez package moved this file to rfcomm.rpmsave, so it's probably defunct.)

These noted pages certainly helped no end and pointed me in the right direction;

http://askubuntu.com/questions/538081/why-wont-my-bluetooth-keyboard-pair-with-my-desktop

http://forums.fedoraforum.org/showthread.php?t=278226

On Fedora, and I would suggest all other distros, the key, ultimately is this;

http://www.kernel.org/pub/linux/bluetooth/bluez-4.99.tar.gz

So, in short, it seems the reliable and working method was to;

  1. Identify the MAC for the intended device to be paired with hcitool scan
  2. Acquire the bluez 'tools package' (which is not in Fedora as standard and AFAIK cannot be installed via default yum repos) from kernel.org
  3. Navigate to the extracted path and into the 'test' directory
  4. Run the simple-agent script against the target MAC (n.b. At this point, it would only attempt to pair if I disabled sspmode)
  5. Enter the requested PIN on the device (n.b. I had to keystroke whilst it was in 'Discovery' mode before it prompted for the PIN input)
  6. Mark the device as 'trusted' so that it will automatically pair on boot
[alduin@odin ~]# cd bluez-4.99/test/

# Disable Secure Protection Mode
[alduin@odin ~]# sudo hciconfig hci0 sspmode 0

# Connect to Device
[alduin@odin test]# sudo ./simple-agent hci0 00:1F:20:EA:D5:98
RequestPinCode (/org/bluez/4798/hci0/dev_00_1F_20_EA_D5_98)
Enter PIN Code: 1111
Release
New device (/org/bluez/4798/hci0/dev_00_1F_20_EA_D5_98) *
* This is the file that is needed for the Bluetooth daemon(s) to register it automatically

# Trust / Connect to Device
[alduin@odin test]# sudo ./test-device trusted 00:1F:20:EA:D5:98 yes
[alduin@odin test]# sudo ./test-input connect 00:1F:20:EA:D5:98 yes

Fortunately, I now have the keyboard working instantly when the Bluetooth daemon (bluetoothd) starts up, so if you find that it's still not working, I'd suggest running less /var/log/messages and confirm that the service is set to start automatically (systemctl enable bluetoothd).

SGNLS.net © 2006-2017

Comments, submissions and errors to desk[at]sgnls.net.

Material and content adheres to the Creative Commons (NC-SA 4.0) license.

v12.01151