Bluetooth headset profile (HSP) - accessing AT command VGM for mic volume

1,413 views
Skip to first unread message

D Wong

unread,
Mar 13, 2011, 5:23:57 AM3/13/11
to android-platform

While HSP support is functionally available Android 1.x, the API for
java applications only appeared since 2.0. So far this API partially
exposes the functionality of the underlying Bluez protocol stack and
utilities.

Currently I am tasked to create an application to (i) control the mic
volume on the Bluetooth (BT) headset from the Android host; (ii)
detect any changes in the mic volume setting on the headset initiated
by the headset user.

The firmware on the BT headset is already programmed to handle the
above by using (i) unsolicited result code VGM in the host to headset
direction; and (ii) AT+VGM from the headset to host.

On the Android host, apparently the AT+VGM command is handled in the
Bluez file gateway.c already, and for sending the unsolicited result
code +VGM in headset.c correspondingly. What is not obvious is a
mechanism for a java application to (i) be alerted about an incoming AT
+VGM (because there is no "intent" defined for it); and (ii) trigger
an outgoing +VGM to any specific mic volume level.

I have considered a number of options, which I believe are all
overkills:

1. Substitute the official API by entending an unofficial one (such as
http://code.google.com/p/android-bluetooth by Stefano Sanna's team)
2. Hack up some native code to access the DBus directly.
3. Put in a request for the support for handling AT+VGM and triggering
+VGM in the list to be considered for future BluetoothHeadset
releases.

Anyone with a neater solution would be greatly appreciated.

D Wong

jaikumar Ganesh

unread,
Mar 14, 2011, 1:40:48 PM3/14/11
to android-...@googlegroups.com, D Wong
On Sun, Mar 13, 2011 at 1:23 AM, D Wong <dykw...@gmail.com> wrote:
>
> While HSP support is functionally available Android 1.x, the API for
> java applications only appeared since 2.0. So far this API partially
> exposes the functionality of the underlying Bluez protocol stack and
> utilities.
>
> Currently I am tasked to create an application to (i) control the mic
> volume on the Bluetooth (BT) headset from the Android host; (ii)
> detect any changes in the mic volume setting on the headset initiated
> by the headset user.
>
> The firmware on the BT headset is already programmed to handle the
> above by using (i) unsolicited result code VGM in the host to headset
> direction; and (ii) AT+VGM from the headset to host.
>
> On the Android host, apparently the AT+VGM command is handled in the
> Bluez file gateway.c already, and for sending the unsolicited result
> code +VGM in headset.c correspondingly. What is not obvious is a
> mechanism for a java application to (i) be alerted about an incoming AT
> +VGM (because there is no "intent" defined for it); and (ii) trigger
> an outgoing +VGM to any specific mic volume level.

Android doesn't use Bluez implement of HSP profile.
The Android implementation is at BluetoothHandsfree.java where the
AT+VGM commands are registered.
So you already have information at the java layer about this.

>
> I have considered a number of options, which I believe are all
> overkills:
>
> 1. Substitute the official API by entending an unofficial one (such as
> http://code.google.com/p/android-bluetooth by Stefano Sanna's team)
> 2. Hack up some native code to access the DBus directly.
> 3. Put in a request for the support for handling AT+VGM and triggering
> +VGM in the list to be considered for future BluetoothHeadset
> releases.
>
> Anyone with a neater solution would be greatly appreciated.
>
> D Wong
>

> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.
>
>

D Wong

unread,
Mar 15, 2011, 12:20:41 AM3/15/11
to android-platform


On Mar 15, 1:40 am, jaikumar Ganesh <jaikum...@gmail.com> wrote:
> On Sun, Mar 13, 2011 at 1:23 AM, D Wong <dykwo...@gmail.com> wrote:
>
> > WhileHSPsupport is functionally available Android 1.x, the API for
> > java applications only appeared since 2.0. So far this API partially
> > exposes the functionality of the underlying Bluez protocol stack and
> > utilities.
>
> > Currently I am tasked to create an application to (i) control the mic
> > volume on the Bluetooth (BT) headset from the Android host; (ii)
> > detect any changes in the mic volume setting on the headset initiated
> > by the headset user.
>
> > The firmware on the BT headset is already programmed to handle the
> > above by using (i) unsolicited result code VGM in the host to headset
> > direction; and (ii) AT+VGM from the headset to host.
>
> > On the Android host, apparently the AT+VGM command is handled in the
> > Bluez file gateway.c already, and for sending the unsolicited result
> > code +VGM in headset.c correspondingly. What is not obvious is a
> > mechanism for a java application to (i) be alerted about an incoming AT
> > +VGM (because there is no "intent" defined for it); and (ii) trigger
> > an outgoing +VGM to any specific mic volume level.
>
> Android doesn't use Bluez implement ofHSPprofile.
> The Android implementation is at BluetoothHandsfree.java where the
> AT+VGM commands are registered.
> So you already have information at the java layer about this.
>

Oh yes, there is BluetoothHandsfree.java. It handles the AT+VGM
command from the Bluetooth headset by sending the response code "OK".
But there appears to be no public access to either the received mic
volume, nor a means to send a mic volume setting to the headset.

In contrast with AT+VGM, the speaker volume setting received from AT
+VGS is exported to the AudioManager. In the reverse direction, public
method sendScoGainUpdate() is available for sending any arbitrary
speaker volume to the headset.

From Android 3.0, the class BluetoothHeadset is available, and it
appears to offer a lot more, but it does not help with the masses of
Android phones at earlier API levels.

Any further information or correction would be greatly appreciated.

>
>
> > I have considered a number of options, which I believe are all
> > overkills:
>
> > 1. Substitute the official API by entending an unofficial one (such as
> >http://code.google.com/p/android-bluetoothby Stefano Sanna's team)

jaikumar Ganesh

unread,
Mar 15, 2011, 1:18:28 AM3/15/11
to android-...@googlegroups.com, D Wong

Yes VGM is not integrated like VGS. And I thought you are working on a
patch to implement this
that you can submit back.

D Wong

unread,
Mar 15, 2011, 1:09:55 PM3/15/11
to android-platform


On Mar 15, 1:18 pm, jaikumar Ganesh <jaikum...@gmail.com> wrote:
So, back to the original question, does anyone know how an AT+VGM
command from a Bluetooth headset could get be handled by an
application, especially on Android 1.6 and 2.0?

Similarly what about the trigger to send the +VGM result codes from
the Android device back to the headset?

Many thanks in advance.

>
> > Any further information or correction would be greatly appreciated.
>
> >> > I have considered a number of options, which I believe are all
> >> > overkills:
>
> >> > 1. Substitute the official API by entending an unofficial one (such as
> >> >http://code.google.com/p/android-bluetoothbyStefano Sanna's team)

jaikumar Ganesh

unread,
Mar 15, 2011, 4:20:30 PM3/15/11
to android-...@googlegroups.com, D Wong
There is no public API for this.

If will have to hack up something in BluetoothHandsfree.java if your want it.

D Wong

unread,
Mar 21, 2011, 9:42:58 AM3/21/11
to android-platform


On Mar 16, 4:20 am, jaikumar Ganesh <jaikum...@gmail.com> wrote:
> There is no public API for this.
>
> If will have to hack up something in BluetoothHandsfree.java if your want it.

Hacking BluetoothHandsfree.java is viable, but rooting the phone
before the user could enjoy the functionality is not really
acceptable. (voiding warranties, complexity, likelihood of things
going wrong...)

So it looks like AT+VGM has hit a dead-end for the time being.

Many thanks.
> >> >> >http://code.google.com/p/android-bluetoothbyStefanoSanna's team)
Reply all
Reply to author
Forward
0 new messages