erwan
Posts: 5
Joined: Sat Jul 19, 2014 1:06 pm

Bluetooth: main.conf seems to be ignored

Sun Sep 14, 2014 4:46 pm

I have a Cambridge Silicon bluetooth dongle for my airplay speaker, I'm trying to make it usable as a bluetooth speaker as well.

I'm having trouble configuring and pairing it. In particular, it seems that none of the config I put in main.conf are ignored: device name, class, discoverability...

Here is hciconfig -a hci0:

Code: Select all

[erwan@alarmpi ~]$ hciconfig -a hci0
hci0:	Type: BR/EDR  Bus: USB
	BD Address: 00:15:83:0C:BF:EB  ACL MTU: 339:8  SCO MTU: 128:2
	UP RUNNING PSCAN ISCAN 
	RX bytes:1217 acl:0 sco:0 events:42 errors:0
	TX bytes:672 acl:0 sco:0 commands:42 errors:0
	Features: 0xff 0x3e 0x85 0x30 0x18 0x18 0x00 0x00
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH HOLD SNIFF 
	Link mode: SLAVE ACCEPT 
	Name: 'alarmpi'
	Class: 0x000104
	Service Classes: Unspecified
	Device Class: Computer, Desktop workstation
	HCI Version: 2.0 (0x3)  Revision: 0xc5c
	LMP Version: 2.0 (0x3)  Subversion: 0xc5c
	Manufacturer: Cambridge Silicon Radio (10)
And my /etc/bluetooth/main.conf :

Code: Select all

[General]

# Default adaper name
# %h - substituted for hostname
# %d - substituted for adapter id
# Defaults to 'BlueZ'
Name = Jukebox

# Default device class. Only the major and minor device class bits are
# considered. Defaults to '0x000000'.
Class = 0x200420

# How long to stay in discoverable mode before going back to non-discoverable
# The value is in seconds. Default is 180, i.e. 3 minutes.
# 0 = disable timer, i.e. stay discoverable forever
DiscoverableTimeout = 0

# How long to stay in pairable mode before going back to non-discoverable
# The value is in seconds. Default is 0.
# 0 = disable timer, i.e. stay pairable forever
PairableTimeout = 0

# Automatic connection for bonded devices driven by platform/user events.
# If a platform plugin uses this mechanism, automatic connections will be
# enabled during the interval defined below. Initially, this feature
# intends to be used to establish connections to ATT channels. Default is 60.
#AutoConnectTimeout = 60

# Use vendor id source (assigner), vendor, product and version information for
# DID profile support. The values are separated by ":" and assigner, VID, PID
# and version.
# Possible vendor id source values: bluetooth, usb (defaults to usb)
#DeviceID = bluetooth:1234:5678:abcd

# Do reverse service discovery for previously unknown devices that connect to
# us. This option is really only needed for qualification since the BITE tester
# doesn't like us doing reverse SDP for some test cases (though there could in
# theory be other useful purposes for this too). Defaults to 'true'.
#ReverseServiceDiscovery = true

# Enable name resolving after inquiry. Set it to 'false' if you don't need
# remote devices name and want shorter discovery cycle. Defaults to 'true'.
#NameResolving = true

# Enable runtime persistency of debug link keys. Default is false which
# makes debug link keys valid only for the duration of the connection
# that they were created for.
#DebugKeys = false

#[Policy]
#
# The ReconnectUUIDs defines the set of remote services that should try
# to be reconnected to in case of a link loss (link supervision
# timeout). The policy plugin should contain a sane set of values by
# default, but this list can be overridden here. By setting the list to
# empty the reconnection feature gets disabled.
#ReconnectUUIDs=
What can cause that, and where should I look to debug this?

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

Re: Bluetooth: main.conf seems to be ignored

Sun Sep 14, 2014 8:46 pm

After much Googling and and trial and error, configuring Bluez remains a mystery to me. There is no official documentation, and so much of the info on various forum posts is either outdated (Bluez 3) or too recent (Bluez 5). But I'll mention some things that may help.

1. According to your hciconfig output, the adapter IS in discoverable mode ('UP RUNNING PSCAN ISCAN'), so that looks like it's working, unless you had set it that way from the command line.
2. For the adapter name, it can specified in two places, /etc/bluetooth/main.conf, and also, once Bluez discovers and creates an adapter, in /var/lib/bluetooth/aa:bb:cc:dd:ee:ff/config (using the BT address of your adapter.) I think this second one is the one actually used (so you can have several adapters with different names.) I'd assume the name in main.conf is used to initialize a new adapter in /var/lib/, but I'm not sure of this. The entire /var/lib/bluetooth/aa:bb:cc:dd:ee:ff/ can be deleted, and it will be recreated at boot time, but you'll lose any pairing/trusting records.
3. For services, I've never decrypted the relationships between the class specified in main.conf, the one specified in /var/lib/bluetooth/aa:bb:cc:dd:ee:ff/config, and actual services specified elsewhere. For example, for A2DP, you'll want to specify services in the /etc/bluetooth/audio.conf file under the [General] section:

