[HOW TO] Pair Bluetooth Devices Using Terminal When GUI Wont

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

[HOW TO] Pair Bluetooth Devices Using Terminal When GUI Wont

Postby jbb on Sat Feb 09, 2013 10:24 am

I am writing this because recently I purchased my first Bluetooth device and could not get it to work on a fresh install of Linux Mint Cinnamon 14 (64-bit). After doing a myriad of searches around the web for my particular device, I concluded that this is not just an issue with Mint, but also other Ubuntu based distributions and devices as well. While this will most likely not solve all pairing issues, hopefully the information below may be of some use to people struggling to get some (newer perhaps?) devices working.

Just before I continue, I am by no means a Linux guru; so if anyone sees something that is incorrect, or has a better understanding of what the issue is please let me know!


THE PROBLEM
When trying to use the default GUI Bluetooth connection program, gnome-control-center bluetooth, to connect my keyboard, it would always fail pairing the device even though I was entering the passkey correctly.
Part of me thought that perhaps it was a user privilege problem, so I also tried running it as su and sudo to no avail.

There were plenty of websites suggesting to select the 'do not pair' option, which would require me re-connecting the keyboard every time I restarted the computer; this was simply not an acceptable option for me. As the device I was trying to connect was my input device, it was imperative to have it setup before logging in to the desktop environment.

After a couple of hours of trying different methods with the GUI, I gave up and decided to try with the terminal instead, although I thought it would behave the same as the UI. Part of me was a little stumped as to why it is not the case??


A GLIMMER OF HOPE
After reading around numerous websites, I stumbled across this one http://devasive.blogspot.com.au/2012/11 ... iring.html which apparently would solve my problem, especially seeming this was the very keyboard I was trying to pair. Unfortunately for whatever reason, the steps on this page did not solve my problem either. In fact, in one way it actually made my problem worse, by simply giving me a time out error with no other indication of what was happening with my Bluetooth device.

Digging a little bit deeper, I started to look up the Linux Bluetooth protocol on http://www.bluez.org and learnt about a few other packages/tools that could assist with the main program. Using Synaptic I downloaded two packages that seemed like a good place to start; albeit I only ended up using one of the packages to find a fix. Maybe the other package may provide useful for people who cannot get their devices to work properly.

    bluez-tools
    Bluez-tools provides command line tools to functions of Bluetooth.
    They are Bluetooth adapter control, Bluetooth agent, sound, input, network
    and other.

    bluez-hcidump
    The hcidump utility allows the monitoring of Bluetooth activity. It
    provides a disassembly of the Bluetooth traffic and can display packets
    from higher level protocols such as RFCOMM, SDP and BNEP.

Following the guide linked above, once you type in "sudo bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX" the computer just seems to sit there for a while thinking, and then throws a timeout error. Using the 'bluez-hcidump' tool, you can see what it is actually doing; waiting for a the passkey to pair the devices. It also has the bonus of showing you the passkey, enabling you to enter it into the K810 before the connection times out.


SOLUTION
So after a little bit of reading to work out how 'bluez-hcidump' tool worked, I came up with the following solution to pair my Bluetooth device to my computer.

  • Turn on PC Bluetooth and set to discoverable
  • Turn on Bluetooth device, and set to discoverable
  • In a new terminal type:
    Code: Select all
    hcitool scan
    and copy mac address XX:XX:XX:XX:XX:XX of the device

  • Now in another terminal type (switches are for ascii output, and date stamped):
    Code: Select all
    sudo hcidump -at

  • You should get output similar to what is posted below (followed by a blinking cursor):
    HCI sniffer - Bluetooth packet analyzer ver 2.4
    device: hci0 snap_len: 1028 filter: 0xffffffffffffffff

  • Assuming the device is on 'hci0', switch back to your original terminal and type:
    Code: Select all
    sudo bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX

  • Now in the hcidump terminal you will see a few things scroll past until you get something that looks like:
    2013-02-07 15:35:40.653393 > HCI Event: User Passkey Notification (0x3b) plen 10
    bdaddr XX:XX:XX:XX:XX:XX passkey xxxxxx

  • Type the 'passkey' in and press ENTER
  • In the original terminal, on success you should get "Release" and "New device (/org/bluez/..."
  • Now set device as trusted:
    Code: Select all
    sudo bluez-test-device trusted XX:XX:XX:XX:XX:XX yes

  • You might have a connection now, but still need to:
    Code: Select all
    sudo bluez-test-input connect XX:XX:XX:XX:XX:XX

That should be it :D
jbb
Level 1
Level 1
 
Posts: 19
Joined: Wed Apr 15, 2009 10:52 pm

Linux Mint is funded by ads and donations.
 

Re: [HOW TO] Pair Bluetooth Devices Using Terminal When GUI

