1 (edited by jivex5k 2014-10-03 23:33:22)

Topic: Bluetooth Speaker, Pairing with HCITool CC not working.

Hey guys,
I'm probably doing something wrong here but I've been searching and can't see to find the answer.
I've got an openWRT image that I compiled with bluetooth support running on a HornetUB. I managed to get the bluetooth recognized by adding in the vendor ID to the btusb.c file, works great. I am very low on space though since I've included MPD Audio, and Pulse, basically this HornetUB is going to be an MPD server that connects to multiple bluetooth speakers as pulseaudio sinks.

Anyways, I'm getting ahead of myself here. I mentioned it because maybe the space is causing an issue?

jffs2: Too few erase blocks (2) 

- this is always displayed after booting

Anyways, I run HCItool dev and it's working:

root@OpenWrt:/# hcitool dev
        hci0    5C:F3:70:61:72:0F

hcitool scan works as well

root@OpenWrt:/# hcitool scan
Scanning ...
        00:58:50:00:35:11       MagicBox

So then I try hcitool cc and auth

root@OpenWrt:/# hcitool cc 00:58:50:00:35:11
root@OpenWrt:/# hcitool auth 00:58:50:00:35:11
Not connected.

Not connected. Everything I've looked up so far has referred to editing etc/bluetooth/hcid.conf and changing security to none, tried this and it's still not working.
Also I tried adding 00:58:50:00:35:11 0000 to /var/lib/bluetooth/5C:F3:70:61:72:0F/pincodes
that didn't work either.

I made sure to follow the instructions on the wiki and ran these commands first:

/etc/init.d/dbus enable
/etc/init.d/bluez-utils enable
/etc/init.d/dbus start
/etc/init.d/bluez-utils start

I'm probably just doing something wrong... Maybe I have to pair a different way?
Then I'm going to have to figure out how to get pulse to use it as a sink. I compiled the bluez library with --enable-audio and pulse with --enable-bluez ,  but I think I have to get it paired first...not sure.

Any advice or point in the right direction would be greatly appreciated! Thanks guys, I'll keep toying with it in the meantime.
Going to flash a smaller image with nothing but bluetooth to save space and see if I can at least get that working.

EDIT - Alright I compiled an image that is small enough for no errors with jffs, has bluetooth support but I am having the same exact issue.

2 (edited by jivex5k 2014-10-07 18:09:47)

Re: Bluetooth Speaker, Pairing with HCITool CC not working.

Well I've gotten some more information.
I managed to deduce the connection is completed for a very short period.

root@OpenWrt:/# hcitool scan
Scanning ...
        00:58:50:00:35:11       MagicBox
root@OpenWrt:/# hcitool cc 00:58:50:00:35:11
root@OpenWrt:/# hcitool con
        < ACL 00:58:50:00:35:11 handle 12 state 1 lm MASTER
root@OpenWrt:/# hcitool con

The 2 con commands were run seconds apart, the first I ran as soon as the cc returned my shell.
So it's connected for a short period, then kicked off for whatever reason.
Subsequent scans will not show the speaker. I can cc again, and it will again maintain the connection briefly.

I have used this usb bluetooth transmitter/receiver on my windows OS, and paired it with this magicbox speaker, so both are working.

I've edited my pincodes file here:


To contain:

 00:58:50:00:35:11 0000 

Here is my HCID.conf

# HCI daemon configuration file.

