ST STEVAL-BLUEMIC-1 User manual

July 2017
DocID030830 Rev 1
1/38
www.st.com
UM2257
User manual
Getting started with the STEVAL-BLUEMIC-1 evaluation board,
ultra-low power wireless microphone based on SPBTLE-1S module
Introduction
The STEVAL-BLUEMIC-1 evaluation board mounts the SPBTLE-1S Bluetooth®SMART application
processor compliant with BT specification v4.2. It supports multiple simultaneous roles and can act as a
Bluetooth Smart master and slave device at the same time.
This BLE wireless battery powered solution also embeds digital MEMS microphone MP34DT04-C1 and
3D accelerometer + 3D gyroscope, which render this evaluation board suitable for a wide range of
advanced smart application.
The evaluation board comes with a complete SW development kit that includes the Bluetooth low
energy stack, all the needed drivers for audio and inertial data acquisition, and button and LED
management. A ready-to-use BlueVoice library is included as middleware and a sample application is
provided to get you started with voice streaming over BLE to an Android or iOS device, running the ST
BlueMS apps.
Figure 1: STEVAL-BLUEMIC-1 evaluation board

Contents
UM2257
2/38
DocID030830 Rev 1
Contents
1Getting started.................................................................................5
1.1 Hardware description........................................................................5
1.1.1 Features ............................................................................................. 5
1.1.2 Evaluation kit ...................................................................................... 5
1.1.3 Evaluation board................................................................................. 7
1.1.4 Schematic diagrams........................................................................... 9
1.2 Software description........................................................................11
1.2.1 Overview........................................................................................... 11
1.2.2 Architecture ...................................................................................... 11
1.2.3 Folder structure ................................................................................ 12
1.2.4 APIs.................................................................................................. 12
1.2.5 BlueMic1 application......................................................................... 12
1.2.6 Audio processing.............................................................................. 14
1.2.7 ADPCM compression....................................................................... 15
1.2.8 Packetization .................................................................................... 16
1.2.9 STSW-BLUEMIC-1 application description...................................... 17
1.3 BlueVoiceADPCM_BNRG1 library software description .................18
1.3.1 Initialization and configuration.......................................................... 18
1.3.2 Working mode setup......................................................................... 18
1.3.3 Audio signal injection........................................................................ 19
1.3.4 Compressed audio streaming .......................................................... 19
2System setup.................................................................................21
2.1 Power supply...................................................................................21
2.2 STEVAL-BLUEMIC-1 evaluation board assembly in form factor
case 21
2.3 STEVAL-BLUEMIC-1 evaluation board programming interface......22
2.4 STEVAL-BLUEMIC-1 evaluation board demos...............................23
2.4.1 Streaming to a mobile device........................................................... 23
2.5 Streaming to an STM32 Nucleo board used as a receiver..............35
3Revision history ............................................................................37

UM2257
List of tables
DocID030830 Rev 1
3/38
List of tables
Table 1: STEVAL-BLUEMIC-1 evaluation board main component details.................................................8
Table 2: BlueMic1 UUID summary table...................................................................................................14
Table 3: Document revision history ..........................................................................................................37

