devnull
Posts: 65
Joined: Sat Dec 24, 2011 7:46 am

headless bluetooth pairing

Tue Aug 20, 2013 2:12 am

I am struggling to get a bluetooth device with a 4 digit keycode paired from the command line (no GUI).

After installing bluez and bluez-utils, the dongle and device to be paired are found:

Code: Select all

hciconfig hci0 up
hcitool scan
> Scanning ...
	00:19:5D:EE:3E:04	OmniTek_Bluetooth
I then run bluetoothctl to attempt pairing:

Code: Select all

[bluetooth]# pair 00:19:5D:EE:3E:04
Attempting to pair with 00:19:5D:EE:3E:04
[CHG] Device 00:19:5D:EE:3E:04 Paired: yes
[CHG] Device 00:19:5D:EE:3E:04 Connected: yes
Pairing successful
[CHG] Device 00:19:5D:EE:3E:04 Paired: no
[CHG] Device 00:19:5D:EE:3E:04 Connected: no
[bluetooth]# connect 00:19:5D:EE:3E:04
Attempting to connect to 00:19:5D:EE:3E:04
Failed to connect: org.bluez.Error.NotAvailable
[bluetooth]# 
As you can see, it reports that pairing was successful, but does not prompt me for the pairing key (1234), and then a few seconds later reports that it is not paired, and attempting to use the connect command fails.

I have run the help command in bluetoothcfg and cannot see any option to specify the pairing key.

How can I pair a device that has a passkey set using bluetoothctl ?
> /dev/null 2>&1

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: headless bluetooth pairing

Tue Aug 20, 2013 8:17 pm

bluez and not bluez4?
Things are going through a change, you have looked at this?
https://wiki.archlinux.org/index.php/Bluetooth
The wiki is generally acknowledged as a very good source of info, I see a note at the top of page in this case
You never mentioned what device you have

roop
Posts: 10
Joined: Thu Sep 27, 2012 12:11 pm

Re: headless bluetooth pairing

Fri Aug 23, 2013 1:02 pm

Hey there,

I have the exact same problem you have.

Depending on what kind of device you are using i might have something for you.
I tried to start pairing from my rpi and got the same error.
After that I tried it the other way around using my phone to pair.
That way I entered the code in my phone but nothing happend on the rpi-side...

My solution with bluetoothctl:

1. Make rpi visible and stuff with: power on / discoverable on / pairable on
(I doubt you need all of this but I used all of these to make sure it works)
2. Start Agent with: agent on
3. Set Default Agent with: default-agent
(I'm not sure myself what this "Default Agent" is but now I was asked for a
Pin on the rpi-side and it paired with my phone)

My problem after this is:

It seems like the rpi is not offering any bt-feature and there is no config file or so...
(Info: I wanted to make a headless bt-audio device)

Greets

erotavlas
Posts: 41
Joined: Wed Mar 11, 2015 5:26 pm

Re: headless bluetooth pairing

Wed May 06, 2015 9:03 am

Hi,
you can find a solution in this thread viewtopic.php?f=29&t=87138&p=752712#p752712 with post on blueagent5.

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Thu May 12, 2016 11:15 pm

Hi,
I have the same problem as above and connot find resolution:

It looks like both devices are rejecting each other and cannot be paired.
When i try to connect to the rpi from my mobile , the same pairing key appears also on my mobile , after confirming with the right pin code that appears also on the rpi , after checking Y , on terminal i see No conection and on my mobile - fail to connect.

Any idea?

[bluetooth]# power on
Changing power on succeeded
[CHG] Controller B8:27:EB:41:0E:7A Powered: yes
[bluetooth]# agent on
Agent is already registered
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:41:0E:7A Discovering: yes
[NEW] Device 18:EE:69:02:B9:00 18-EE-69-02-B9-00
[NEW] Device 94:39:E5:EB:82:40 ADDI-DELL
[CHG] Device 18:EE:69:02:B9:00 RSSI: -84
[NEW] Device B8:6C:E8:51:32:D1 Galaxy S5

[agent] Confirm passkey 037479 (yes/no): Y
[CHG] Device B8:6C:E8:51:32:D1 Connected: no
[bluetooth]# pair B8:6C:E8:51:32:D1
Attempting to pair with B8:6C:E8:51:32:D1
[CHG] Device B8:6C:E8:51:32:D1 Connected: yes
Request confirmation
[agent] Confirm passkey 765771 (yes/no): Y
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device B8:6C:E8:51:32:D1 Connected: no
[bluetooth]#

User avatar
Douglas6
Posts: 4307
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: headless bluetooth pairing

Fri May 13, 2016 12:22 am

If memory serves, the positive response to 'confirm passkey' must be 'yes', not 'Y'.

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Fri May 13, 2016 3:34 pm

Great , thanks for focusing me on this issue ,and pairing has passed fine. However the connection is rejected.
Going strait in to the point , the end purpose is to send text from one rpi 3 to the other.
Is there any place that this process is described nice and easy ?

User avatar
Douglas6
Posts: 4307
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: headless bluetooth pairing

Fri May 13, 2016 4:36 pm

You'll need to setup the Serial Port Profile on both Pi's, and run an rfcomm watch command on one of them. You should then be able to connect with the other, and use minicom or whatever to communicate. See if this post helps: viewtopic.php?p=955425#p955425

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Sat May 14, 2016 11:27 am