Code: Select all

[General]:
Enable=Source,Sink,Media,Socket
Source is needed, Media maybe, not sure about Sink and Socket,
4 You can also list the services offered by the adapter with 'sdptools browse local', and manually add them with 'sdptools add'
(you might have to 'sudo apt-get bluez-utils' for that.)

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

Re: Bluetooth: main.conf seems to be ignored

Mon Sep 15, 2014 12:54 pm

Have you looked at wiki?
https://wiki.archlinux.org/index.php/Bluetooth
Does bluetoothctl show the adapter

Edit, this is best post
https://bbs.archlinux.org/viewtopic.php ... 8#p1376448
This guy has done it on arm, remember pulseaudio doesn't run as root

erwan
Posts: 5
Joined: Sat Jul 19, 2014 1:06 pm

Re: Bluetooth: main.conf seems to be ignored

Mon Sep 15, 2014 8:44 pm

Douglas6: yes indeed, the discoverability was set by command line.

Thank you for the /var/lib/bluetooth thing, indeed I could change the name with that - but for some reason it won't take the Class and discoverability into account. After setting discoverability to on I can see it, but pairing fails.

pepedog: yes, I've seen Arch's doc on bluetooth and it was helpful but not enough to get it to work... Regarding Pulseaudio, is it really necessary? Currently my Raspberry Pi works as an AirPlay speaker, with just Alsa and it works great.

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

Re: Bluetooth: main.conf seems to be ignored

Mon Sep 15, 2014 10:16 pm

You can do the pairing several different ways. It's easiest I think to initiate pairing from the device. You'll need to have a pairing agent running on the Pi, either the blueman Bluetooth Manager if you're running LXDE (desktop), or the bluez-simple-agent command line script (and not both). Search the forum for one or the other for the exact steps. If it's still not working, come back here with the steps you tried and the results (I'm more familiar with the command-line myself)

I've never really looked at setting discoverability on permanently. I'd rather my Pi is discoverable only when I'm looking for it (just prior to pairing).

Yes, for A2DP with Linux, PulseAudio is requisite for all intents and purposes. PA works with Bluez to detect a Bluetooth audio connection, and it will create an audio source on the fly. The only way I know of to do that without PA is with some low-level ALSA / Bluez programming, like this guy did, and he admits it's only a proof-of-concept.

edtoml
Posts: 11
Joined: Fri Dec 21, 2012 11:21 pm

Re: Bluetooth: main.conf seems to be ignored

Wed Sep 17, 2014 6:31 pm

You probably want to use the bluetoothctl program. Works here with arch on both x86 and arm.

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

Re: Bluetooth: main.conf seems to be ignored

Wed Sep 17, 2014 9:41 pm

edtoml wrote:You probably want to use the bluetoothctl program. Works here with arch on both x86 and arm.
Yeah, I keep forgetting about that one. It's really more convenient than having to use separate commands for setting discovery, scanning, pairing, trusting, starting an agent, etc.

tmcneal43
Posts: 1
Joined: Sun Jan 08, 2017 7:59 pm

Re: Bluetooth: main.conf seems to be ignored

Sun Jan 08, 2017 8:05 pm

I ran into this issue recently. The root cause was that the location of my 'main.conf' file was not the location that is expected by BlueZ (v5.43). If you look at 'man bluetoothd' you'll see that the expected location of the config file is '/usr/local/etc/bluetooth/main.conf', however the bluetooth config is located in '/etc/bluetooth/conf'. I was able to fix this by creating the following symlink:

Code: Select all

cd /usr/local/etc
sudo ln -s /etc/bluetooth bluetooth
sudo systemctl daemon-reload && sudo systemctl restart bluetooth.service

rensa
Posts: 2
Joined: Sun Jul 02, 2017 9:41 am

Re: Bluetooth: main.conf seems to be ignored

Sat Aug 12, 2017 8:27 am

I'm having a similar problem with my device class with Bluez 5.23, and unfortunately tmcneal43's solution didn't help. I've also found someone else on SE having it.

In my case, I'm building a Bluetooth speaker, so my /etc/bluetooth/main.conf has:

Code: Select all

[General]
Class=0x20041C
Name=bearspeaker
And my /etc/bluetooth/audio.conf (have tried adding and removing this) has:

Code: Select all

[General]
Class=0x20041C
Enable=Source,Sink,Media,Socket
However, using hciconfig, my controller report as class 0x00041C (no audio service class) and my phone refuses to connect to it. When I first set up the Bluetooth it worked fine, but now the class always changes. If I use hciconfig to change it, the change reverts as soon as I use bluetoothctl to connect to something or turn on discoverability, or when I reboot the service or the whole Pi. Not sure where to go from here :/

Return to “Arch”

Who is online

Users browsing this forum: No registered users and 2 guests