Error while connecting to BLE device using Gatttool - raspberry-pi

I am using gatttool on Raspberry PI to connect to a BLE peripheral.
The connection fails with the error message "connect error: Too many levels of symbolic links (40)"
The following is the command & response log obtained with gatttool.
pi#raspberrypi:~ $ sudo gatttool -b 20:70:6a:10:01:81 -I
[20:70:6a:10:01:81][LE]> connect
Attempting to connect to 20:70:6a:10:01:81
Error: connect error: Too many levels of symbolic links (40)
What is the issue here?
Thanks

I had the same issue, and bringing the hci0 interface down and up helped me.
sudo hciconfig hci0 down/up

sudo hciconfig hci0 down
sudo hciconfig hci0 up
solved the issue for me, as described by user3493478, thanks!

Thanks to #user3493478, #contractorwolf,
It solved my problem to connect MiFlora to P4 (Raspbian)
root#raspberrypi:/home/pi# gatttool -I -b C4:7C:8D:6C:9A:5A
[C4:7C:8D:6C:9A:5A][LE] connect
Attempting to connect to C4:7C:8D:6C:9A:5A
Error: connect error: Too many levels of symbolic links (40)
root#raspberrypi:/home/pi# hciconfig hci0 up
root#raspberrypi:/home/pi# hciconfig hci0 down
[C4:7C:8D:6C:9A:5A][LE] connect
Attempting to connect to C4:7C:8D:6C:9A:5A
Connection successful

Related

problem installing omv on raspberry pi: "unable to resolve host address raw.githubusercontent.com

im trying to install open media player on my raspberry pi 3.
ive tried installing the installerMedia plugin with the following command:
wget -O - https://raw.githubusercontent.com/OpenMediaVault-Plugin-Developers/installScript/master/install | sudo bash
but i keep getting this error...
any help?
thanks in advance!

bind failed: EADDRINUSE while starting Xbt tracker in Ubuntu

I follow these steps to install xbt on ubuntu.
Download Xbt from GitHub
install g++
install xbt
4)create database and import data.
when I am going to start xbt ./xbt_tracker it shows bind failed: EADDRINUSE. Kindly help me I am stuck on this error for the last two days
kiran#kiran:/var/www/xbt_tracker$ ./xbt_tracker
bind failed: EADDRINUSE
The error points to the port already being in use by another application or service. You can check which by using netstat:
sudo netstat -tulpn

Connect BLE devices with Raspberry pi 3 B