List of figures
UM2257
4/38
DocID030830 Rev 1
List of figures
Figure 1: STEVAL-BLUEMIC-1 evaluation board.......................................................................................1
Figure 2: STEVAL-BLUEMIC-1 evaluation kit............................................................................................5
Figure 3: STEVAL-BLUEMIC-1 evaluation board: top and bottom ............................................................6
Figure 4: Battery .........................................................................................................................................6
Figure 5: Plastic case..................................................................................................................................6
Figure 6: SWD cable...................................................................................................................................6
Figure 7: STEVAL-BLUEMIC-1 evaluation board hardware architecture...................................................7
Figure 8: STEVAL-BLUEMIC-1 evaluation board main components.........................................................7
Figure 9: Power and SPBTLE-1S module..................................................................................................9
Figure 10: MEMS, button and LEDs.........................................................................................................10
Figure 11: STSW-BLUEMIC-1 software architecture ...............................................................................11
Figure 12: STSW-BLUEMIC-1 folder structure.........................................................................................12
Figure 13: STSW-BLUEMIC-1 audio processing chain............................................................................14
Figure 14: ADPCM encode-decode schema............................................................................................15
Figure 15: ADPCM packet mechanism.....................................................................................................16
Figure 16: BLE packets for 16 Hz audio...................................................................................................17
Figure 17: STSW-BLUEMIC-1 software package architecture.................................................................17
Figure 18: Battery connection and power switch......................................................................................21
Figure 19: STEVAL-BLUEMIC-1 evaluation board in plastic case...........................................................22
Figure 20: STM32 Nucleo board and STEVAL-BLUEMIC-1 SWD connections with a 5-pin flat cable ...23
Figure 21: Voice streaming from the STEVAL-BLUEMIC-1 evaluation board to an Android™ or iOS™
mobile device............................................................................................................................................24
Figure 22: BlueMS (Android version) app device list................................................................................24
Figure 23: BlueMS (Android version) BlueVoice demo............................................................................25
Figure 24: BlueMS (Android version) ASR language selection................................................................26
Figure 25: BlueMS (Android version) Chinese ASR, iFlytek technology..................................................27
Figure 26: BlueMS (Android version) popup API key window..................................................................27
Figure 27: BlueMS (Android version) ASR service enabled.....................................................................28
Figure 28: BlueMS (Android version) voice recording..............................................................................29
Figure 29: BlueMS (Android version) recognised voice text.....................................................................30
Figure 30: Google Chromium-dev: search group .....................................................................................31
Figure 31: Google Chromium-dev: join group to post...............................................................................31
Figure 32: Google Chromium-dev: join the group ....................................................................................31
Figure 33: Google Chromium-dev: create project ....................................................................................32
Figure 34: Google Developers Console: new project...............................................................................32
Figure 35: Google Developers Console: ASRProject...............................................................................32
Figure 36: Google Developers Console: select API .................................................................................32
Figure 37: Google API Manager: enable API ...........................................................................................33
Figure 38: Google API Manager: create API key .....................................................................................33
Figure 39: Google API Manager: Android API key...................................................................................33
Figure 40: BlueMS (Android version) plot data page................................................................................34
Figure 41: Voice streaming from a STEVAL-BLUEMIC-1 evaluation board to an STM32 Nucleo board 35
Figure 42: Receiver recognized as USB microphone...............................................................................36
Figure 43: Audacity recording voice streamed by the peripheral .............................................................36

UM2257
Getting started
DocID030830 Rev 1
5/38
1 Getting started
1.1 Hardware description
1.1.1 Features
Bluetooth®SMART small form factor board based on the SPBTLE-1S module,
Bluetooth v4.2 compliant
On-board SPBTLE-1S module, based on BlueNRG-1, Bluetooth low energy
application processor system on chip embedding an high performance:
ultra-low power ARM®Cortex®-M0 32-bit core architecture
Programmable embedded 160 KB Flash
24 KB embedded RAM with data retention
On-board MP34DT04-C1 digital MEMS microphone
On-board LSM6DSL: MEMS 3D accelerometer (±2 / ±4 / ±8 / ±16 g) + 3D gyroscope
(±125 / ±245 / ±500 / ±1000 / ±2000 dps)
Voltage supply: 1V8 or 3V3
Battery or USB powered
On-board STBC08 linear Li-Ion battery charger
SWD connector
Included in the development kit package:
STEVAL-BLUEMIC-1
Plastic box for housing STEVAL-BLUEMIC-1
100 mAh Li-Ion battery
SWD programming cable
SW development kit for audio and inertial MEMS data streaming over BLE
ST BlueMS: Android and iOS demo App available in the respective stores
1.1.2 Evaluation kit
The STEVAL-BLUEMIC-1 evaluation kit helps you to start prototyping a very low power
solution to stream audio and inertial data over BLE, exploiting the single-mode system-on-
chip BlueNRG-1.
Figure 2: STEVAL-BLUEMIC-1 evaluation kit

Getting started
UM2257
6/38
DocID030830 Rev 1
The evaluation kit contains:
an STEVAL-BLUEMIC-1 evaluation board
Figure 3: STEVAL-BLUEMIC-1 evaluation board: top and bottom
a 100 mAh LiPO battery to be connected to the evaluation board as power supply
Figure 4: Battery
a plastic case to house the evaluation board connected to the battery
Figure 5: Plastic case
an ST-LINK SWD programming cable to program the evaluation board connected to
ST-LINK
Figure 6: SWD cable

