1. Introduction
The Hearing Access Profile is a Bluetooth® LE Audio Profile specified by the Bluetooth SIG. It is categorized as a "use-case profile", meaning that it is a high-layer profile designed for a specific use case. The complete specification can be found on the Bluetooth SIG website[1].
The HAP addresses the use-case of Hearing Aids control over Bluetooth® LE. It specifies audio preset control, immediate alert notification and requirements for LE Audio profiles.
2. HAP Specification
The full HAP specification is available on the Bluetooth Website [1].
2.1. Roles
The HAP introduces four different roles:
- Hearing Aid (HA): Role implemented by hearing aids. Can receive audio stream as Unicast Server and implement Hearing Access Service as Server to allow remote devices to control local audio presets.
- Hearing Aid Unicast Client (HAUC): Connects to hearing aids to stream audio data as Unicast Client. Examples of device implementing this role are smartphones, laptops, media players, TV, tablets, and PCs.
- Hearing Aid Remote Controller (HARC): Connects to hearing aids and control audio presets, volume and microphone status. Implements Hearing Access Service as Client role. Examples of device implementing this role are smartphones, tablets and remote controllers.
- Immediate Alert Client (IAC): Connects to hearing aids to emit alert notification to capture the attention of the hearing aid wearer. Example of devices implementing this role are smartphone , tablets, laptops and home appliances.
The requirements for the four roles are the following:
HAP Role | CAP Roles | BAP Roles | GAP Roles | VCP Roles |
---|---|---|---|---|
Hearing Aid (HA) | Acceptor | Unicast Server | Peripheral | Volume Renderer |
Hearing Aid Unicast Client (HAUC) | Initiator | Unicast Client | Central | None |
Hearing Aid Remote Controller (HARC) | Commander | None | Central | Volume Controller |
Immediate Alert Client (IAC) | None | None | None | None |
2.2. Hearing Aid Presets
The major feature introduced by the Hearing Aid Profile is the preset selection, using the Hearing Access Service. A device implementing the HAP HA role can declare one or multiple hearing aid presets, which will be exposed to a remote device implementing the HARC role using the HAS.
Examples of hearing aid presets are "Normal", "Noise Reduction", "Telecoil" and "Outdoor". These presets are manufacturer specific and the HAS is only used as a way to transmit the device capabilities and to permit control over them.
2.3. Hearing Aid Features
A device implementing HAP with HA role exposes their Hearing Aid Features. The following tables details the different features and their possible values. The possible values should be used as a bitfield to create a Hearing Aid Features value.
Feature | Description | Value(s) |
---|---|---|
Hearing Aid Type | Indicates if the hearing aid is part of a Binaural hearing aid set (2 different devices for the 2 ears), is a Monaural Hearing Aid (only one hearing aid for one ear) or is a Banded Hearing Aid (one device covering the 2 ears) | HAP_HA_TYPE_BINAURAL_HEARING_AID HAP_HA_TYPE_MONAURAL_HEARING_AID HAP_HA_TYPE_BANDED_HEARING_AID |
Preset Synchronization Support | In case of a Binaural Hearing Aid, indicates if the hearing aid is able to relay the active preset to the other hearing aid in the set or if this action should be handled by the Hearing Aid Remote Controller | HAP_PRESET_SYNC_SUPPORTED if preset sync is supported |
Independent Presets | In case of a Binaural hearing aid, indicates if the list of preset records of the hearing aid is identical to the list of preset records on the other hearing aid | HAP_INDEPENDANT_PRESETS if presets are independent |
Dynamic Presets | Indicates if the list of preset records of the hearing aid can change or not | HAP_DYNAMIC_PRESETS if the list of preset records can change |
Writable Presets Support | Indicates if the hearing aid supports modifications performed by the Hearing Aid Remote Controller on its preset records | HAP_WRITABLE_PRESETS_SUPPORTED if writable preset records is supported |
2.4. HAP Advertising
A device implementing HAP with HA role shall put the Hearing Access Service UUID in the Service UUID AD Type field of its advertising data.
2.5. Hearing Access Service (HAS)
A device implementing the HA role shall implement the GATT server role with one instance of Hearing Access Service. This service permits remote HARC to control local Audio Presets when connected.
3. Hearing Access Profile application APIs
The following section lists and describes the APIs typically used in a HAP application.
3.1. HAP HA APIs
The following APIs are available for the HAP in HA Role:
HAP_Init | Initialize the Hearing Access Profile with the selected role(s) |
HAP_HA_BuildAdvPacket | Build HAP HA advertising packet with the concatenation of CAP Advertising data, HAS UUID and Appearance |
HAP_HA_SetHearingAidFeatures | Set the local Hearing Aids Features value |
HAP_HA_AddPreset | Add a new local preset |
HAP_HA_RemovePreset | Remove a local preset |
HAP_HA_SetPresetAvailability | Set the availability value of a local preset |
HAP_HA_EditPreset | Edit a local preset |
HAP_HA_SetActivePresetIndex | Set the local Active Preset Index value |
HAP_HA_DB_IsPresent | Indicate if HAP HA Database is saved in NVM |
HAP_HA_DB_RemoveServicesRecord | Remove the record of the HAP HA stored in NVM |
3.2. HAP HAUC APIs
There are no HAP HAUC specific APIs, refer to CAP Unicast Client APIs.
3.3. HAP HARC APIs
The following APIs are available for the HAP in HARC Role:
HAP_Init | Initialize the Hearing Access Profile with the selected roles |
HAP_Linkup | Link Up the HAP Client roles with remote HAP HA |
HAP_HARC_ReadHAFeatures | Read the remote Hearing Aid Features |
HAP_HARC_ReadActivePresetIndex | Read the remote Active Preset Index |
HAP_HARC_ReadPresetsRequest | Send a request to read remote HAP Server presets |
HAP_HARC_WritePresetName | Send a Write Preset Name command |
HAP_HARC_SetActivePreset | Set preset with specified index on remote HAP Server |
HAP_HARC_SetNextPreset | Set next preset on remote HAP Server |
HAP_HARC_SetPreviousPreset | Set previous preset on remote HAP Server |
HAP_HARC_DB_IsPresent | Indicate if HAP HARC Database is saved in NVM |
HAP_HARC_DB_RemoveServicesRecord | Remove the record of the HAP HARC stored in NVM |
3.4. HAP IAC APIs
The following APIs are available for the HAP in IAC Role:
HAP_Init | Initialize the Hearing Access Profile with the selected roles |
HAP_Linkup | Link Up the HAP Client roles with remote HAP HA |
HAP_IAC_SetAlertLevel | Set Alert Level on remote Immediate Alert Server |
HAP_IAC_DB_IsPresent | Indicate if HAP IAC Database is saved in NVM |
HAP_IAC_DB_RemoveServicesRecord | Remove the record of the HAP IAC stored in the NVM |
3.5. HAP initialization
1. First, initialize the use-case device management module:
USECASE_DEV_MGMT_Init();
2. Then, initialize the HAP with a HAP_Role_t bitfield:
HAP_Role_t role = HAP_ROLE_HEARING_AID;
HAP_Init(role);
3. Additionally, as a Hearing Aid device, specify the Hearing Aid Features and add supported presets with :
/* Store the index of the added preset */
uint8_t pres_index;
/* Set Hearing aid features */
HAP_HA_SetHearingAidFeatures(HAP_HA_TYPE_BANDED_HEARING_AID|HAP_DYNAMIC_PRESETS);
/* Add Presets */
HAP_HA_AddPreset(HAP_PRESET_PROPERTIES_IS_AVAILABLE, "Normal", 6, &pres_index);
HAP_HA_AddPreset(HAP_PRESET_PROPERTIES_IS_AVAILABLE, "Outdoor", 7, &pres_index);
/* Sec Active Preset */
HAP_HA_SetActivePresetIndex(pres_index);
3.6. Linkup remote HAP server
To perform linkup on a remote HAP server as HAP HARC, use the dedicated API. If a database is already present, use the Restore mode.
/* Check if HAP link is present in NVM from a previous connection*/
if (HAP_DB_IsPresent(p_conn->Peer_Address_Type,p_conn->Peer_Address) == 0)
{
HAP_Linkup(ConnHandle, HAP_LINKUP_MODE_COMPLETE);
}
else
{
HAP_Linkup(pNotification->ConnHandle,HAP_LINKUP_MODE_RESTORE);
}
During the linkup process, the HAP_LINKUP_COMPLETE_EVT, HAP_HARC_HA_FEATURES_EVT and HAP_HARC_ACTIVE_PRESET_INDEX_EVT events are generated:
void HAP_Notification(HAP_Notification_Evt_t *pNotification)
{
switch(pNotification->EvtOpcode)
{
case HAP_LINKUP_COMPLETE_EVT:
{
break;
}
case HAP_HARC_HA_FEATURES_EVT:
{
HAP_HA_Features_t ha_features = pNotification->pInfo[0];
break;
}
case HAP_HARC_ACTIVE_PRESET_INDEX_EVT:
{
uint8_t active_preset_index = pNotification->pInfo[0];
break;
}
}
}
4. HAP demonstrator using STM32WBA
The STM32WBA cube firmware allows to easily build and deploy HAP Peripheral and HAP Central applications.
4.1. Project architecture
The figure below represents the firmware architecture of the HAP Peripheral/Central example projects inside STM32CubeWBA MCU package.
The two HAP projects present in STM32WBA cube firmware implement a menu displayed on the OLED Screen of the STM32WBA55G-DK or the STM32WBA65I-DK boards.
4.2.1. HAP Peripheral screens
The following diagram show and describes the screens on the HAP Peripheral application:
The Audio Config submenu in the Startup Menu allows to configure the device type of the local HAP Peripheral device (Select the configuration with Joystick Up/Down and valid with Joystick Left) :
- Banded HA (default)
- Right Binaural HA
- Left Binaural HA
- Monaural HA
Left Binaural HA and Right Binaural HA are types of device identified as a Set Member of a Coordinated Set (see Coordinated Devices wiki page). When launching a HAP Peripheral project on a board in Left Binaural HA configuration and another one on a board in Right Binaural HA configuration, the two boards form a Coordinated Set. A remote HAP Central device ( Set Coordinator) would then be able to identify the two boards as a Coordinated Set in its audio feature processes.
4.2.2. HAP Central Screens
The following diagram shows and describes the screens on the HAP Central application:
4.2.3. Audio streaming state screen
On the two HAP applications, the screen displays the status of the audio stream when connected. The following table describes each possible screen:
4.3. Unicast Demo using two STM32WBA
4.3.1. Hardware required
This demonstrator requires the following hardware:
- 2x STM32WBA55G-DK or STM32WBA65I-DK boards
- 1x Headphones/Headset with a 3.5mm jack cable, optionally with a microphone in which case the jack is 4-pin.
Additionally, as an audio source on the HAP Central side, one of the following can be used:
- 1x music source with a 3.5mm jack output (Laptop or smartphone with a jack output). If the music source is powered using a power supply, use a Ground Loop isolator device or run the laptop on a battery to avoid Ground Loop issues
- 1x headset with microphone
4.3.2. Setup
The setup is as follows:
4.3.3. Operate demonstrator
The two projects integrate a menu permitting to operate the demonstrator.
1. To establish the connection between the two STM32WBAs, press the right direction on the joystick of the HAP Peripheral and select "Start Adv." to start advertising, then press the right direction on the joystick of the HAP Central and select "Start Scan" to start scanning. Select your device in the list and press the right direction to initiate the connection.
2. Once the linkup is done on each side, access the menu using the right direction of the joystick
- To start or stop an audio stream, navigate to the “Audio stream” submenu on the HAP Central target and select the desired item list
- To operate the HAP Central volume, navigate to the “Local volume” on the HAP Central target
- To operate the HAP Peripheral volume, navigate to the “Remote Volume” submenu on the HAP Central target, or navigate to the “Volume” submenu on the HAP Peripheral target
- To control the HAP Peripheral microphone mute status, navigate to the “Microphone” submenu on the HAP Central or Peripheral target
- To control the HAP Peripheral active preset, navigate to the “Preset” submenu on the HAP Central or Peripheral target
The following configurations are used in the HAP Central project:
Configuration | BAP audio configuration | Legend | Codec configuration |
---|---|---|---|
Media | 6(i) | -------> -------> |
24_2 |
Telephony | 3 | <-------> | 16_2 |
5. References