Bluez fails on Raspberry Pi running Jessie Headless - bluetooth

I've run out of tutorials and tricks that worked for others but not for me.
I'm trying to pair a remote bluetooth speaker with my PI Zero.
When I attempt to connect I get the error message:
[bluetooth]# connect XX:XX:XX:XX:XX:XX
Attempting to connect to XX:XX:XX:XX:XX:XX
Failed to connect: org.bluez.Error.Failed
[bluetooth]#
And the log reports:
org.bluez.Manager.GetProperties() failed:
org.freedesktop.DBus.Error.UnknownMethod: Method "GetProperties" with
signature "" on interface "org.bluez.Manager" doesn't exist
I have no idea where to begin addressing that. The logs also report
Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported:
Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
and
a2dp-sink profile connect failed for XX:XX:XX:XX:XX:XX: Protocol not
available a2dp-source profile connect failed for XX:XX:XX:XX:XX:XX:
Protocol not available
I'm sure there's useful information in there but every time I think I've googled a solution I'm disappointed. Moving the load of the discoverable module until after X11 load didn't work. Purging pulseaudio and reinstalling it didn't help. Any ideas?

Somewhere on some thread someone said that Pulseaudio had to be version 6.0 or greater, which led me down the rabbit hole of installing version 7, which broke on Jessie due to incompatible dependencies.
Ultimately I purged the following:
apt-get purge pulseaudio pulseaudio-module-bluetooth libpulse0
And reinstalled
apt-get install pulseaudio pulseaudio-module-bluetooth
I then unpaired the Alexa from the pi via the Alexa app on my phone
and ran
bluetoothctl
[bluetooth]# remove XX:XX:XX:XX:XX:XX
Reboot and voilĂ , Pulseaudio running and paired on the Pi and working! Only issue I have now is that I can't seem to get it to start automatically on boot. I've added to /etc/rc.local:
su -c 'pulseaudio --start' - pi
echo connect XX:XX:XX:XX:XX:XX | bluetoothctl
su -c 'pacmd set-card-profile bluez_card.68_54_FD_82_A9_BF a2dp' - pi
Well, to be precise, it pairs automatically on boot, but then drops out. If I manually run
pulseaudio --start
and
bluetoothctl
[bluetooth]# power on
[bluetooth]# agent on
[bluetooth]# default-agent
[bluetooth]# connect XX:XX:XX:XX:XX:XX
Then all works fine, stays rock solid. Despite the fact that I STILL have these error messages in the log:
cat /var/log/syslog | grep dbus
org.bluez.Manager.GetProperties() failed:
org.freedesktop.DBus.Error.UnknownMethod: Method "GetProperties" with
signature "" on interface "org.bluez.Manager" doesn't exist
Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported:
Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

Related

CentOS 7 USB. Connect to Wi-Fi using CLI only

I just installed CentOS 7 [Kernel 3.10.0-514] on my USB stick.
Operating system works fine but I had some problems with my Broadcom 43227 wireless card.
I downloaded driver, patched it, changed code a bit according to the instruction here: https://wiki.centos.org/HowTos/Laptops/Wireless/Broadcom and after many attempts it finally compilled and after loading the driver module into kernel led turned on.
Now I need to connect to my Wi-Fi.
What am I trying to do:
Get wireless interface name using iw dev:
phy#0
Interface wlp2s0
Scan to find WiFi Network using iw wlp2s0 scan | grep SSID
SSID: MyNetworkName
Generate a WPA/WPA2 configuration file using wpa_passphrase MyNetworkName >> /etc/wpa_supplicant.conf
MyNetworkPassword
Connect to WPA/WPA2 WiFi network using wpa_supplicant -B -D wext -i wlp2s0 -c /etc/wpa_supplicant.conf
Successfylly initialized wpa_supplicant
[and in some cases after few minutes]
ERROR #wl_cfg80211_scan: WLC_SCAN error (-22)
Get an IP using dhclient using dhclient wlp2s0
But nohing happens
Ping command : Name or sarvice not known
If I run wpa_supplicant without -B I get some repeating errors:
Device or resource busy
wlp2s0: Failed to initiate AP scan
wlp2s0: Trying to associate with [MAC] (SSID='MyNetName' freq=2462 MHz)
Operation not supported
wlp2s0: Association request to the driver failed
....
if I add -D nl80211 to wpa_supplicant call I get same errors without "Device or resource busy"
What I am doing wrong?

