2008-02-07 19:05:09

by Peter Wurmsdobler

[permalink] [raw]
Subject: [Bluez-users] Headset, ALSA and other issues

Hello,

It was not trivial to sucessfully connect to my BlueTooth development
module apm6628 (based on CSR BlueCore4-ROM) over RS232. After some
initial problems the device appears in 90% of trials as hci0 using:

hciattach /dev/ttyS0 bcsp 57600 flow
hciconfig hci0 up
bccmd -t hci psload -r apm6628BT-UART.psr
killall hciattach
sleep 1
hciattach /dev/ttyS0 bcsp 115200 flow
hciconfig hci0 up

Where the uncertainly und unreliability comes from is still a mistery
for me. Nevertheless, "hcitool scan" discovers neighbouring bluetooth
devices, such as the Nokia BH-202 headset with its detailed information:

peter@pc:~$ hcitool info 00:16:8F:EB:6E:53
Requesting information ...
BD Address: 00:16:8F:EB:6E:53
Device Name: Nokia BH-202
LMP Version: 2.0 (0x3) LMP Subversion: 0x978
Manufacturer: Cambridge Silicon Radio (10)
Features: 0xfd 0xfe 0x8b 0x80 0x0b 0xa8 0x00 0x80
<3-slot packets> <encryption> <slot offset> <timing accuracy>
<role switch> <hold mode> <sniff mode> <RSSI>
<channel quality> <SCO link> <HV2 packets> <HV3 packets>
<u-law log> <A-law log> <CVSD> <paging scheme>
<transparent SCO> <broadcast encrypt> <extended SCO>
<EV4 packets> <EV5 packets> <AFH cap. slave> <AFH cap. master>
<EDR eSCO 2 Mbps> <3-slot EDR eSCO> <extended features>

"rfcomm bind all" binds the device to /dev/rfcomm0 using the appropriate
/etc/bluetooth/rfcomm.conf :

rfcomm0 {
bind yes;
device 00:16:8F:EB:6E:53;
channel 1;
}

peter@pc:~$ rfcomm
rfcomm0: 00:16:8F:EB:6E:53 channel 1 clean


As a next step I would like to pair my host PC with the headset and send
an audio stream. Even after searching along a lot of documentation on
various web sites, I do not quite succeed:

peter@pc:~$ mplayer -ao alsa:device=bluetooth test.wav
MPlayer 2:1.0~rc1-0ubuntu13.1 (C) 2000-2006 MPlayer Team
CPU: Intel(R) Core(TM)2 Duo CPU E6550 @ 2.33GHz (Family: 6, Model:
15, Stepping: 11)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote
control.

