OpenWrt Forum Archive

Topic: Help with Bluez

The content of this topic has been archived on 13 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello everyone,

I'm setting up a an openwrt-based system for the Raspberry Pi (actually, my partner is the project lead, but he's away for the summer) and I want to pair with a device called the Muse from Interaxon.

I can pair with my software running on my laptop (Ubuntu), without any issue.

When I build my software for my raspberry pi, I can't pair with the device anymore.

I don't know much about Bluetooth, I'm using the bluez package. When I sniff a connection attempt with hcidump, I get:

root@OpenWrt:~# hcidump
HCI sniffer - Bluetooth packet analyzer ver 1.42
device: hci0 snap_len: 1028 filter: 0xffffffff
< HCI Command: Create Connection (0x01|0x0005) plen 13
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Connect Complete (0x03) plen 11
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Max Slots Change (0x1b) plen 3
> HCI Event: Command Status (0x0f) plen 4
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Read Remote Supported Features (0x0b) plen 11
< HCI Command: Read Remote Extended Features (0x01|0x001c) plen 3
> HCI Event: Remote Name Req Complete (0x07) plen 255
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Read Remote Extended Features (0x23) plen 13
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
< ACL data: handle 71 flags 0x00 dlen 10
> HCI Event: Number of Completed Packets (0x13) plen 5
> HCI Event: Command Status (0x0f) plen 4
> ACL data: handle 71 flags 0x02 dlen 16
L2CAP(s): Info rsp: type 2 result 0
Extended feature mask 0x0000
< ACL data: handle 71 flags 0x00 dlen 12
> HCI Event: Remote Name Req Complete (0x07) plen 255
> ACL data: handle 71 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0041 scid 0x0040 result 1 status 2
Connection pending - Authorization pending
> HCI Event: Number of Completed Packets (0x13) plen 5
> HCI Event: PIN Code Request (0x16) plen 6
< HCI Command: PIN Code Request Negative Reply (0x01|0x000e) plen 6
> HCI Event: Command Complete (0x0e) plen 10
< HCI Command: PIN Code Request Negative Reply (0x01|0x000e) plen 6
> HCI Event: Command Complete (0x0e) plen 10
> ACL data: handle 71 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0000 scid 0x0040 result 3 status 0
Connection refused - security block
> HCI Event: Disconn Complete (0x05) plen 4

From my perspective, the L2CAP message seems to be at the heart of the problem, since it concludes with connection refused. Is it even supposed to try to connect this way, that's an open question. To compare, here's what I get on my laptop, when the connection is established. The two are obviously different, but I don't know enough yet to understand what is going on.

> HCI Event: Command Status (0x0f) plen 4
Create Connection (0x01|0x0005) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
status 0x00 handle 71 bdaddr 00:06:66:6C:16:54 type ACL encrypt 0x00
> HCI Event: Command Status (0x0f) plen 4
Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 0
> HCI Event: Command Status (0x0f) plen 4
Unknown (0x00|0x0000) status 0x00 ncmd 1
> HCI Event: Read Remote Supported Features (0x0b) plen 11
status 0x00 handle 71
Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x59 0x83
> HCI Event: Command Status (0x0f) plen 4
Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
> HCI Event: Read Remote Extended Features (0x23) plen 13
status 0x00 handle 71 page 1 max 1
Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: Command Status (0x0f) plen 4
Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Remote Name Req Complete (0x07) plen 255
status 0x00 bdaddr 00:06:66:6C:16:54 name 'Muse-1654'
> HCI Event: Command Status (0x0f) plen 4
Authentication Requested (0x01|0x0011) status 0x00 ncmd 1
> HCI Event: Command Complete (0x0e) plen 10
Link Key Request Negative Reply (0x01|0x000c) ncmd 1
status 0x00 bdaddr 00:06:66:6C:16:54
> HCI Event: Command Complete (0x0e) plen 10
IO Capability Request Reply (0x01|0x002b) ncmd 1
status 0x00 bdaddr 00:06:66:6C:16:54
> HCI Event: Command Complete (0x0e) plen 10
User Confirmation Request Reply (0x01|0x002c) ncmd 1
status 0x00 bdaddr 00:06:66:6C:16:54
> HCI Event: Auth Complete (0x06) plen 3
status 0x00 handle 71
> HCI Event: Command Status (0x0f) plen 4
Set Connection Encryption (0x01|0x0013) status 0x00 ncmd 1
> HCI Event: Encrypt Change (0x08) plen 4
status 0x00 handle 71 encrypt 0x01

Anyone to give a few hints on what to look for?