Postby randydevilad on Fri May 10, 2013 6:56 am

Hi i want to change over to linux mint but my logitech k810 keyboard wont pair up... im thinking just to stay with windows 7, i just read what you have done and i am totally confused as to hot to make my k810 keyboard work :((((((((( HELPPPPPPPPPPPPPPPPPPPPPP :(
randydevilad
Level 1
Level 1
 
Posts: 2
Joined: Thu May 09, 2013 1:36 pm

Re: [HOW TO] Pair Bluetooth Devices Using Terminal When GUI

Postby desQEDo on Tue Aug 06, 2013 5:25 am

Update: I found that the connection to the K810 was not consistent. I sometimes get a few intended double keystrokes dropped, even after playing with the settings which I found to be quite non-linear and therefore somewhat difficult to set as the sliders seemed to have a "tipping" point. I also did what is suggested here (http://community.linuxmint.com/tutorial/view/703) that improved things a bit by changing "hiddev*" to "hidraw*" in /lib/udev/rules.d/97-bluetooth-hid2hci.rules, which is a different file with the same function... I'm still not completely sold on the connection issue under MATE. I might try the more radical suggestion from here (viewtopic.php?t=102417&f=206) to nuke the MATE Bluetooth utility and go with Blueman when I get some time... This is al on the Asus P9X79_PRO MB with 32MB RAM running LM15 64 MATE. :roll:
The MAc K811 works perfectly OOTB with iMac, iPhone & iPad mini! :D

I just bought two of these great keyboards, one for the wife's Mac, iPad & iPhone (K811) and one (K810) for my Asus P9X79 PRO to replace a quite old (over 6 yrs) but really great diNovo Edge. The Mac was simple to pair, the PC on Linux went according to the above instructions for which my heartfelt thanks!
Sometimes though the K810 waits after keystrokes before showing input and sometimes repeats keystrokesssss when nooooot asked to... as demonsssstrated here.
Any ideas for a solution? I already tried the BT keyboard preferences Repeat Keys Delay, Speed & Bounce settings to no avail.
I have also paired the K810 with an Android SGTab 7.7 and a Mac mini and they work fine together as I don't have big demands on the Mac specific keys.
One request to help out randydevilad should he/she not yet have found a solution and to be sure myself: please say which terminal window(s) the final two commands should be executed in – at the end two are still open...
Again, many thanks!
User avatar
desQEDo
Level 1
Level 1
 
Posts: 14
Joined: Mon Jun 01, 2009 10:32 am

Re: [HOW TO] Pair Bluetooth Devices Using Terminal When GUI

Postby MarkMT on Wed Nov 20, 2013 6:27 pm

I'm having the same problem described here and the steps described by jbb sound like a possible solution. However I don't have hcidump on my system - Linux Mint 14. Apparently it's not in the repo. I tried -

sudo apt-get install bluez-hcidump

and get -

Package bluez-hcidump is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

When I try

sudo apt-get install bluez-tools

I get -

E: Unable to locate package bluez-tools

Any suggestions?
MarkMT
Level 1
Level 1
 
Posts: 19
Joined: Wed Jun 01, 2011 6:53 pm

Re: [HOW TO] Pair Bluetooth Devices Using Terminal When GUI

Postby MarkMT on Wed Nov 20, 2013 7:54 pm

Ok, I managed to solve this myself...

From this page -

https://launchpad.net/ubuntu/trusty/+so ... dump/2.5-1

I downloaded the file - bluez-hcidump_2.5.orig.tar.xz

extracted it and followed the compile instructions in the README. I was then able to follow jbb's instructions and everything proceeded as advertised. I am now typing this on my K810 :).
MarkMT
Level 1
Level 1
 
Posts: 19
Joined: Wed Jun 01, 2011 6:53 pm

Re: [HOW TO] Pair Bluetooth Devices Using Terminal When GUI

Postby WhiteListed on Sat Mar 29, 2014 5:07 pm

Hello Guys,

Just an quick update for everyone who is still trying to pair the Logitech K810 (If you are doubting: Don´t, just buy it! You will not regret!):

Follow the instructions provided here, but make sure you press the "connect" button at the rear side of the keyboard, it is not mentioned explicitly in this topic and I thought I would mention it, since there are other ways to connect to the Logitech K810.... If you have pressed the connect button succesful, all three "connection lights" start blinking. At this point, just follow the rest of the tutorial(Thanks for it BTW!).

When trying to connect by just pressing the bluetooth 1 button, there was no key pairing visible in the hcidump -at window.

Goodluck, and if you still have a question you can just PM and I will try to help you.

--WhiteListed
WhiteListed
Level 1
Level 1
 
Posts: 1
Joined: Sat Mar 29, 2014 4:58 pm


Return to Tutorials

Who is online

Users browsing this forum: Google [Bot], Znap! and 9 guests