Playing test.wav.
Audio file file format detected.
==========================================================================
Forced audio codec: mad
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 8000 Hz, 1 ch, u8, 64.0 kbit/100.00% (ratio: 8000->8000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
alsa-lib: pcm_bluetooth.c:1261:(bluetooth_init) Connection fail
alsa-init: playback open error: Connection refused
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video

Exiting... (End of file)


The configuration files are:

/etc/bluetooth/audio.conf
[General]
SCORouting=HCI
[Headset]
DisableHFP=false
pcm.bluetooth {
type bluetooth
device "00:16:8F:EB:6E:53"
}

~/.asoundrc
pcm.bluetooth {
type bluetooth
device "00:16:8F:EB:6E:53"
}


I guess I am missing something essential, and there are a few missing
links in my understanding how things have to be set up.

Assuming that hcid's role is to discover dynamically bluetooth devices,
does hcid have to run if there is anyway only one fixed bluetooth device
connected to the system?

How does an audio player, or consequently the ALSA sound system know
where to send the PCM synchonous data to such that the bluetooth
subsystem can transmit them?

Who takes the responsibility to negotiate to the headset over
/dev/rfcomm0 and to establish the SCO connection?

Who opens a connection to the hci0 socket to pipe the PCM data into it?

What role does the dbus play in this game?

Browsing through the BlueZ-utils code, I get a rough idea, but not the
big picture how things hang together. Is there somebody on the list who
happens to life somewhere in Europe (or in a timezon +- a fe hours from
GMT) and who can spare a few minutes for a phone chat?

Time and number can be arranged over peter at wurmsdobler dot org, and
as far as the language is concerend, English, German and French are
fine. If in Cambridge, UK, I am happy to pay a few pints in a local pub.

Regards,
peter



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users


2008-02-08 09:34:14

by Peter Wurmsdobler

[permalink] [raw]
Subject: Re: [Bluez-users] Headset, ALSA and other issues

Hello Johan,
> The preferred way would be to use the BlueZ D-Bus interface, but I'm
> not aware of any nice UI to do it (e.g. the bluetooth-wizard from
> bluez-gnome is still incomplete).
I had this wizard running on the desktop, but I am not very happy with
it as it is not clear how it happens, what happens and also it is not
predictible enough.

> You can however find some examples
> of running dbus-send from the command line and example python scripts
> here:
> http://wiki.bluez.org/wiki/HOWTO/Bonding
Thanks, I will have a look at it.

If a "client" would send requests on the dbus, who would be the
receiver? WOuld it have to be hcid?

As mentioned earlier, the entire bt system appears to me very woolly;
difficult to get a grip onit.

peter



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2008-02-08 09:26:36

by Johan Hedberg

[permalink] [raw]
Subject: Re: [Bluez-users] Headset, ALSA and other issues


On Feb 8, 2008, at 11:05, Peter Wurmsdobler wrote:
>> Do you have them paired?
> Well here I am not so sure. I know that this is necessary, but how
> can I
> make pairing happen? is there an hcitool command?

The preferred way would be to use the BlueZ D-Bus interface, but I'm
not aware of any nice UI to do it (e.g. the bluetooth-wizard from
bluez-gnome is still incomplete). You can however find some examples
of running dbus-send from the command line and example python scripts
here:
http://wiki.bluez.org/wiki/HOWTO/Bonding

Johan

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2008-02-08 09:05:07

by Peter Wurmsdobler

[permalink] [raw]
Subject: Re: [Bluez-users] Headset, ALSA and other issues

Hello Brian,
> Do you have them paired?
Well here I am not so sure. I know that this is necessary, but how can I
make pairing happen? is there an hcitool command?
peter


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2008-02-08 01:06:39

by Brian Sammon

[permalink] [raw]
Subject: Re: [Bluez-users] Headset, ALSA and other issues

I found it easier to focus on pairing the devices, before I worry about
playing sound.
Do you have them paired?
To figure that out, look in /var/lib/bluetooth/ . There should be a directory
named for the MAC address of the bluetooth adaptor (local device). In that
directory should be a file "linkkeys" which will list all the devices that it
is paired with. In particular, you hope that the file contains the MAC
address of the headset.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2008-02-07 22:59:33

by Rod Boyce

[permalink] [raw]
Subject: Re: [Bluez-users] Headset, ALSA and other issues

Peter,

You are going to have problems emptying the UART FIFO's fast enough on
your target hardware at a baud rate fast enough to transfer audio I know
I have seen these issues before.
You would be better using another medium for the transport USB or SPI or
something other than a UART.

Regards.
Rod Boyce

Peter Wurmsdobler wrote:
> Hello,
>
>> 115k is probably too slow to be workable for audio. That's one reason
>> it's more common to connect the adapter to the pc over usb.
>>
> you are right in principal. One thing I neglected to mention, however,
> is that the target hardware is based on the imx27 ADS board. We are
> going to use the hardware facilities, i.e. UART to the BC4-ROM for
> control, and PCM over SSI. How this is going to work in terms of routing
> the signals through ALSA and the Linux kernel, I hope to find out soon.
>
> peter
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Bluez-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bluez-users
>
>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2008-02-07 22:52:49

by Brad Midgley

[permalink] [raw]
Subject: Re: [Bluez-users] Headset, ALSA and other issues

Peter

Yes, it will work if using pcm routing. Be sure to configure
/etc/bluetooth/audio.conf for pcm routing. That's how nokia uses the
audio service in the n810.

Brad

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2008-02-07 22:43:41

by Peter Wurmsdobler

[permalink] [raw]
Subject: Re: [Bluez-users] Headset, ALSA and other issues

Hello,
> 115k is probably too slow to be workable for audio. That's one reason
> it's more common to connect the adapter to the pc over usb.
you are right in principal. One thing I neglected to mention, however,
is that the target hardware is based on the imx27 ADS board. We are
going to use the hardware facilities, i.e. UART to the BC4-ROM for
control, and PCM over SSI. How this is going to work in terms of routing
the signals through ALSA and the Linux kernel, I hope to find out soon.

peter



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2008-02-07 19:49:30

by Brad Midgley

[permalink] [raw]
Subject: Re: [Bluez-users] Headset, ALSA and other issues

Peter

> hciattach /dev/ttyS0 bcsp 115200 flow

115k is probably too slow to be workable for audio. That's one reason
it's more common to connect the adapter to the pc over usb.

--
Brad

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users