gatttool can't connect to a bluetooth module

I'm trying to connect a bluetooth module to a Raspberry Pi3 using gatttool.
First, I launched gatttool with following command, and tried to connect;
$ sudo gatttool -b (MAC ADDRESS) -I
Then an error message was shown.
Error: connect: Device or resource busy (16)
I searched it and found some solutions. After that, I tried again.
$ sudo gatttool -t random -b (MAC ADDRESS) -I
Then it attempted to connect to the bluetooth module for a while, and showed following error.
Error: connect error: Connection refused (111)
I never heard about a situation that somebody encountered both of these errors. What can I do to solve it?

Bluetooth LE on Raspbian does not bond with nRF

I have an Rpi3 and I want to bond it with nRF which is connected to my laptop via UART. This nRF-laptop connection shows me whether Rpi3 is connected and/or paired with nRF. I am able to connect to the nRF device by running:
gatttool -t random -b XX:XX:XX:XX:XX:XX -I
I found that to be able to pair it, all I need to do is run the following command after I connected using gattool:
sec-level medium
However, nRF device only showed "Connected".
Then I tried using bluetoothctl command. I made sure the power is on, agent is on, it's discoverable and etc. After I ran the command pair XX:XX:XX:XX:XX:XX, it said it was successful. This was also confirmed after running info XX:XX:XX:XX:XX:XX. Yet nRF device did not react to the pairing. If I connect to nRF device through my phone using "nRF Connect" app, then nRF shows that my phone is paired.
I am running:
Linux 4.9.13-v7+ #974 SMP Wed Mar 1 20:09:48 GMT 2017 armv7l GNU/Linux
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
Bluez-5.44
I followed tutorials from adafruit and stackoverflow. I read that for Bluez-5.44 I do not need to run bluetooth in the experimental mode.
What am I missing? I would appreciate any help.
To any lost souls who might have also been stuck in this situation, here is how I solved it (you need to run sudo for the following commands):
$ service bluetooth stop
$ /etc/init.d/bluetooth start
If the nRF device has been paired once and then restarted, that means the pairing key is still on Pi's side which needs to be removed and can be done by:
$ bluetoothctl
$ remove XX:XX:XX:XX:XX:XX
$ exit
After this you need to start bluetooth device:
$ hciconfig hci0 up

BlueZ bluetoothctl on Raspbian Jessie, connecting a Raspberry Pi to a Sphero

When trying to connect to a Sphero (from Orbotix) through Bluetooth, on a Raspbian Jessie fully updated:
if I do (being root, with Sphero paired and trusted)
# bluetoothctl
[bluetooth]# connect {sphero-mac-address}
[CHG] Device {sphero-mac-address} Connected:yes
[CHG] Device {sphero-mac-address} Connected:no
As you can see the connection fails
but if I do instead
# rfcomm connect /dev/rfcomm0 {sphero-mac-address}
Connected /dev/rfcomm0 to {sphero-mac-address} on channel 1
The connection succeeds, and the Sphero appears connected in bluetoothctl also, afterwards.
What do I do wrong with bluetoothctl connect?
i have the same phenomenom on raspberry pi 3 Jessie when i forgot to do
pulseaudio --start
before bluetoothctl

bluetooth pairing and connection from command line

I want to connect and pair to available nearby bluetooth devices from command line in linux.
I have searched through internet, and found that we can pair through simple-agent, but it is not available in my device.
following commands are available in device:
hcitool, hciconfig, hcidump, sdptool, l2ping, rfcomm.
for connecting to remote device i am running the following command.
hcitool cc BD_ADDRESS
but above command is connecting the device for a while, and again the device is getting disconnected. in hcidump output , i am seeing the disconnection event. Is there anyway in linux command line through which i can test my bluetooth? What can be the reason for device is getting disconnected after a while?
I saw the same issue once and was able to solve it with the rfcomm command. Try the following:
# rfcomm connect /dev/rfcomm0 00:11:22:33:44:55 1 &
Additionally, it is good practice to enable secure simple pairing and enable page and inquiry scan with the following commands:
# hciconfig hci0 sspmode 1
# hciconfig hci0 piscan
Let me know if you still have problems.

Resources