RPi 3 bluetooth - cannot connect keyboard


40 posts   Page 1 of 2   1, 2
by alexsh1 » Wed Mar 02, 2016 3:06 pm
Hello,


When I run 'sudo bluetoothctl' command and then try to pair the keyboard I got the following:


Code: Select all
[CHG] Device 30:73:00:01:7D:1A Connected: yes
[CHG] Device 30:73:00:01:7D:1A Connected: no
[CHG] Device 30:73:00:01:7D:1A Connected: yes
[CHG] Device 30:73:00:01:7D:1A Connected: no
[CHG] Device 30:73:00:01:7D:1A Connected: yes
[CHG] Device 30:73:00:01:7D:1A Connected: no
[CHG] Device 30:73:00:01:7D:1A Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed


Anyone can me help please to setup a bluetooth keyboard?
Posts: 20
Joined: Fri Mar 06, 2015 11:24 am
by ShiftPlusOne » Wed Mar 02, 2016 3:08 pm
Not sure if this will help, but try running bluetoothctl with the -a flag.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4382
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy
by Douglas6 » Wed Mar 02, 2016 3:31 pm
It would be helpful to know what exactly you did in bluetoothctl. Did you power on the adapter? Register a pairing agent and set it as the default? Make the keyboard discoverable? Scan for the keyboard? Run the pair command? Trust the paired device? Run the connect command?
User avatar
Posts: 3874
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by alexsh1 » Wed Mar 02, 2016 7:25 pm
ShiftPlusOne wrote:Not sure if this will help, but try running bluetoothctl with the -a flag.

Thanks - this resolved the issue.

Code: Select all
[CHG] Device 30:73:00:01:7D:1A Paired: yes
Pairing successful

Posts: 20
Joined: Fri Mar 06, 2015 11:24 am
by alexsh1 » Wed Mar 02, 2016 7:28 pm
Douglas6 wrote:It would be helpful to know what exactly you did in bluetoothctl. Did you power on the adapter? Register a pairing agent and set it as the default? Make the keyboard discoverable? Scan for the keyboard? Run the pair command? Trust the paired device? Run the connect command?


Sorry - yes, I did pretty much all you mention above:
- bluetooth is powered and installed
- agent was registered and set to default
- Keyboard is discoverable
- scan on or hcitool scan performed.
- run 'pair xxxxxxxxxxxxxxxx' and got the error message
- trust was run
Posts: 20
Joined: Fri Mar 06, 2015 11:24 am
by evertheoptimist » Mon Mar 07, 2016 9:41 pm
ShiftPlusOne wrote:Not sure if this will help, but try running bluetoothctl with the -a flag.