UM2257
Getting started
DocID030830 Rev 1
7/38
1.1.3 Evaluation board
The STEVAL-BLUEMIC-1 evaluation board is a highly integrated reference design that
enables a fast prototyping of very low power solutions for audio and inertial streaming.
Figure 7: STEVAL-BLUEMIC-1 evaluation board hardware architecture
Figure 8: STEVAL-BLUEMIC-1 evaluation board main components

Getting started
UM2257
8/38
DocID030830 Rev 1
Table 1: STEVAL-BLUEMIC-1 evaluation board main component details
Reference
Device
Description
A
SPBTLE-1S
Bluetooth Low Energy application processor compliant with BT
specification v4.2, based on BlueNRG-1 system-on-chip
B
LSM6DSL
iNEMO inertial module: low-power 3D accelerometer and 3D
gyroscope
C
MP34DT04-C1
MEMS audio sensor digital microphone
D
Button
User button
E
LED
A blue LED and a green LED for visual feedback
F
USB
Micro USB connector for power supply and battery charging
G
Battery
connector
Connector to plug the LiPO battery contained in the kit
H
Switch
ON-OFF switch to power the board
I
SWD
connector
5-pin SWD connector for programming and debugging

UM2257
Getting started
DocID030830 Rev 1
9/38
1.1.4 Schematic diagrams
Figure 9: Power and SPBTLE-1S module
Battery Charger
BlueNRG-1 Module Footprint
USB, SWD, Battery monitor
Max 200mA
Vout=3V3
R1=147K R2=47K
Vout=1V8
R1=150K R2=120K
Battery monitor
(4.2V -> 1.8V)
VPROG = 1V
IBAT=(VPROG/RPROG)x1000
RPROG=1000*VPROG/IBAT
V_USB
VBlue
VBat
VBlue
VBlue
VBlue
V_USB
V_USB
VBat
VBat
VBatVBat
V_USB VBat
I2C_SDA
I2C_SCL
INT1_AG
INT2_AG
PDM_CLK
PDM_DATA
LED1
LED2
BUTTON1
R8
0R
SW1
PWR
R16
0R
R1
147K
R13
20K
C9
4.7µF
U2 LDK120M-R
EN
3
GND
2
IN
1
ADJ4
OUT 5
U1 STBC08PMR
PROG 5
CHRG
3
PAD
7
BAT1
Vcc
6
GND
4
PWR_ON
2
R15
NC
BATT1
Battery Connector
1
2
3
CHRG
21
C1
4.7µF
SWD
1
2
3
4
5
R14
2K
R12
105K
VBAT
VBAT
1
U3 SPBTLE-1S
DIO14/ANATEST0
6
VBLUE
5DIO5/I2C_SDA
4DIO4/I2C_CLK
3ADC IN1
2ADC IN2
1
DIO6/UART_RTS
9DIO7/BOOT/UART_CTS
7
DIO8/UART_TXD
10
DIO11/UART_RXD
11
DIO9/TCK/SWTCK
12
DIO10/TMS/SWTDI
13
ANATEST1
14
DIO0/SPI_CLK 15
DIO2/SPI_MOSI 16
DIO1/SPI_CS18
BT_RESET19
DIOA12 20
DIO3/SPI_MISO 17
GND
8
R5
4K7
C8
100nF
C7
4.7µF
USB
USB-MICRO
1
2
3
4
SH1
SH2
5
R11
140K
R2
47K
C2
4.7µF
GND
GND
1
SWDIO
RESET
SWDCLK
SWDCLK
RESET
SWDIO
ADC_IN2
ADC_IN2
CHRG
CHRG