# HCId options
options {
        # Automatically initialize new devices
        autoinit no;

        # Security Manager mode
        #   none - Security manager disabled
        #   auto - Use local PIN for incoming connections
        #   user - Always ask user for a PIN
        security user;

        # Pairing mode
        #   none  - Pairing disabled
        #   multi - Allow pairing with already paired devices
        #   once  - Pair once and deny successive attempts
        pairing multi;

        # Default PIN code for incoming connections
        passkey "0000";

# Default settings for HCI devices
device {
        # Local device name
        #   %d - device id
        #   %h - host name
        name "%h";

        # Local device class
        class 0x000100;

        # Default packet type
        #pkt_type DH1,DM1,HV1;

        # Inquiry and Page scan
        iscan enable; pscan enable;

        # Default link mode
        #   none   - no specific policy
        #   accept - always accept incoming connections
        #   master - become master on incoming connections,
        #            deny role switch on outgoing connections
        lm accept;

        # Default link policy
        #   none    - no specific policy
        #   rswitch - allow role switch
        #   hold    - allow hold mode
        #   sniff   - allow sniff mode
        #   park    - allow park mode
        lp rswitch,hold,sniff,park;

Some more info, the state of the connection seems to be increasing in number:

        < ACL 00:58:50:00:35:11 handle 12 state 1 lm MASTER
root@OpenWrt:/# hcitool -i hci0 con
        < ACL 00:58:50:00:35:11 handle 12 state 8 lm MASTER
root@OpenWrt:/# hcitool -i hci0 con

3 (edited by jivex5k 2014-10-07 19:48:54)

Re: Bluetooth Speaker, Pairing with HCITool CC not working.

More progress, can maintain a connection using RFComm.
I edited hcid.conf and added these lines:

auth enable;
encrypt enable;

Then I enabled simple pairing on hci0:

hciconfig hci0 sspmode 1

Registered the serial port

 sdptool add SP

Then used RFCOMM to connect

 root@OpenWrt:/# rfcomm connect /dev/rfcomm0 00:58:50:00:35:11 1 &
root@OpenWrt:/# Connected /dev/rfcomm0 to 00:58:50:00:35:11 on channel 1
Press CTRL-C for hangup

This successfully paired the speaker, it made the little success noise. Now I have to...well..get it working as an audio speaker. I'm kind of lost at this point but have a few threads to follow and attempt things.

FWIW I think HCItool never sustains the connection now, I believe a lot of tutorials and threads assume a GUI or something else. Using RFComm I can get the connection to stay.

 root@OpenWrt:/# hcitool con
        < ACL 00:58:50:00:35:11 handle 11 state 1 lm MASTER AUTH ENCRYPT

So now I'm going to mess with PCM and see what I can get working. I'll keep posting to this thread.
I feel like I'm getting close now...

Re: Bluetooth Speaker, Pairing with HCITool CC not working.

Progress report.
I've got the image running with ALSA support and enough space to avoid the JFFS error. I actually have the 16MB version of this router on the way so soon I can test it with PulseAudio correctly.

Anyways, I've attempted to directly interface with ALSA, seems like the image is missing support for ALSA bluetooth.
I edited etc/asound.conf to read:

pcm.speaker {
        type plug
        slave {
                pcm {
                        type bluetooth
                        device 00:58:50:00:35:11
                        profile "auto"
ctl.speaker {
        type bluetooth

Doesn't seem to work:

root@OpenWrt:/tmp# alsactl init
alsactl: init:1743: No soundcards found...
root@OpenWrt:/tmp# aplay -l
aplay: device_list:240: no soundcards found...

I can also get it to reference a library that doesn't exist:

root@OpenWrt:/tmp# aplay -D speaker test.wav
ALSA lib dlmisc.c:236:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/alsa-lib/libasound_module_pcm_bluetooth.so
aplay: main:660: audio open error: No such device or address

After some searching it may be related to bluez-util compilation with -disable-audio,

    --disable-glib \
    --enable-pand \
    --enable-rfcomm \
    --enable-dund \
    --enable-serial \
    --enable-network \
    --enable-usb \
    --enable-input \
    --enable-audio \
    --with-bluez="$(STAGING_DIR)/usr/include" \
    --with-usb=yes \

I already had it enabled.
Looks like Bluez 5 doesn't support native alsa bluetooth, but 4 should, openwrt is usuing version 3.36

I'm going to see if I can get version 4 working.
Anyways, hope someone finds this info useful somehow, nobody seems to ever comment on my threads. Not sure if I'm getting etiquette wrong or it's just very obscure, I'll keep posting regardless though.

Re: Bluetooth Speaker, Pairing with HCITool CC not working.

I am very interested in your  bluetooth experience and the thing that can be done with openwrt bluetooth.
As i understand the bluetooth package is a bit old
Please keep posting

6 (edited by jivex5k 2014-10-08 22:45:07)

Re: Bluetooth Speaker, Pairing with HCITool CC not working.

Alright apparently if I can connect with RFComm that means the bluetooth side is working fine.
I've dropped the 12.09 attitude adjustment branch in favor of the dev branch from github.com/openwrt
This has upgraded PulseAudio to 5.0, as well as upgrading MPD. Bluez librarys however are still on 3.6, a far cry from the latest version > 5.

I've come across some people saying to just use PulseAudio with Bluetooth and ALSA, so, I'm compiling images with Pulseaudio 5.0, and Bluez 3.6

I have the --enable-audio flag in the bluez-util makefile
And I have the --enable-bluez flag in the pulseaudio makefile

The newer openwrt branch also supported my bluetooth usb stick out of the box which is nice. No more editing btusb.c to simply add a vendor code.

So I'll report back when I make some more progress using pulse 5.0 and bluez 3.6 together. I can get them both on the hornet with no space issues if I avoid MPD, ultimately though MPD will be installed as well on the 16MB flash hornetUB once it arrives.

It's strange that bluez was never updated yet pulse and mpd were updated very recently in this branch. I had to uncomment the oldpackages entry in the feeds config file to install the bluetooth librarys. (bluez-lib and bluez-utils)

And thanks for the response dude! Glad to hear at least somebody is reading this thread.

Re: Bluetooth Speaker, Pairing with HCITool CC not working.

No luck yet...seems like pulse isn't compiling with bluetooth modules.
Doesn't make sense to me, here's the makefile from pulseaudio:

# Copyright (C) 2011-2014 OpenWrt.org
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.

include $(TOPDIR)/rules.mk






include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk

#TODO: split pulse into executable and library (or even better into several libraries since they're used as loadable modules, so not linked into)
define Package/pulseaudio/Default
  DEPENDS:=+libspeexdsp +libsndfile +libltdl +libpthread +libdbus \
    +librt +alsa-lib +libjson +libopenssl +libwrap +libcap $(ICONV_DEPENDS) $(INTL_DEPENDS)
  TITLE:=Network sound server
  MAINTAINER:=Peter Wagner <tripolar@gmx.at>

define Package/pulseaudio-daemon
  $(call Package/pulseaudio/Default)

define Package/pulseaudio/Default/description
  PulseAudio (formerly Polypaudio) is a cross-platform, networked sound server.

define Package/pulseaudio-daemon/description
  $(call Package/pulseaudio/Default/description)

define Package/pulseaudio-daemon/conffiles

define Package/pulseaudio-tools
  DEPENDS:=+libsndfile pulseaudio
  TITLE:=Tools for Pulseaudio

define Package/pulseaudio-profiles
  TITLE:=Profiles for Pulseaudio

    --with-system-user=pulse \
    --with-system-group=pulse \
    --with-access-group=audio \
    --with-database=simple \
    --enable-alsa \
    --disable-hal \
    --disable-gconf \
    --disable-nls \
    --disable-manpages \
    --enable-oss-output \
    --disable-oss-wrapper \
    --disable-samplerate \
    --disable-per-user-esound-socket \
    --disable-solaris \
    --disable-gtk2 \
    --disable-glib2 \
    --disable-jack \
    --disable-asyncns \
    --disable-lirc \
    --enable-bluez \
    --disable-udev \
    --without-fftw \
    --disable-avahi \


TARGET_CFLAGS += -std=gnu99

define Build/InstallDev
    $(INSTALL_DIR) \
        $(1)/usr/lib/pkgconfig \
        $(1)/usr/include/pulse \
        $(1)/usr/lib \
    $(CP) \
        $(PKG_INSTALL_DIR)/usr/include/pulse/* \
    $(CP) \
        $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc \
    $(CP) \
        $(PKG_INSTALL_DIR)/usr/lib/*.so* \
    $(CP) \
        $(PKG_INSTALL_DIR)/usr/lib/pulseaudio/* \

define Package/pulseaudio-daemon/install
    $(INSTALL_DIR) \
        $(1)/etc/pulse \
        $(1)/etc/init.d \
        $(1)/usr/bin \
        $(1)/usr/lib \
        $(1)/usr/lib/pulseaudio \

    $(INSTALL_BIN) \
        $(PKG_INSTALL_DIR)/usr/bin/pulseaudio \

    $(INSTALL_BIN) \
        ./files/pulseaudio.init \

        $(PKG_INSTALL_DIR)/etc/pulse/* \

    $(CP) \
        $(PKG_INSTALL_DIR)/usr/lib/*.so* \

    $(CP) \
        $(PKG_INSTALL_DIR)/usr/lib/pulseaudio/* \

    $(CP) \
        $(PKG_INSTALL_DIR)/usr/lib/pulse-$(PKG_VERSION)/modules/lib*.so \

    $(CP) \
        $(PKG_INSTALL_DIR)/usr/lib/pulse-$(PKG_VERSION)/modules/module*.so \

    chmod -R 0644 $(1)/etc/pulse/*

define Package/pulseaudio-tools/install
    $(INSTALL_DIR) \

    $(INSTALL_BIN) \
        $(PKG_INSTALL_DIR)/usr/bin/pa* \

define Package/pulseaudio-profiles/install
    $(INSTALL_DIR) \
        $(1)/usr/share/pulseaudio/alsa-mixer/paths \

        $(PKG_INSTALL_DIR)/usr/share/pulseaudio/alsa-mixer/paths/* \

        $(PKG_INSTALL_DIR)/usr/share/pulseaudio/alsa-mixer/profile-sets/* \

$(eval $(call BuildPackage,pulseaudio-daemon))
$(eval $(call BuildPackage,pulseaudio-tools))
$(eval $(call BuildPackage,pulseaudio-profiles))

Getting this:

E: [pulseaudio] ltdl-bind-now.c: Failed to open module module-bluetooth-discover.so: File not found
E: [pulseaudio] module.c: Failed to open module "module-bluetooth-discover".
E: [pulseaudio] main.c: Module load failed.
E: [pulseaudio] main.c: Failed to initialize daemon.
I: [pulseaudio] main.c: Daemon terminated.

Makes sense because:

root@OpenWrt:/usr/lib/pulse-5.0/modules# ls
module-alsa-card.so                 module-native-protocol-tcp.so
module-alsa-sink.so                 module-native-protocol-unix.so
module-alsa-source.so               module-null-sink.so
module-always-sink.so               module-null-source.so
module-augment-properties.so        module-oss.so
module-card-restore.so              module-pipe-sink.so
module-cli-protocol-tcp.so          module-pipe-source.so
module-cli-protocol-unix.so         module-position-event-sounds.so
module-cli.so                       module-raop-sink.so
module-combine-sink.so              module-remap-sink.so
module-combine.so                   module-remap-source.so
module-console-kit.so               module-rescue-streams.so
module-dbus-protocol.so             module-role-cork.so
module-default-device-restore.so    module-role-ducking.so
module-detect.so                    module-rtp-recv.so
module-device-manager.so            module-rtp-send.so
module-device-restore.so            module-rygel-media-server.so
module-echo-cancel.so               module-simple-protocol-tcp.so
module-esound-compat-spawnfd.so     module-simple-protocol-unix.so
module-esound-compat-spawnpid.so    module-sine-source.so
module-esound-protocol-tcp.so       module-sine.so
module-esound-protocol-unix.so      module-stream-restore.so
module-esound-sink.so               module-suspend-on-idle.so
module-filter-apply.so              module-switch-on-connect.so
module-filter-heuristics.so         module-switch-on-port-available.so
module-http-protocol-tcp.so         module-tunnel-sink-new.so
module-http-protocol-unix.so        module-tunnel-sink.so
module-intended-roles.so            module-tunnel-source-new.so
module-ladspa-sink.so               module-tunnel-source.so
module-loopback.so                  module-virtual-sink.so
module-match.so                     module-virtual-source.so
module-mmkbd-evdev.so               module-virtual-surround-sink.so
module-native-protocol-fd.so        module-volume-restore.so

Gotta figure out how to get pulse to compile with the bluetooth modules somehow...I'm in their IRC but no one is very responsive.

8 (edited by pilovis 2014-11-09 17:27:22)

Re: Bluetooth Speaker, Pairing with HCITool CC not working.

I've never been able to get bluetooth working on OpenWRT, neither on  attitude adjustment nor on barrier breaker.

I wasted weeks of testing trying to connect a bluetooth something: cell phone, keyboard, audio speaker or anything else.

There are almost no openwrt bluetooth documentation beside few (negative) blog posts, also openwrt developpers never added a pin pairing helper in the bluetooth packages, why? Laziness?
That seems suspecting, isn't it?

Simply Bluetooth does not work in OpenWrt, is badly broken, end of story.

Electronic engineer, Asterisk Voip and Linux Senior System Administrator.
Speak: fluent English, French and Italian (mother tongue).
Looking for a new job, anywere in the world ;)
My personal forum: http://forum.49v.com