Windows CE supports the Bluetooth Hands Free Profile Audio Gateway (AG).  This profile allows you to use a Bluetooth headset or car kit as a hands free (HF) device.  This feature is supported on Windows CE 5.0 and Windows Mobile 5.0 (and WM2003 SE).  You can find the Hands Free specification at


On top of routing audio to the HF, this profile allows many other functions like answering/ending/placing a call, redial, memory dial, voice dial, sending DTMF tones, etc.  The Windows CE implementation supports all of the mandatory features along with some optional features.  For a list of supported features (AT commands):


Does this mean that your phone can only take advantage of the features Microsoft has implemented?  Of course not!  The Hands Free Profile has an extensibility mechanism to allow OEMs to handle AT commands coming from the HF:


Some optional features of the Hands Free Profile require that the AG modify its “capability” bit mask in order to claim support for the feature (see HFP spec for details).  You can override the AG capability to include the new optional feature by using the “capability” registry value:


So you can handle new AT commands, but what about controlling the audio connection to the HF?  The AG service (btagsvc.dll) is a module in services.exe.  Applications can send IOControl messages to the service.  The AG supports the following IOControl messages:


Using IOCTL_AG_OPEN_AUDIO and IOCTL_AG_CLOSE_AUDIO you can allow all system audio to use your BT HF instead of the default system speaker/mic.  Keep in mind that BT audio is routed in hardware between the BT baseband module and cellular modem.  Some phones (e.g. HTC Typhoon) will support routing the audio to the OS to enable system sounds and voice dialing over BT, while other phones will only support cellular audio.


Here is a code sample:


    // TODO: Handle failure case where AG is not present

if (FALSE == fStatus) {
    // Failed to open BT audio!
} else {
    // Success!



[Author: Greg Scott]