Getting started
UM2257
10/38
DocID030830 Rev 1
Figure 10: MEMS, button and LEDs
VBlue
VBlue
VBlue
VBlue
VBlue
VBlue
VBlue
PDM_CLK
I2C_SC L
I2C_SD A
INT1_AGINT2_AG
PDM_DATA
I2C_SC L
I2C_SD A
BUTTON1
LED1
LED2
R7
100K
C4
100nF
R9 1K LED2
LED Blue
21
R3
4K7
R10
100
Button1
12
3
4
5
6
R6
4K7
C5
100nF
C6
10nF
M1 MP34D T04
DOUT 4
LR
2
GND
5A
VDD
1
CLK
3
GND
5B
GND
5D GND
5C
U4
LSM6DS L
GND1
6VDDIO
5
INT1
4SCx
3SDx
2SDO/SA0
1
VDD8
INT2 9
OCS_A ux 10
SDO_Aux 11
CS 12
SCL13
GND2
7SDA14
R4 1K LED1
LED Green
21
C3
100nF

UM2257
Getting started
DocID030830 Rev 1
11/38
1.2 Software description
1.2.1 Overview
The STSW-BLUEMIC-1 is an evaluation software package that allows development of
smart and innovative solution using the SPBTLE-1S module.
The software package includes the entire Bluetooth®low energy stack and protocols,
complaint with the STSW-BLUENRG1-DK. It also contains a Board Support Package that
offers a complete set of APIs for digital MEMS microphone, 3-axis accelerometer and
gyroscope, button and LED management.
The latter is based on BlueNRG-1, a very low power Bluetooth low energy single mode
system-on-chip embedding a high performance, ultra-low power 32-bit ARM®Cortex®-M0,
with 160 kB of Flash memory and 24 kB of RAM.
The BlueVoiceADPCM_BNRG1 binary library (available as middleware) provides a vendor
specific profile for voice streaming over Bluetooth®low energy; it includes all APIs needed
for audio compression using the ITU-T G.726 ADPCM standard, packetization and
streaming.
The STSW-BLUEMIC-1 allows an STEVAL-BLUEMIC-1 evaluation board to act as a
peripheral in a point-to-point connection with a mobile device running the ST BlueMS app,
available for Android™ and iOS™. In this configuration, the evaluation board streams the
audio acquired from the on-board digital MEMS microphone (MP34DT04-C1) or motion
data acquired from the 3-axis accelerometer and gyroscope (LSM6DSL).
1.2.2 Architecture
The STSW-BLUEMIC-1 software is organized in different layers.
Figure 11: STSW-BLUEMIC-1 software architecture

Getting started
UM2257
12/38
DocID030830 Rev 1
The application layer manages the complete software chain from the audio and inertial data
acquisition to the streaming.
A complete set of drivers is available to interact with the on-board sensors and to manage
the BlueNRG-1 peripheral.
A middleware layer, between the application and the hardware abstraction layer, includes:
the Bluetooth®Low Energy stack library that allows communication between the
central and the peripheral device;
the BlueVoiceADPCM_BNRG1 library that provides all the APIs needed to implement
a voice-over-Bluetooth®Low Energy profile.
1.2.3 Folder structure
Figure 12: STSW-BLUEMIC-1 folder structure
The following folders are included in the software package:
Binary: contains ready-to-use firmware binary to be flashed on the STEVAL-
BLUEMIC-1 evaluation board
Documentation: contains a compiled HTML file generated from the source code
detailing the software components and APIs
Drivers: contains the board specific drivers including the on-board components
Library: contains the Bluetooth low energy stack binary library, the CMSIS vendor-
independent hardware abstraction layer for the ARM®Cortex®-M processor series, and
BlueNRG-1 peripheral drivers
Middlewares: contains the BlueVoice over BlueNRG-1 library
Projects: contains demo applications for voice transmission over Bluetooth Low
Energy. The projects support IAR Embedded Workbench for ARM, RealView
Microcontroller Development Kit (MDK-ARM) and Atollic-True Studio for ARM
development environments
1.2.4 APIs
Fully detailed user-API function and parameter descriptions are compiled in an HTML file
located in the software Documentation folder.
1.2.5 BlueMic1 application
The BlueMic1 application has been designed and built on the Bluetooth low energy
architecture.