Feel free to ask for any extra information and I'll do my best to provide it.

did you run bluetoothctl with "trust <MAC>" ?

bluez is really badly documented - i wrote something about pairing at:
http://wiki.openwrt.org/wiki/bluetooth.audio

feel free to add / modify information there (maybe mark changes that are different/check the bluez version you are using)
I dont have the overview about that topic atm (there are different pairing modes ...)

(Last edited by zloop on 1 Aug 2015, 10:24)

Hey zloop,

Thanks for the details, I'll test this within the next few days and I'll let you know.

Reading your post about bluetooth audio, I noticed that you were reffering to bluez5. I'm using bluez-libs and bluez-utils 3.36, but these are depreciated version of bluez. And since I have the latest version of bluez on my laptop, I thought that this might the cause of my problem.

I'm a bit of a noob regarding openwrt and linux, but do you mind indicating me where I can find the bluez5 package for openwrt, or should I simply use bluez 5.33 release from the official website.

Hey,

I check and I don't have the bluetoothctl utility on my system. I check in the menuconfig and I can't find it.

I found this:
http://git.kernel.org/pub/scm/bluetooth/bluez.git/

I'll try to build it on my system.

Details about my system:
OS: openwrt
HW: Raspberry Pi 1 model B+ (BCM2835/ARM)

All my code is at:
https://sourceforge.net/projects/atomproducts/

If anybody care at helping me getting this to work. I'm a noob, but a fast learner.

(Last edited by atom2626 on 2 Aug 2015, 21:33)

Update on my attempt at getting this to work.

I tried to include the bluez package into my kernel image. I got a series of dependencies that I tried to satisfy, one after the other (ever in hope that it was the last). So far it doesn't work, nevertheless I'm writing down what I did for anyone interested in doing to same thing or if anyone sees a simple shortcut. Like I said, I'm a noob, and I've trespassed the limit of my knowledge at the moment I opened the topic.

I got the bluez package this way (extract from the makefile):
PKG_NAME:=bluez
PKG_VERSION:=5.33
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.kernel.org/pub/linux/bluetooth/
PKG_MD5SUM:=e7f479e6820b93a63fef56b560f2d975

It had dependencies on udev and glib2, which were availabe in my menuconfig. I only had to make sure that they were built ahead of time. (added +udev, +glib2 to the makefile)

Then libical was needed:
https://github.com/openwrt/packages/blo … l/Makefile
+libical

And libreadline:
https://dev.openwrt.org/browser/package … e?rev=4137
+readline

Then systemd was needed (this is a link to a how-to, which I followed):
https://github.com/jdub/openwrt-systemd
+systemd

Then Perl-XML-parser was needed by systemd...
http://home.mag.cx/openwrt/source/mk/ka … ml-parser/

Which uses ipkg (it's depreciated, I know), but since I'm cross-compiling, I don't have it on my host and I don't have opkg either. I tried to replace the command with dpkg, but I'm not sure if it worked fine.

And now I'm missing libmount... which is part of util-linux:
https://dev.openwrt.org/browser/trunk/p … order=name

And this point however, this is starting to make a lot of changes... and the systemd required me to change compilation from uClibc to eglibc, which, I'm afraid will backfire at one point.

Anyway, I'm going to try a bit more. If it doesn't work, I'll put this aside and try to find another solution.

This seems to be referring to what I'm experiencing with my bluetooth problem, even though the patch hasn't been retained, I might try to modify bluez-utils to incorporate the patch.
http://www.spinics.net/lists/linux-blue … 10266.html

I got it to work.

I'm not sure of what I did, I'll do some test to figure out exactly what has been the turning point. In regard to bluez, I dropped the idea of building bluez5 and used bluez4 instead, which built like a charm.

I'm not sure if it bluez4 that made the difference, but in any case someone needs it:

Bluez4 package:
PKG_NAME:=bluez
PKG_VERSION:=4.101
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.kernel.org/pub/linux/bluetooth/
PKG_MD5SUM:=fb42cb7038c380eb0e2fa208987c96ad

List of dependencies for bluez4:
https://aur.archlinux.org/packages/bluez4/

They were all available in my menuconfig, so I didn't had to search further.

I'll post an update, once I'll have figured out the exact steps to solve the initial problem.

Apparently, all the hassle I went through to build bluez4 (and 5 before), serve nothing.

For my bluetooth, I used packages:
bluez-libs 3.36
bluez-utils 3.36
both found in openwrt old_packages

and I need to enable simple pairing mode with the following command:
#hciconfig hci0 sspmode 1

and this work fine. No more problem.

The discussion might have continued from here.