I know this is not the first time this question was asked but after trying every thing I could during a week, I still have problems.
I'm trying to connect to my Raspberry pi to BLE devices. I can scan them but not connect to them.
The last explanation I have followed was this github issue: https://github.com/ukBaz/python-bluezero/issues/30
And here is all the commands I have done to try to update bluez and make this connection works.
###Install RASPBIAN JESSIE LITE
2017-01-11-raspbian-jessie-lite.img
###Updates
$ sudo apt-get update
$ sudo apt-get upgrade
###Add libs
$ sudo apt-get install bluetooth bluez-tools build-essential autoconf glib2.0 libglib2.0-dev libdbus-1-dev libudev-dev libical-dev libreadline-dev git
###Get bluez-5.43
$ wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.43.tar.xz
$ tar xf bluez-5.43.tar.xz
$ cd bluez-5.43
###Patch bluez
$ wget https://gist.github.com/pelwell/c8230c48ea24698527cd/archive/3b07a1eb296862da889609a84f8e10b299b7442d.zip
$ unzip 3b07a1eb296862da889609a84f8e10b299b7442d.zip
$ git apply -v c8230c48ea24698527cd-3b07a1eb296862da889609a84f8e10b299b7442d/*
###Install bluez
$ ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental --enable-maintainer-mode
$ make -j 4 && sudo make install
### Add to /etc/dbus-1/system.d/bluetooth.conf
<!-- allow users of bluetooth group to communicate -->
<policy group="bluetooth">
<allow send_destination="org.bluez"/>
</policy>
$ sudo usermod -G bluetooth -a $USER
$ sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/' /lib/systemd/system/bluetooth.service
$ sudo systemctl daemon-reload
$ sudo service bluetooth restart
$ service bluetooth status
$ sudo reboot
$ sudo hcitool lescan
LE Scan ...
XX:XX:XX:XX:XX:XX (name)
$ gatttool -b XX:XX:XX:XX:XX:XX -I
[XX:XX:XX:XX:XX:XX][LE]> connect
Attempting to connect to XX:XX:XX:XX:XX:XX
Error: connect error: Transport endpoint is not connected (107)
$ gatttool -b XX:XX:XX:XX:XX:XX -t random -I
[XX:XX:XX:XX:XX:XX][LE]> connect
Attempting to connect to XX:XX:XX:XX:XX:XX
Error: connect error: Connection refused (111)
Thank you for your help
Edit for Constantin Chabirand's answer
$ systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
Active: active (running) since Tue 2017-01-17 21:17:07 UTC; 1min 51s ago
Docs: man:bluetoothd(8)
Main PID: 587 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─587 /usr/libexec/bluetooth/bluetoothd --experimental
$ bluetoothctl
[NEW] Controller B8:27:EB:FD:93:2B raspberrypi [default]
[bluetooth]# scan on
Discovery started
....
[bluetooth]# scan off
[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
Edit 2
After reinstalling with the simple solution:
$ bluetoothctl -v
5.43
$ systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
Active: active (running) since Wed 2017-01-18 15:46:53 UTC; 3min 37s ago
Docs: man:bluetoothd(8)
Main PID: 586 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─586 /usr/local/libexec/bluetooth/bluetoothd --experimental
$ sudo bluetoothctl
[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
Thank's to Constantin Chabirand, I made it work. I needed a few more command lines to make it work and I needed to change the advertising frequency of my BLE device (I still need to do some tests on that).
Here is the exact commands I used to install bluez on my rpi3 and connect to BLE devices:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install -y libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.43.tar.xz
tar xf bluez-5.43.tar.xz
cd bluez-5.43/
./configure
make
sudo make install
sudo reboot
# check version
bluetoothctl -v
sudo nano /lib/systemd/system/bluetooth.service
# Add --experimental to this lane
ExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimental
sudo systemctl daemon-reload
sudo systemctl restart bluetooth
sudo hciconfig hci0 up
sudo reboot
sudo usermod -G bluetooth -a pi
sudo reboot
That's it. Thank's again for your help.
What is the result of the bash command systemctl status bluetooth ?
Can you start bluetoothctl (just type it in your shell) ?
I also use a raspberry pi 3 to connect to BLE devices and I don't need a patch. Start a fresh install with bluez5.43 and post the results of the two commands I've written
UPDATE
For the installation I did it the simplest way I could. I followed the "The simplest way to compile this package is:" section in the INSTALL file which is :
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.43.tar.xz
tar xf bluez-5.43.tar.xz
cd bluez-5.43.tar.xz
./configure
make
make install
Did you succesfully connect to your BLE device using something else ? Like a smartphone ? There are applications out there that can read gatt atrributes.
UPDATE 2
I did not remove a thing. Merely installed bluez5.43 on top of the rest. When I run
bluetoothctl -v it returns : 5.43.
When I run apt list --installed is can see the following packages installed automatically :
bluez/stable,now 5.23-2+rpi2 armhf [installed,automatic]
bluez-firmware/stable,now 1.2-3+rpi1 all [installed,automatic]
bluez-obexd/stable,now 5.23-2+rpi2 armhf [installed,automatic]
bluez-tools/stable,now 0.2.0~20140808-3 armhf [installed]
As you can see I still have the old version installed.
I needed to install the bluez-5.43 to get around bugs in the default bluez-5.23 when using bluetoothctl from scripts.
You could probably install the binary version from stretch, but my experience is that you often run into other dependencies.
I had the same problem under Ubuntu-16.04 and used the deb-src package from Ubuntu-Zesty, to fix that. Since this is just a debian package I used this on the Raspberry pi too, worked fine when using a USB-bluetooth dongle. To make this work on the RPI-3, which has its bluetooth controller attached via a serial line, you need to install the ../issue/30 patches too.
The advantage of doing it this way, is that once your Raspbian will contain a newer bluez version it will replace what we do here, and if you got more raspbian system you of course only need to install the generated .deb packages
This is what I did (handsfree):
#!/bin/bash
sudo apt-get install devscripts debhelper dh-autoreconf flex bison libdbus-glib-1-dev libglib2.0-dev libcap-ng-dev libudev-dev l
ibreadline-dev libical-dev check dh-systemd libebook1.2-dev
wget https://launchpad.net/ubuntu/+archive/primary/+files/bluez_5.43.orig.tar.xz
wget https://launchpad.net/ubuntu/+archive/primary/+files/bluez_5.43-0ubuntu1.debian.tar.xz
wget https://launchpad.net/ubuntu/+archive/primary/+files/bluez_5.43-0ubuntu1.dsc
tar xf bluez_5.43.orig.tar.xz
cd bluez-5.43
tar xf ../bluez_5.43-0ubuntu1.debian.tar.xz
# install patches relevant for rpi-3 bluetooth
. /etc/os-release
if [ $ID = raspbian ]; then
wget https://gist.github.com/pelwell/c8230c48ea24698527cd/archive/3b07a1eb296862da889609a84f8e10b299b7442d.zip
cd debian/patches
unzip ../../3b07a1eb296862da889609a84f8e10b299b7442d.zip
for i in c8230c48ea24698527cd-3b07a1eb296862da889609a84f8e10b299b7442d/*;do
mv $i .
basename $i >> series
done
rmdir c8230c48ea24698527cd-3b07a1eb296862da889609a84f8e10b299b7442d
cd ../..
fi
# end of Raspian related patches
debchange --local=~lorenzen 'Backport to Xenial'
debuild -b -j4
cd ..
sudo dpkg -i *.deb
This would should work under other Debian derived systems too,
https://askubuntu.com/a/884062/655086
I faced the same problem that connecting and playing BLE devices with Raspberry Pi 3 built-in Bluetooth. First of all, I learned how to play and control a tool of bluetoothctl in virtue of below webpage.
[https://mcuoneclipse.com/2016/12/19/tutorial-ble-pairing-the-raspberry-pi-3-model-b-with-hexiwear/][1]
In this tutorial, after successful connection with your BLE devices, you can work with an attribute that you want to play with.
For example, if you want to work with the attribute of Bluetooth UART TX or RX, you just need to input commands below, then read or write a value of that attribute of characteristic.
list-attributes 00:34:40:0A:00:4E
select-attribute /org/bluez/hci0/dev_00_32_40_08_00_12/service0026/char0027
read
write
If there is anyone who is fully aware of creating bluetooth connecting between Raspberry Pi 3 built-in BLE with Arduino Ble, Please share your knowledge. ;)

bluez5 ble advertise stops after first connect

We are unclear about the functionality of the leadv command in bluez5.
After connecting to a device and disconnecting again it is impossible to reconnect to the same device. Only after calling leadv again it is possible to reconnect.
We have reproduced this behaviour with various platforms (raspberrypi, x86) and various versions of bluez5 (5.15, 5.16, 5.18, 5.21) and bt dongles from broadcom and csr.
Is it possible to reconnect multiple times without readvertising?
bluetoothd with gatt server is running
We issued the following commands
hciconfig hci0 up
hciconfig hci0 noscan
hciconfig hci0 name foo
hciconfig hci0 leadv 0
I am having the exact same issue.
Interesting is that during a disconnect 'hcidump' doesn't show any commands issued by bluez to the bluetooth controller which would indicate that it turned off the advertising.
I am using this workaround to re-enable advertising as soon as a device disconnected:
sudo dbus-monitor --system --profile | grep --line-buffered --only-matching InterfacesRemoved | xargs -n1 -I % sudo /home/pi/bluez/bluez-5.25/tools/hciconfig hci0 leadv 0
Explanations:
'--line-buffered' is needed as dbus-monitor does not flush its output
'-I %' makes xargs not appending the grep'd "InterfaceRemoved" to the executed command
It turned out that it is actually possible to reenable advertising automatically, but it only seems to work with selected bluez/kernel combinations. We finally had it working with bluez 5.21 and a raspberry pi kernel 3.16 for both broadcom and csr dongles. We haven't tried since with other combinations because we switched to custom hardware (TI CC2451) shortly afterwards.

SASL create user failure

I am trying to add new user to SASL db with:
saslpasswd2 -a memcached -c <new_user>.
Once I repeat password I get following error:
saslpasswd2: generic failure
I was not able to find any solution online...
If anyone has similar problem, solution is to add sudo before saslpasswd2...
sudo saslpasswd2 -a memcached -c <new_user>