UM2257
Getting started
DocID030830 Rev 1
13/38
1.2.5.1 BlueMic1 profile description
The BlueMic1 application deploys a connection-based communication paradigm by
providing a permanent point-to-point link between two devices, one acting as peripheral
and one as central (Generic Access Profile or GAP).
The STEVAL-BLUEMIC-1 evaluation board acts as a peripheral device supporting a single
connection and low complexity. This device only requires a controller that supports the
slave role.
The central module can be an Android™ and iOS™ device running the ST BlueMS app
(v3.0.0 or higher) or a FP-AUD-BVLINK1 receiver node.
The central and peripheral role assignment reflects the asymmetric design concept of
Bluetooth Low Energy, where the device with a lower energy source works less: a slave
cannot initiate complex procedures, whereas a master manages communication timing,
adaptive frequency hopping, encryption setup, etc. A portable device provided with a coin-
size battery is usually suitable as slave device.
Data sent through a Bluetooth Low Energy connection is organized through an additional
protocol layer, the Generic Attribute Profile (GATT). It provides standard profiles to ensure
interoperability between devices from different vendors that implement features like
Proximity Profile, Glucose Profile and Health Thermometer Profile. The Bluetooth
specification also lets you add custom profiles.
GATT defines client and server roles for interacting devices independent of the GAP
master/central and slave/peripheral roles:
Client performs service discovery about the presence and nature of server attributes;
it sends requests to a server and accepts responses and server-initiated updates.
Server accepts requests, commands and confirmations from a client and sends
responses and server-initiated updates; it arranges and stores data according to the
attribute (ATT) protocol.
In a mono-directional audio streaming asymmetric system, the device with voice data is the
one with a microphone and is therefore considered the server. The client device sends
requests to the server and accepts server-initiated updates containing audio data.
Audio data transmission is based on periodic server-to-client notifications which do not
require a request or response from the receiving device. Server-initiated updates are sent
as asynchronous notification packets which include the handle of a characteristic along
with its current value.
According to the Bluetooth specification, the peripheral enters advertising mode at start-up
and sends advertisement packets at relatively long intervals. The central unit enters
discovery mode and sends a connection request on reception of an advertisement packet
from a slave device. After connection, notifications carrying audio data are periodically sent
from the server to the client.
1.2.5.2 BlueMic1 service
The Attribute Protocol (ATT) is used by GATT as a transport protocol for exchanging data
between devices. The smallest entities defined by ATT (named attributes) are addressable
pieces of information that may contain user data or meta-information on the attribute
architecture, stored in the server and exchanged between client and server.
GATT server attributes are organized as a sequence of services, each one starting with a
service declaration attribute marking its beginning. Each service groups one or more
characteristics and each characteristic can include zero or more descriptors.
Since audio streaming is not part of the predefined set of profiles, the STSW-BLUEMIC-1
application defines a vendor-specific service named BlueMic1 Service based on an Audio

Getting started
UM2257
14/38
DocID030830 Rev 1
characteristic to expose actual compressed audio data and a Sync characteristic to expose
collateral information to implement a synchronization mechanism and an inertial
characteristic to expose 3-axis accelerometer and gyroscope raw data.
Table 2: BlueMic1 UUID summary table
UUID name
UUID
bluemic1_service_uuid
00000000-0001-11e1-9ab4-0002a5d5c51b
audio_adpcm_char_uuid
08000000-0001-11e1-ac36-0002a5d5c51b
audio_adpcm_sync_char_uuid
40000000-0001-11e1-ac36-0002a5d5c51b
acc_gyr_char_uuid
00E00000-0001-11e1-ac36-0002a5d5c51b
Given the service hierarchical architecture, further characteristics may be added to the
BlueMic1 service, such as configuration of parameters like volume, enabling/disabling of
processing algorithms, etc.
1.2.6 Audio processing
The audio processing component of the STSW-BLUEMIC-1 application is designed to
achieve an audio sampling frequency of 8 or 16 kHz at the receiver side, with a trade-off
between audio quality and bandwidth occupation for voice signals. The audio signal
transmitted is compressed via ADPCM (adaptive differential pulse code modulation) to fit in
the available data rate while minimizing radio transmission time and power consumption.
The figure below shows the speech processing chain in a complete communication system
with Tx and Rx.
On the Tx side, the library receives an audio signal which is typically acquired by a digital
MEMS microphone as a 1-bit PDM signal and converted by a PDM to PCM conversion
filter, integrated in the ADC peripheral of the BlueNRG-1 SoC, into 16-bit PCM samples at
8 or 16 kHz.
The library can be provided with 1, 2, 5 or 10 ms of audio data. When the compressed
output buffer is ready, a flag is set and audio data is streamed via Bluetooth Low Energy
together with collateral ADPCM information. The resulting communication bandwidth is 32
kbps (with 8 kHz audio sampling frequency) or 64 kbps (with 16 kHz audio sampling
frequency) of audio data plus 300 bps of collateral information.
Figure 13: STSW-BLUEMIC-1 audio processing chain