can anyone give step by step guide on how to connect bluetooth keyboard to raspberry pi 3 with built in wi/fi bluetooth for a complete beginner, as I dont know where to start.
Thanks in advance.
Posts: 2
Joined: Sun Mar 06, 2016 12:31 am
by frankymusic » Sun Mar 13, 2016 5:02 pm
Input the following commands from a console (I'm using WinSCP and then PuTTY from my PC, but you can attach a HDMI display, an USB keyboard or so, meanwhile...)

1. bluetoothctl
2. pairable on
3. scan on
Now you have to wait, until your BT device (keyboard) is shown (don't forget to activate your keyboard now! Press the so called "pairing button" of your BT keyboard, may be a combination of two keys, see the users manual!). Don't forget to wait!!! You should see it's address as "xx:xx:xx:xx:xx:xx"
4. scan off
5. agent on
6. pair xx:xx:xx:xx:xx:xx
Now you are requested to input a number (6 digits) using your BT keyboard, and then you have to quit it by pressing the "return" button of your BT keyboard! "pairing successful" should be displayed!
7. trust xx:xx:xx:xx:xx:xx
8. connect xx:xx:xx:xx:xx:xx
"connection successful" should be displayed!
9. info xx:xx:xx:xx:xx:xx
... will show the success again (some Information are displayed).
10. exit

Reboot your RPi now.

At my "system" after any reboot (or new start at all) I have to switch on my BT keyboard not before (!) the RPi waits for the first input command, and then it takes about 2 minutes (!) until I can see the keyboard's key strokes!!! Therefore, be patiently!!!

Frank
Posts: 13
Joined: Thu Mar 03, 2016 4:09 pm
by lmoss30 » Mon Mar 14, 2016 2:55 pm
when i follow these instuctions i get

failed to connect: org.blueze.error.failed

any ideas?
Posts: 66
Joined: Mon May 28, 2012 11:45 am
by frankymusic » Mon Mar 14, 2016 4:04 pm
Hi lmoss30,

which steps can you follow without error messages?

Frank
Posts: 13
Joined: Thu Mar 03, 2016 4:09 pm
by lmoss30 » Mon Mar 14, 2016 4:05 pm
I can do right upto the connect step, it goes through

pair, trust, and when i do connect it seems to go wrong.
Posts: 66
Joined: Mon May 28, 2012 11:45 am
by frankymusic » Mon Mar 14, 2016 4:17 pm
... did you try to press the so called "pairing button" of your BT keyboard between? You should try this now...

Frank
Posts: 13
Joined: Thu Mar 03, 2016 4:09 pm
by lmoss30 » Mon Mar 14, 2016 4:27 pm
Hi Frank,

I have tried that, you have to press that button to get the keyboard into its original pairing state anyway,

The keyboard must be being seen as i have to enter a 6 digit code during the pairing stage

Regards
Lee
Posts: 66
Joined: Mon May 28, 2012 11:45 am
by frankymusic » Mon Mar 14, 2016 5:06 pm
... of course, I know! But the idea behind was, that the BT keyboard isn't patiently enough, forgets its mission because of a delay from you... ;)

No idea at the moment, sorry, my keyboard connected accurately using this method...

Frank
Posts: 13
Joined: Thu Mar 03, 2016 4:09 pm
by frankymusic » Mon Mar 14, 2016 5:15 pm
... if everything runs fine, there is an info file at
Code: Select all
/var/lib/bluetooth/id1/id2/info
where
id1 ID-code of the RPi's BT controller
id2 ID-code of the BT keyboard

You get access only during a root session or using the "sudo command".

Could you have a look into that file (if it exists already)?

Frank
Posts: 13
Joined: Thu Mar 03, 2016 4:09 pm
by uklightman » Mon Mar 14, 2016 10:31 pm
Thank you 'Frankymusic', after a couple of weeks of frustration, I can now use my 'Bluetooth' keyboard.
Posts: 1
Joined: Tue Jan 10, 2012 11:52 pm
by lmoss30 » Tue Mar 15, 2016 1:29 pm
I checked for that file with

sudo /var/lib/bluetooth/id1/id2/info

and says not present.

also re ran the procedure, and still no luck, have tried bluetoothctl -a and that makes no difference,

this is so fustrating, the only think i can say is if i leave pairable on, it says device not available.
Posts: 66
Joined: Mon May 28, 2012 11:45 am
by frankymusic » Tue Mar 15, 2016 2:27 pm
Hi lmoss30,

that "info" file is accessable for a super user only. Sorry for the "short form" of my hint... :?

To see it's content (while you're logged in as "pi" user for example) you should type the following command into the console window:
Code: Select all
sudo nano /var/lib/bluetooth/id1/id2/info
to open it using the "nano" editor... (be careful NOT to edit anything!!!)
... or...:
Code: Select all
sudo less /var/lib/bluetooth/id1/id2/info
to only have a look inside...

For id1 and id2 you must type in the BT address of your devices (RPi 3 as well as BT keyboard)
So a (working) command could be (this is only an example because of the choosen numbers...!!!)
Code: Select all
sudo less  /var/lib/bluetooth/B8:27:EB:9A:A5:EB/20:73:AB:00:0D:C3/info
Hope this helps

Frank
Posts: 13
Joined: Thu Mar 03, 2016 4:09 pm
by lmoss30 » Tue Mar 15, 2016 2:43 pm
Hi Frank

this is the response from the info file

[General]
Name=Bluetooth Keyboard
Class=0x000540
SupportedTechnologies=BR/EDR;
Trusted=true
Blocked=false

[LinkKey]
Key=C7E8998BF31E3612EA0789C6771D8917
Type=0
PINLength=0

[DeviceID]
Source=2
Vendor=1452
Product=544
Version=1
[General]
Name=Bluetooth Keyboard
Posts: 66
Joined: Mon May 28, 2012 11:45 am
by frankymusic » Tue Mar 15, 2016 9:19 pm
Hi lmoss30, again,

sorry that I don't have the solution for your (specific ?) problem...

Another question:
did you start from a fresh (actual) Raspbian-Jessie image? How about "sudo apt-get update / sudo apt-get upgrade" before configuring that BT connection? May be you completed all these things, but if not, please do it...

My "info" file's content - for comparison only:
Code: Select all
[LinkKey]
Key=42E5D18C44FC023A95D06F1B9AE3394C
Type=0
PINLength=0

[General]
Name=Bluetooth V3.0 TouchPad Keyboard
Class=0x000540
SupportedTechnologies=BR/EDR;
Trusted=true
Blocked=false
Services=00001000-0000-1000-8000-00805f9b34fb;00001124-0000-1000-8000-00805f9b34fb;00001200-0000-1000-8000-00805f9b34fb;

[DeviceID]
Source=1
Vendor=2652
Product=34050
Version=283
It seems that the line "Services" is missed inside your "info" file! No idea why, at the moment...

This line looks very specific (... only valid for my "specific" BT keyboard...), but no!
Here I found a quite other protocol from a different user: http://askubuntu.com/questions/554053/where-are-bluetooth-link-keys-stored-in-ubuntu-14-10
(you have to scroll down almost to the bottom of that topic),
and as far as I can see, that line "Services" is exactly the same as that of my "info" file.

No idea at the moment why yours doesn't work, but please report if you did all the initialisation steps mentioned above (sudo apt get ...).

Frank

PS: May be some BT experts can give "us" an advice to help getting your BT keyboard connected...? :idea:
Posts: 13
Joined: Thu Mar 03, 2016 4:09 pm
by lmoss30 » Wed Mar 16, 2016 10:28 am
Hi Frank,

thank you for all you help, it is very furstrating, althought in the process learning quite abit about bluetooth in the process,

i initially did a clean install, i will try again on a fresh card and see how that goes, i think we all take for granted windows/phones that do this in the background without any modification. Might even see if i can find a different keyboard to use.

Regards
Lee
Posts: 66
Joined: Mon May 28, 2012 11:45 am
by frankymusic » Wed Mar 16, 2016 10:51 am
Hi Lee,

... and don't forget to update/upgrade the whole system before trying the BT connection to be sure you're using the latest drivers and so...

BT on RPi 3 is very new (as the RPi 3 by itself) and so it could take some time to solve all the "starting" problems...

Did you try to connect your BT keyboard to an android smartphone for example? I did so and therefore I was hopefully to get it connected to the RPi 3... and therefore I didn't gave up until it was working. ;)

Don't forget to report your final insights, please.

Frank
Posts: 13
Joined: Thu Mar 03, 2016 4:09 pm
by lmoss30 » Wed Mar 16, 2016 1:24 pm
Hi Frank,

yeah it pairs to my smart phone and laptop no problems so it seems to an issue with my install,

i will report back once i do a clean install and try again.

Lee
Posts: 66
Joined: Mon May 28, 2012 11:45 am
by lmoss30 » Thu Mar 17, 2016 11:24 am
Hi Frank,

Could you check if possible this report on yours i did a

sudo service bluetooth status and i get the following, does look right

● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
Active: active (running) since Fri 2016-02-26 02:21:08 UTC; 2 weeks 6 days ag o
Docs: man:bluetoothd(8)
Main PID: 567 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─567 /usr/lib/bluetooth/bluetoothd

Feb 26 02:21:08 raspberrypi bluetoothd[567]: Bluetooth daemon 5.23
Feb 26 02:21:08 raspberrypi systemd[1]: Started Bluetooth service.
Feb 26 02:21:08 raspberrypi bluetoothd[567]: Starting SDP server
Feb 26 02:21:08 raspberrypi bluetoothd[567]: Bluetooth management interface ...d
Feb 26 02:21:08 raspberrypi bluetoothd[567]: Sap driver initialization failed.
Feb 26 02:21:08 raspberrypi bluetoothd[567]: sap-server: Operation not permi...)
Hint: Some lines were ellipsized, use -l to show in full.
Posts: 66
Joined: Mon May 28, 2012 11:45 am
by Massi » Thu Mar 17, 2016 11:47 am
frankymusic wrote:BT on RPi 3 is very new (as the RPi 3 by itself) and so it could take some time to solve all the "starting" problems...