Thanks, after running the rfcomm command , it seems that the command line went into a serial mode with no response to commands and a try session to connect from the remote RPi one using the command : connect , than i received from the remote one a response that the device is not available. Since i thought there is a link to the previous BT connection to my mobile (which has ended up with no more than a successful pairing ) i have unpaired of that particular from my mobile . Still same behavior.

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Sat May 14, 2016 8:19 pm

It seems that on the device that i enabled the Rfcomm , once i re booth the RPI and transfer into bluetoothctl mode it seems the Rfcomm channel is still open, which is probably the reason for the previous issue.
1. How do i end the rfcomm session ?
2. How do i make this thing to work properly ?
Attachments
bluetooth rfcomm.JPG
bluetooth rfcomm.JPG (38.95 KiB) Viewed 65361 times

User avatar
Douglas6
Posts: 4307
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: headless bluetooth pairing

Sat May 14, 2016 8:38 pm

The rfcomm watch 'session' ends when the command ends. Certainly after a reboot.

According to your screenshot, you do not have a working Bluetooth adapter. What does 'hciconfig - a' show?

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Sat May 14, 2016 9:38 pm

The bluetooth that i am using is the internal one and not external module.

pi@raspberrypi:~ $ hciconfig - a
Warning: unknown command - "a"
hci0: Type: BR/EDR Bus: UART
BD Address: B8:27:EB:41:0E:7A ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:654 acl:0 sco:0 events:33 errors:0
TX bytes:419 acl:0 sco:0 commands:33 errors:0

User avatar
Douglas6
Posts: 4307
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: headless bluetooth pairing

Sat May 14, 2016 9:49 pm

That's odd. I wonder why it doesn't show in bluetoothctl....

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Sat May 14, 2016 10:05 pm

i have send the restart comand for the bluetooth and received the following:

pi@raspberrypi:~ $ sudo invoke-rc.d bluetooth restart
Failed to restart bluetooth.service: Unit bluetooth.service failed to load: Bad message. See system logs and 'systemctl status bluetooth.service' for details.
invoke-rc.d: initscript bluetooth, action "restart" failed.

User avatar
Douglas6
Posts: 4307
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: headless bluetooth pairing

Sat May 14, 2016 10:10 pm

To restart bluetoothd in Jessie, do this

Code: Select all

sudo systemctl restart bluetooth

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Sat May 14, 2016 10:26 pm

pi@raspberrypi:~ $ sudo systemctl restart bluetooth
Failed to restart bluetooth.service: Unit bluetooth.service failed to load: Bad message. See system logs and 'systemctl status bluetooth.service' for details.
pi@raspberrypi:~ $

User avatar
Douglas6
Posts: 4307
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: headless bluetooth pairing

Sat May 14, 2016 10:40 pm

Well, that might explain why bluetoothctl does not show the adapter. Take a look in /var/log/syslog for any messages showing why the service failed. You might also try

Code: Select all

sudo systemctl start bluetooth
Have you made changes to dbus-org.bluez.service? Post it here.

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Sun May 15, 2016 8:23 am

The log file seems to address an issue with dbus-org.bluez.service.
Yes i changed it according to :
viewtopic.php?p=955425#p955425
Attachments
dbus-org.bluez.JPG
dbus-org.bluez.JPG (33.17 KiB) Viewed 64980 times

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Sun May 15, 2016 9:28 am

There is no doubt that the issue is with this file as it seems i did not alter it properly as there are various files with the same name in addition to suffix of 1, 2,3 each has its own content. However i could not delete any of them since the OS doesn't let me do so.

User avatar
Douglas6
Posts: 4307
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: headless bluetooth pairing

Sun May 15, 2016 1:44 pm

'ExacStartPost=' should be 'ExecStartPost='

av05
Posts: 18
Joined: Fri May 06, 2016 10:59 pm

Re: headless bluetooth pairing

Sun May 15, 2016 2:19 pm

Thanks allot.
however i have corrected the file accordingly , still have the same issue:
once going into bluetoothctl, command line does not respond.

User avatar
Douglas6
Posts: 4307
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: headless bluetooth pairing

Sun May 15, 2016 2:33 pm

What does

Code: Select all

systemctl status bluetooth
tell you now?

sdjf
Posts: 1388
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: headless bluetooth pairing

Sun May 15, 2016 4:51 pm

About those files you can not delete. A couple of things to do, to examine where they came from and what they are.

Run "ls -l PATH-TO-FILES*" with an asterisk at the end, to see if they may just be symlinks and what the write permissions are.

To find out what package owns each of those files, run "pacman -Qo NAME-OF-FILE".

Make sure they aren't needed by something before removing them, the above should help answer that question. Then to remove something, if you are absolutely sure it won't break something, it may be an ownership/permission problem. Use "sudo rm NAME-OF-FILE" if the issue is root privileges are required.

It is possible the files are orphaned from an earlier upgrade and not owned by anyone, pacman does have a facility for safely removing orphaned files, read the man page and get back with a question here if you cannot figure out how to remove orphaned files.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || My 512MB Model B only runs Arch.

Return to “Arch”

Who is online

Users browsing this forum: No registered users and 1 guest