UM2257
Getting started
DocID030830 Rev 1
15/38
1.2.7 ADPCM compression
The ITU-T G.726 adaptive differential pulse code modulation (ADPCM) standard is applied
to save bandwidth. This audio algorithm for lossy waveform coding predicts the current
signal value from previous values, and transmits the difference between the real and the
predicted value, quantized with an adaptive quantization step.
The ADPCM algorithm used in this application compresses digital voice signals encoded
as:
Audio format: PCM
Audio sample size: 16 bits
Channels: 1 (mono)
Audio sample rate: 8-16 kHz
Figure 14: ADPCM encode-decode schema
BlueVoiceADPCM implements a modified version of the compression algorithm with
improved communication robustness through an additional low data rate channel with
collateral information added to the ADPCM quantized values; slightly increasing the overall
bit-rate to an average 64.3 Kbps.
The internal buffering required by ADPCM compression is shown in the figure below. 16-bit
input PCM samples are encoded in 8-bit temporary samples with 4-bit actual data (u8
ADPCM_app buffer) and then encapsulated in 8-bit samples containing information of two
PCM samples (u8 ADPCM buffer).

Getting started
UM2257
16/38
DocID030830 Rev 1
Figure 15: ADPCM packet mechanism
ADCPM decoding on the Rx side is performed in a symmetric fashion.
1.2.8 Packetization
The Tx data rate for streaming data is obtained from:
the connection interval
the number of packets per connection interval and user data payload for each packet
The STSW-BLUEMIC-1 application implements:
a constant bitrate allocated to audio data through the chosen ADPCM compression
a small connection interval to minimize the overall audio latency
The following connection intervals are set for Android™ and iOS™ compliance:
conn_min_int=10 ms
conn_max_int=21.25 ms
If the streaming is performed between two ST modules, the selected connection interval is
the minimum value (10 ms). The target 64 kbps constant data rate is achieved by sending
80 bytes of ADPCM data (640 bits) at each connection event. Consistent with maxPayload
= 20 bytes per packet (160 bit), four packets (two if an audio sampling frequency of 8 kHz
is set) of 20 bytes are sent per average connection event. In addition, ADPCM collateral
information is sent at a lower frequency via an additional smaller packet sent at regular
intervals.
The following figure shows a 16 kHz compressed audio streaming example, where four
data packets of 20 bytes are sent at each connection interval of 10 ms, while ADPCM
collateral information is sent as an additional packet once every 160 ms.

UM2257
Getting started
DocID030830 Rev 1
17/38
Figure 16: BLE packets for 16 Hz audio
1.2.9 STSW-BLUEMIC-1 application description
The STSW-BLUEMIC-1 software package is a complete example of audio and inertial data
streaming over Bluetooth®Low Energy to an Android™ and iOS™ mobile device running
the ST BlueMS app or to an STM32 platform.
Figure 17: STSW-BLUEMIC-1 software package architecture
The main loop continuously calls the BTLE_StackTick function needed for the RF
management and the APP_Tick that contains all the functions implemented by the user.
As soon as the application starts, the APP_STATUS_ADVERTISEMENT state is set,
BlueNRG-1 acts as a peripheral and sends advertisement messages until a central node
requests a connection.
When the connection is estabilished, the app status is set to APP_STATUS_CONNECTED
and two different demos can be activated from the ST BlueMS app running on the central
node.
If BlueVoice is enabled (firmware status set to APP_BLUEVOICE_ENABLED) audio
acquisition from the on-board digital microphone starts and drives the voice streaming.
PCM samples are compressed and sent.
The audio streaming can be stopped or restarted by pressing the STEVAL-BLUEMIC-1
evaluation board button.
The user can switch to the inertial demo (firmware status set to APP_INERTIAL_ENABLE)
via the BlueMS app.