well, in my opinion the problem is not the new BT on rpi3, but that maleficent BlueZ 5 :lol: :lol:
i'm hating it so much ant it's impossibility to get a rfcomm paired and created on startup..

btw, i'm also seeing these 2 errors:
Code: Select all
Feb 26 02:21:08 raspberrypi bluetoothd[567]: Sap driver initialization failed.
Feb 26 02:21:08 raspberrypi bluetoothd[567]: sap-server: Operation not permi...)


i don't think where these come from, but i think they are not breaking BT at all..
Posts: 1560
Joined: Fri May 02, 2014 1:52 pm
Location: Italy
by frankymusic » Thu Mar 17, 2016 11:56 am
Hi Lee,

I tested it for your comparision. While my BT keyboard is working well, it seems to be the same output of that status request...

pi@raspberrypi:~ $ sudo service bluetooth status
bluetooth.service - Bluetooth Service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
Active: active (running) since Di 2016-03-15 22:17:08 CET; 1 day 14h ago
Docs: man:bluetoothd(8)
Main PID: 687 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─687 /usr/lib/bluetooth/bluetoothd

Mär 15 22:17:08 raspberrypi bluetoothd[687]: Bluetooth daemon 5.23
Mär 15 22:17:08 raspberrypi systemd[1]: Started Bluetooth service.
Mär 15 22:17:08 raspberrypi bluetoothd[687]: Starting SDP server
Mär 15 22:17:08 raspberrypi bluetoothd[687]: Bluetooth management interface 1.9 initialized
Mär 15 22:17:08 raspberrypi bluetoothd[687]: Sap driver initialization failed.
Mär 15 22:17:08 raspberrypi bluetoothd[687]: sap-server: Operation not permitted (1)
pi@raspberrypi:~ $

Frank
Posts: 13
Joined: Thu Mar 03, 2016 4:09 pm