1.3
BlueVoiceADPCM_BNRG1 library software description
1.3.1
Initialization and configuration
To initialize the library call the
BluevoiceADPCM_BNRG1_Initialize
API. Then, configure the library on the
basis of the audio acquisition implemented in the application.
A configuration structure must be filled by setting the audio sampling frequency (FR_8000 or FR_16000), the total
number of channels given as the input to the library and which channel (between 1 and channel_tot) is used for
the voice streaming:
BV_ADPCM_BNRG1_Config_t BV_ADPCM_BNRG1_Config;
BV_ADPCM_BNRG1_Config.sampling_frequency = FR_8000;
BV_ADPCM_BNRG1_Config.channel_in = 1;
BV_ADPCM_BNRG1_Config.channel_tot = 1;
BluevoiceADPCM_BNRG1_SetConfig(&BV_ADPCM_BNRG1_Config);
If the return value is
BV_ADPCM_BNRG1_SUCCESS
, the library has been correctly configured.
The BlueVoiceADPCM_BNRG1 library can be reset by recalling
BluevoiceADPCM_BNRG1_SetConfig
.
The library includes three callbacks that must be called when the corresponding BlueNRG event occurs:
•
BluevoiceADPCM_BNRG1_ConnectionComplete_CB
sets the connection handle when an
EVT_LE_CONN_COMPLETE event occurs;
•
BluevoiceADPCM_BNRG1_DisconnectionComplete_CB
resets internal parameters when an
EVT_DISCONN_COMPLETE event occurs;
•
BluevoiceADPCM_BNRG1_AttributeModified_CB
sets the working mode according to the enable
notification received when an EVT_BLUE_GATT_ATTRIBUTE_MODIFIED event occurs.
A timeout has been included for correct management of the BlueVoice profile status; when the module is no
longer streaming or receiving, the profile status switches to
BV_ADPCM_BNRG1_STATUS_READY
as soon as the
timer expires. The timeout duration (in ms) is defined by
BV_ADPCM_BNRG1_TIMEOUT_STATUS
.
To increase this timer, call the
BluevoiceADPCM_BNRG1_IncTick
function every 1 ms from the
SysTick_Handler.
1.3.2
Working mode setup
The library working mode can be configured as NOT_READY (initial setting), TRANSMITTER, RECEIVER or
HALF-DUPLEX.
The service and characteristics for the BlueVoice profile can be created by calling the
BluevoiceADPCM_BNRG1
_AddService
and
BluevoiceADPCM_BNRG1_AddChar
functions.
Both APIs require the UUIDs (chosen by the user) as parameters and they return the relevant handle.
The handle of the service must be passed to the
BluevoiceADPCM_AddChar
API.
Alternately, BlueVoice characteristics can be added to a pre-existing service created in your own application by
calling
BluevoiceADPCM_BNRG1_AddChar
and passing the handle of that particular service as a parameter.
If both the functions return
BV_ADPCM_BNRG1_SUCCESS
, the library is set to TRANSMITTER mode and can
stream audio over Bluetooth Low Energy.
You can also create the characteristics out of the library and pass the relevant handles using a structure of the
type
BV_ADPCM_BNRG1_ProfileHandle_t
to the
BluevoiceADPCM_BNRG1_SetTxHandle
API. In the latter
case, the following characteristics must be created:
•
related to the compressed audio data
aci_gatt_add_char(ServiceHandle,
UUID_TYPE_128, CharAudioUUID, 20,
CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE,
GATT_DONT_NOTIFY_EVENTS, 16, 1,
CharAudioHandle);
UM2257
BlueVoiceADPCM_BNRG1 library software description
UM2257
-
Rev 2
page 13/35