Getting started
UM2257
18/38
DocID030830 Rev 1
A timer is set and every 30 ms raw data are acquired from the 3-axis accelerometer and
gyroscope and sent to the mobile device together with a timestamp increased by one every
10 ms.
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.

UM2257
Getting started
DocID030830 Rev 1
19/38
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);
to send collateral information for synchronization mechanism implementation
aci_gatt_add_char(ServiceHandle,
UUID_TYPE_128, CharAudioSyncUUID, 6,
CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE,
GATT_DONT_NOTIFY_EVENTS, 16, 1,
CharAudioSyncHandle);
You can choose to not create the BlueVoice Service and the module is not able to transmit
audio.
This node can still function as a RECEIVER; however, if the connected module exports the
BlueVoice profile; you must set the handle of the BlueVoice service and characteristics
exported by the transmitter module through the BluevoiceADPCM_BNRG1_SetRxHandle
API and enable notifications on the other node by calling the
BluevoiceADPCM_BNRG1_EnableNotification function.
If both the TRANSMITTER and RECEIVER procedures are performed, the module acts as
transmitter and receiver and the working mode is set to HALF-DUPLEX, creating a half-
duplex link over Bluetooth Low Energy.
1.3.3 Audio signal injection
The BlueVoiceADPCM_BNRG1 library receives audio PCM input samples.
The BluevoiceADPCM_BNRG1_AudioIn function accepts parameters from a PCM buffer,
containing all the acquired audio channels (channel_tot according to the previous library
configuration) and the number of PCM samples (for each channel) given as input. An
amount of data equal to 1, 2, 5 or 10 ms is accepted, otherwise an
BV_ADPCM_BNRG1_PCM_SAMPLES_ERR is returned.
The library compresses received PCM input samples; when 10 ms of audio is compressed,
the BluevoiceADPCM_BNRG1_AudioIn API returns
BV_ADPCM_BNRG1_OUT_BUF_READY.
1.3.4 Compressed audio streaming
On the transmitter side, the BlueVoiceADPCM_BNRG1 library gathers compressed data in
an internal double buffer. For every 10 ms of audio, the
BluevoiceADPCM_BNRG1_AudioIn function returns
BV_ADPCM_BNRG1_OUT_BUF_READY to signal output data can be send via Bluetooth Low
Energy by calling the BluevoiceADPCM_BNRG1_SendData API.

Getting started
UM2257
20/38
DocID030830 Rev 1
If the audio sampling frequency is set to 8 kHz, two 20-byte packets are sent every 10 ms
(according to the connection interval); if the frequency is 16 kHz, four 20-byte packets are
sent.
On the receiver side, compressed audio is received from a notification through a
EVT_BLUE_GATT_NOTIFICATION event and passed to the
BluevoiceADPCM_BNRG1_ParseData function that decompresses the data and returns
a PCM buffer. This API is used to parse both audio and collateral information data.
Other manuals for STEVAL-BLUEMIC-1
1
Table of contents
Other ST Motherboard manuals

ST
ST EVALSP1340CPU User manual

ST
ST NUCLEO-8S207K8 User manual

ST
ST STM3220F-EVAL User manual

ST
ST STEVAL-OET001V1-LCP154DJF User manual

ST
ST STM32L5 Nucleo-144 board User manual

ST
ST STEVAL-BLUEPLUG1 User manual

ST
ST EVAL-L9960 User manual

ST
ST UM0527 User manual

ST
ST STEVAL-AKI001V1 User manual

ST
ST STM8L1528-EVAL User manual

ST
ST STM32L476ZG User manual

ST
ST STEVAL-QUADV01 User manual

ST
ST STEVAL-AKI002V1 User manual

ST
ST STM32G474E-EVAL User manual

ST
ST STLINK-V3SET User manual

ST
ST STUSB02E User manual

ST
ST B-L4S5I-IOT01A User manual

ST
ST STM32H7 Nucleo-144 User manual

ST
ST STM32L152-EVAL User manual

ST
ST ST7 Series User manual