2009-09-25 03:34:59

by Nick Davies

[permalink] [raw]
Subject: Volume control for headset

Dear all,

I've tried to control the headset's volume via the volume control on my platform. I am curious about how the headset's volume is controlled? Just send some special bluetooth packets to the headset, and then change some registers related with volume control of the headset?

Any explanations are welcome!

Best regards,
Nick







2009-09-25 13:14:43

by Marcel Holtmann

[permalink] [raw]
Subject: Re: Volume control for headset

Hi Nick,

so first of all this mailing list does NOT allow top posting. So don't
do it.

> I'd like to provide you more details about my current situation:
> I download the btsco-5.0 , use the old bt-sco module and daemon to connect the headset with my PC, then I can hear the sound from my headset, but it's not available to control the volume from my PC. So I start to debug this issue.

And this is where you are using old and deprecated software. btsco and
its kernel module is and actually never was supported. Use the method
Johan described.

Regards

Marcel



2009-09-25 12:09:03

by Nick Davies

[permalink] [raw]
Subject: Re: Volume control for headset

Hi all,

I'd like to provide you more details about my current situation:
I download the btsco-5.0 , use the old bt-sco module and daemon to connect the headset with my PC, then I can hear the sound from my headset, but it's not available to control the volume from my PC. So I start to debug this issue.
With Iain's help, I add some codes to send the volume value to the RFCOMM socket after the socket is created by the daemon:

+ char vol[20];
+ int value = 1;
+ int ret;
+ if((value >= 0) && (value <= 15)) {
+ sprintf(vol, "\r\n+VGS=%d\r\n", value);
+ ret = send(socket_name, vol, strlen(vol), MSG_NOSIGNAL);
+ }

I checked the ret value, it's OK, but the headset value isn't changed to 1. Is there something wrong with my approach? Or the signal I've sent is not correct?

Best regards,
Nick



> audio/headset.c
>
> > how can I connect to existing socket?
>
> You can't really but you also shouldn't need to. You can request
> bluetoothd to change the volume using the SetProperty("SpeakerGain", 0-15)
> method on the org.bluez.Headset interface on the D-Bus object that
> represents your headset. There's a python script in the bluez source that
> lets you do it too, e.g:
>
> test/test-telephony speakergain 10
> test/test-telephony microphonegain 5
>
> Johan






2009-09-25 10:54:41

by Johan Hedberg

[permalink] [raw]
Subject: Re: Volume control for headset

Hi,

On Fri, Sep 25, 2009, Nick Davies wrote:
> OK, but I don't know where the RFCOMM socket is created,

audio/headset.c

> how can I connect to existing socket?

You can't really but you also shouldn't need to. You can request
bluetoothd to change the volume using the SetProperty("SpeakerGain", 0-15)
method on the org.bluez.Headset interface on the D-Bus object that
represents your headset. There's a python script in the bluez source that
lets you do it too, e.g:

test/test-telephony <remote address> speakergain 10
test/test-telephony <remote address> microphonegain 5

Johan

2009-09-25 09:34:53

by Nick Davies

[permalink] [raw]
Subject: Re: Volume control for headset

Hi Iain,

Thanks for your quick response! :)

> Yes, it uses a straight serial (over RFCOMM) link with commands/responses
> being sent each way in plaintext. eg from Audio Gateway (computer) to
> Headset:
>
> +VGS=n
>
> set headset speaker volume (0-15)
>
> +VGM=n
>
> set headset microphone gain (0-15)

OK, but I don't know where the RFCOMM socket is created, how can I connect to existing socket?

Best regards,
Nick






2009-09-25 07:38:21

by Iain Hibbert

[permalink] [raw]
Subject: Re: Volume control for headset

On Thu, 24 Sep 2009, Nick Davies wrote:

> I've tried to control the headset's volume via the volume control on
> my platform. I am curious about how the headset's volume is controlled?
> Just send some special bluetooth packets to the headset, and then change
> some registers related with volume control of the headset?

Yes, it uses a straight serial (over RFCOMM) link with commands/responses
being sent each way in plaintext. eg from Audio Gateway (computer) to
Headset:

+VGS=n

set headset speaker volume (0-15)

+VGM=n

set headset microphone gain (0-15)

> Any explanations are welcome!

You can find more information in the "Headset Profile" specification at
http://www.bluetooth.com

regards,
iain