1. Data Throughput
Data Throughput applications (BLE_DataThroughput_Client and BLE_DataThroughput_Server) are proprietary applications used to measure the throughput between devices according to different parameters, 1M or 2M PHY, different connection intervals.
The Data Throughput Server is the device exposing three characteristics to be controlled by the remote client
- Characteristics DATA_TRANSFER_TX (Notification) to notify data from Server TO Client
- Characteristics DATA_TRANSFER_RX (Write) to Send data from Client TO Server
- Characteristics DATA_TRANSFER_TX_RX_INFO (Notification) to notify throughput measurement of data received
The Central & GATT Client Collector can be three different applications
- Data Throughput Client to measure performances between 2 STM32WBA devices
- Smartphone ST BLE Toolbox to performs Smartphone benchmarking
- Web Bluetooth Interface to use laptop
This wiki page is the description of the Data throughput project provided within the STM32CubeWBA MCU Package[1]
Bluetooth® LE Data Throughput project & STM32WBA |
---|
The table below describes the structure of Data Throughput service:
Bluetooth® LE Data Throughput Service specification | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Example 1 of flow diagram between a Data Throughput server (STM32WBA) & a Client Collector |
---|
Example 2 of flow diagram between a Data Throughput server (STM32WBA) & a Client Collector |
---|
1.1. STMicrolectronics Manufacturer Advertising Data
Data Throughput Sensor STMicroelectronics Manufacturer Advertising data | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
1.2. On board buttons configuration
DT Sensor Application Nucleo-WBA buttons configuration | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
DT Client Application Nucleo-WBA buttons configuration | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2. Requirements
2.1. Software and system requirements
The software required are the following (minimum IDEs version):
- IAR Embedded Workbench for ARM (EWARM) toolchain V9.20.1
- RealView Microcontroller Development Kit (MDK-ARM) toolchain V??
- STM32CubeIDE toolchain V?? [2].
Programmer:
- STM32CubeProgrammer[3] : To flash the board with an already generated binary
2.2. Hardware requirements
NUCLEO-WBA5 [4] is necessary to install the application.
Hardware platform illustration |
---|
|
2.3. Collector applications compatible
The STM32CubeWBA Data Throughput Sensor project is compatible with the following collector:
3. STM32WBA Data Throughput Server example description
3.1. Project directory
The "BLE_DataThroughput_Server" application is available by downloading STM32CubeWBA MCU Package[5].
Data Throughput Server project directory |
---|
3.2. Project description
3.2.1. Structure
Software project structure with the most important parts:
Data Throughput Server project structure |
---|
WARNING: Do not modify the files in Middlewares folder |
3.2.2. Application initialization
The different steps of the application initialization are described below:
Data Throughput Server project initialization |
---|
3.2.3. GAP and GATT initialization and interaction
and The Bluetooth LE Data Throughput Server application initialization is done within app_ble.c
- Start the BLE stack - initialize the device as peripheral - configure and start advertising: ADV parameters, local name, UUID - APP_BLE_init()
- Call the services controller initialization SVCCTL_Init() - svc_ctl.c
- Manage the GAP event - SVCCTL_App_Notification()
- EVT_LE_CONN_COMPLETE - provides information of the connection interval, slave latency, supervision timeout
- EVT_LE_CONN_UPDATE_COMPLETE - provides the new information of the connection
- EVT_DISCONN_COMPLETE - informs the application about the link disconnection and the reason
- EVT_ENCRYPT_CHANGE - informs the application weather the link is encrypted
The Services management is done by the service controller, svc_ctl.c
- Initialize the number of registered handler - SVCCTL_SvcInit()
- Manage events - SVCCTL_UserEvtRx()- from the BLE Host Stack and redirect them to the gap event handler - SVCCTL_App_Notification
The application level of the Data Throughput Sensor is done with dt_serv_app.c:
- Initialization of the services:
- Data Throughput Service - DT_SERV_Init() - dt_serv.c
- Initialization of the context of the application
- Register Data Throughput Event Handle to Service Controller - SVCCTL_RegisterSvcHandler(DT_SERV_EventHandler);
- Initialize Service UUID – add Data Throughput service as Primary services
The Data Throughput Service dt_serv.c manages the specification of the service:
- Service Init - DT_SERV_Init()
- Register Data Throughput Event Handle to Service Controller - SVCCTL_RegisterSvcHandler(DT_SERV_EventHandler);
- Initialize Service UUID – add Data Throughput service as Primary service
- Initialize Transmitted Data characteristic
- Initialize Received Data characteristic
- Initialize Received Data value characteristic transmitted to the client
- Update Data Throughput DT_SERV_THROUGH measurement characteristic - DT_SERV_UpdateValue()
- Update Data Throughput DT_SERV_TX characteristic Value - DT_SERV_UpdateValue()
- Manage the GATT event from BLE Stack - DT_SERV_EventHandler()
- ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE
- Reception of a Write Command: DT_SERV_RX Characteristic Value
- ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE
- ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE
- Reception of an attribute modification - DT_SERV_TX Value : ENABLE or DISABLE Notification
- Reception of an attribute modification - DT_SERV_THROUGH Value : ENABLE or DISABLE Notification
- Notify application of the Transmitted Data - DT_SERV_Notification(DT_SERV_TX_CHAR)
- Notify application of the Received Data - DT_SERV_Notification(DT_SERV_THROUGH_CHAR)
- ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE
Data Throughput Server software module interaction |
---|
3.3. Build and install
Follow the steps described in Bluetooth® LE Build and Install Application page, applying them for STM32WBA BLE_DataThroughput_Server project.
3.4. How to use
Once the BLE Data Throughput Server application is installed on the STM32WBA platform, launch
ST BLE ToolBox smartphone application.
Then, scan and connect the device called DT_XX (where XX is replaced by the last byte of the BD address) to the application.
Once the Bluetooth® LE connection is established and the notifications enabled by the smartphone:
- Pressing B1 while connected allows to start/stop sending of data through notification
- Pressing B2 while not connected allows to clear the security database
- Pressing B2 while connected allows to update the connection interval
With the WBA5x.Nucleo board, it is also possible to change RF PHY modulation
- Pressing B3 while connected allows to switch between 2 Mbits and 1 Mbits PHY
3.5. UART debug trace
Traces are enabled within the project, in app_conf.h as described below:
/**
* Enable or Disable traces in application
*/
#define CFG_DEBUG_APP_TRACE (1)
Debugger can also be supported by enabling it within app_conf.h as described below:
/**
* User interaction
* When CFG_LED_SUPPORTED is set, LEDS are activated if requested
* When CFG_BUTTON_SUPPORTED is set, the push button are activated if requested
* When CFG_DBG_SUPPORTED is set, the debugger is activated
*/
[...]
#define CFG_DBG_SUPPORTED (1)
Data Throughput Sensor - Initialization phase | Connected Phase |
---|---|
==>> Start Ble_Hci_Gap_Gatt_Init function
Success: hci_reset command
Success: aci_hal_write_config_data command - CONFIG_DATA_PUBADDR_OFFSET
Public Bluetooth Address: 00:80:e1:2a:7e:9d
Success: aci_hal_write_config_data command - CONFIG_DATA_IR_OFFSET
Success: aci_hal_write_config_data command - CONFIG_DATA_ER_OFFSET
Success: aci_hal_set_tx_power_level command
Success: aci_gatt_init command
Success: aci_gap_init command
Success: aci_gatt_update_char_value - Device Name
Success: aci_gatt_update_char_value - Appearance
Success: hci_le_set_default_phy command
Success: aci_gap_set_io_capability command
Success: aci_gap_set_authentication_requirement command
Success: aci_gap_configure_whitelist command
==>> End Ble_Hci_Gap_Gatt_Init function
Services and Characteristics creation
Success: aci_gatt_add_service command: DT_SERV
Success: aci_gatt_add_char command : TX_CHAR
Success: aci_gatt_add_char command : RX_CHAR
Success: aci_gatt_add_char command : THROUGH_CHAR
End of Services and Characteristics creation
==>> aci_gap_set_discoverable - Success
==>> Success: Start Fast Advertising
|
>>== HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE - Connection handle: 0x0001
- Connection established with @:00:80:e1:2a:7e:6e
- Connection Interval: 7.50 ms
- Connection latency: 0
- Supervision Timeout: 5000 ms
Success: change MTU
Success: set data length command
>>== Connection Handle = 1
>>== MTU_size = 255
==>> Tx_char_handle Notification enabled
==>> Through_char_handle attribute modified
==>> Through_char_handle attribute enabled
>>== HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE
- Connection Interval: 50.00 ms
- Connection latency: 0
- Supervision Timeout: 10000 ms
|
Data Throughput Client - Initialization phase | Push B1 then Connected Phase |
---|---|
==>> Start Ble_Hci_Gap_Gatt_Init function
Success: hci_reset command
Success: aci_hal_write_config_data command - CONFIG_DATA_PUBADDR_OFFSET
Public Bluetooth Address: 00:80:e1:2a:7e:6e
Success: aci_hal_write_config_data command - CONFIG_DATA_IR_OFFSET
Success: aci_hal_write_config_data command - CONFIG_DATA_ER_OFFSET
Success: aci_hal_set_tx_power_level command
Success: aci_gatt_init command
Success: aci_gap_init command
Success: aci_gatt_update_char_value - Appearance
Success: aci_gap_set_io_capability command
Success: aci_gap_set_authentication_requirement command
Success: aci_gap_configure_whitelist command
==>> End Ble_Hci_Gap_Gatt_Init function
-- DT CLIENT INITIALIZED
|
** START GENERAL DISCOVERY (SCAN) **
--- ST MANUFACTURER data BlueSTv2
-- DT server not detected
--- ST MANUFACTURER data BlueSTv2
-- DT server detected, db addr 0x00:80:E1:2A:7E:9D
>>== ACI_GAP_PROC_COMPLETE_VSEVT_CODE
-- GAP_GENERAL_DISCOVERY_PROC completed
Create connection to P2Pserver index 0
wait for event HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE
>>== ACI_GAP_PROC_COMPLETE_VSEVT_CODE
>>== HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE - Connection handle: 0x0001
- Connection established with @:00:80:e1:2a:7e:9d
- Connection Interval: 7.50 ms
- Connection latency: 0
- Supervision Timeout: 5000 ms
GATT services discovery
MTU exchanged size = 255
Success: set data length command
ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE - ConnHdl=0x0001
1/2 short UUID=0x1801, handle [0x0001 - 0x0004], GENERIC_ATTRIBUTE_SERVICE_UUID found
2/2 short UUID=0x1800, handle [0x0005 - 0x000B], GAP_SERVICE_UUID found
ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE - ConnHdl=0x0001
1/1 short UUID=0xFE80, handle [0x000C - 0x0014], GENERIC_ATTRIBUTE_SERVICE_UUID found
PROC_GATT_DISC_ALL_PRIMARY_SERVICES services discovered Successfully
DISCOVER_ALL_CHARS ConnHdl=0x0001 ALLServiceHandle[0x0001 - 0x0014]
ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE - ConnHdl=0x0001
ConnHdl=0x0001, number of value pair = 4
1/4 short UUID=0x2A05, Properties=0x0020, CharHandle [0x0002 - 0x0003], GATT SERVICE_CHANGED_CHARACTERISTIC_UUID charac found
2/4 short UUID=0x2A00, Properties=0x000A, CharHandle [0x0006 - 0x0007], GAP DEVICE_NAME charac found
3/4 short UUID=0x2A01, Properties=0x0002, CharHandle [0x0008 - 0x0009], GAP APPEARANCE charac found
4/4 short UUID=0x2A04, Properties=0x0002, CharHandle [0x000A - 0x000B]
ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE - ConnHdl=0x0001
ConnHdl=0x0001, number of value pair = 3
1/3 short UUID=0xFE81, Properties=0x0010, CharHandle [0x000D - 0x000E], GATT TX_CHARACTERISTIC_UUID charac found
2/3 short UUID=0xFE82, Properties=0x0006, CharHandle [0x0010 - 0x0011], GATT RX_CHARACTERISTIC_UUID charac found
3/3 short UUID=0xFE83, Properties=0x0010, CharHandle [0x0012 - 0x0013], GATT THROUGHPUT_CHARACTERISTIC_UUID charac found
All characteristics discovered Successfully
DISCOVER_ALL_CHAR_DESCS [0x0001 - 0x0014]
ACI_ATT_FIND_INFO_RESP_VSEVT_CODE - ConnHdl=0x0001
reset - UUID & handle - CHARACTERISTIC_UUID=0x2803 CharStartHandle=0x0002
UUID=0x2A05, handle=0x0003, found GATT SERVICE_CHANGED_CHARACTERISTIC_UUID
Descriptor UUID=0x2902, handle=0x0002-0x0003-0x0004, Service Changed found
PRIMARY_SERVICE_UUID=0x2800 handle=0x0005
reset - UUID & handle - CHARACTERISTIC_UUID=0x2803 CharStartHandle=0x0006
UUID=0x2A00, handle=0x0007, found GAP DEVICE_NAME_UUID
reset - UUID & handle - CHARACTERISTIC_UUID=0x2803 CharStartHandle=0x0008
UUID=0x2A01, handle=0x0009, found GAP APPEARANCE_UUID
reset - UUID & handle - CHARACTERISTIC_UUID=0x2803 CharStartHandle=0x000A
UUID=0x2A04, handle=0x000B
PRIMARY_SERVICE_UUID=0x2800 handle=0x000C
reset - UUID & handle - CHARACTERISTIC_UUID=0x2803 CharStartHandle=0x000D
ACI_ATT_FIND_INFO_RESP_VSEVT_CODE - ConnHdl=0x0001
UUID=0xFE81, handle=0x000E
ACI_ATT_FIND_INFO_RESP_VSEVT_CODE - ConnHdl=0x0001
Descriptor UUID=0x2902, handle=0x000D-0x000E-0x000F, DTTX Client descriptor found
reset - UUID & handle - CHARACTERISTIC_UUID=0x2803 CharStartHandle=0x0010
ACI_ATT_FIND_INFO_RESP_VSEVT_CODE - ConnHdl=0x0001
UUID=0xFE82, handle=0x0011
ACI_ATT_FIND_INFO_RESP_VSEVT_CODE - ConnHdl=0x0001
reset - UUID & handle - CHARACTERISTIC_UUID=0x2803 CharStartHandle=0x0012
ACI_ATT_FIND_INFO_RESP_VSEVT_CODE - ConnHdl=0x0001
UUID=0xFE83, handle=0x0013
ACI_ATT_FIND_INFO_RESP_VSEVT_CODE - ConnHdl=0x0001
Descriptor UUID=0x2902, handle=0x0012-0x0013-0x0014, DTThroughput Client descriptor found
All characteristic descriptors discovered Successfully
ServiceChangedCharDescHdl =0x0004
DTTXDescHdl =0x000F
DTThroughputDescHdl =0x0014
All notifications enabled Successfully
** CONNECTION UPDATE **
>>== HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE
- Connection Interval: 50.00 ms
- Connection latency: 0
- Supervision Timeout: 10000 ms
|
Data Throughput Sensor - Receive data | Data Throughput Client - push B1 Writes data |
---|---|
DataThroughput = 33840 bytes/s lost = 0
Success: aci_gatt_update_char_value THROUGH_CHAR command
DataThroughput = 34080 bytes/s lost = 0
Success: aci_gatt_update_char_value THROUGH_CHAR command
DataThroughput = 34080 bytes/s lost = 0
Success: aci_gatt_update_char_value THROUGH_CHAR command
DataThroughput = 34080 bytes/s lost = 0
Success: aci_gatt_update_char_value THROUGH_CHAR command
DataThroughput = 33840 bytes/s lost = 0
Success: aci_gatt_update_char_value THROUGH_CHAR command
DataThroughput = 34080 bytes/s lost = 0
Success: aci_gatt_update_char_value THROUGH_CHAR command
DataThroughput = 34080 bytes/s lost = 0
Success: aci_gatt_update_char_value THROUGH_CHAR command
DataThroughput = 34080 bytes/s lost = 0
Success: aci_gatt_update_char_value THROUGH_CHAR command
DataThroughput = 12240 bytes/s lost = 0
Success: aci_gatt_update_char_value THROUGH_CHAR command
|
ACI_GATT_NOTIFICATION_VSEVT_CODE - ConnHdl=0x0001, Attribute_Handle=0x0013
ACI_GATT_NOTIFICATION_VSEVT_CODE - ConnHdl=0x0001, Attribute_Handle=0x0013
ACI_GATT_NOTIFICATION_VSEVT_CODE - ConnHdl=0x0001, Attribute_Handle=0x0013
ACI_GATT_NOTIFICATION_VSEVT_CODE - ConnHdl=0x0001, Attribute_Handle=0x0013
ACI_GATT_NOTIFICATION_VSEVT_CODE - ConnHdl=0x0001, Attribute_Handle=0x0013
ACI_GATT_NOTIFICATION_VSEVT_CODE - ConnHdl=0x0001, Attribute_Handle=0x0013
ACI_GATT_NOTIFICATION_VSEVT_CODE - ConnHdl=0x0001, Attribute_Handle=0x0013
ACI_GATT_NOTIFICATION_VSEVT_CODE - ConnHdl=0x0001, Attribute_Handle=0x0013
ACI_GATT_NOTIFICATION_VSEVT_CODE - ConnHdl=0x0001, Attribute_Handle=0x0013
|
4. STM32WBA Data Throughput Client example description
4.1. Project directory
The "BLE_DataThroughput_Client" application is available by downloading STM32CubeWBA MCU Package[5].
Data Throughput Client project directory |
---|
4.2. Project description
4.2.1. Structure
Software project structure with the most important parts:
Data Throughput Client project structure |
---|
WARNING: Do not modify the files in Middlewares folder |
4.2.2. Application initialization
The different steps of the application initialization are described below:
Data Throughput Client project initialization |
---|
4.2.3. GAP and GATT initialization and interaction
and The Bluetooth LE Data Throughput Client application initialization is done within app_ble.c
- Start the BLE stack - initialize the device as central - configure and start scanning
- Call the services controller initialization SVCCTL_Init() - svc_ctl.c
- Manage the GAP event - SVCCTL_App_Notification()
- EVT_LE_CONN_COMPLETE - provides information of the connection interval, slave latency, supervision timeout
- EVT_LE_CONN_UPDATE_COMPLETE - provides the new information of the connection
- EVT_DISCONN_COMPLETE - informs the application about the link disconnection and the reason
- EVT_ENCRYPT_CHANGE - informs the application weather the link is encrypted
- connects to device with MANUFACTURER SPECIFIC DATA equals to CFG_DEV_ID_DT_SERVER
The Services management is done by the service controller, svc_ctl.c
- Initialize the number of registered handler - SVCCTL_SvcInit()
- Manage events - SVCCTL_UserEvtRx()- from the BLE Host Stack and redirect them to the gap event handler - SVCCTL_App_Notification
The application level of Data Throughput Client is done with gatt_client_app.c:
- Register Data Throughput Client Event Handle to Service Controller - SVCCTL_RegisterCltHandler(Event_Handler)
- Initialization of the context of the application
- Discovers service: GATT_CLIENT_APP_Procedure_Gatt(PROC_GATT_DISC_ALL_PRIMARY_SERVICES)
- Discovers characteristics: GATT_CLIENT_APP_Procedure_Gatt(PROC_GATT_DISC_ALL_CHARS)
- Discovers client descriptor characteristics: GATT_CLIENT_APP_Procedure_Gatt(PROC_GATT_DISC_ALL_DESCS)
- Enables notifications: GATT_CLIENT_APP_Procedure_Gatt(PROC_GATT_ENABLE_ALL_NOTIFICATIONS)
- Manage the GATT event from BLE Stack - Event_Handler()
- ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE
- Reception of an attribute modification - DT_SERV_TX Value : Notification of data sent by the server
- Reception of an attribute modification - DT_SERV_THROUGH Value : Throughput value calculated corresponding of DT_SERV_RX_VALUE sent back to the client
- ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE
Data Throughput Client software module interaction |
---|
4.3. Build and install
Follow the steps described in Bluetooth® LE Build and Install Application page, applying them for STM32WBA BLE_DataThroughput_Client project.
4.4. How to use
Install the BLE Data Throughput Client application on one STM32WBA platform.
Install the BLE Data Throughput Server application on other STM32WBA platform.
- Pressing B1 while not connected scans and connects to Data Throughput Server device, enables all notifications.
- Pressing B1 while connected allows to start/stop the sending of data through write w/o response
BLE Data Throughput Client application supports the pairing procedure
- Pressing B2 while not connected allows to clear the security database
- Pressing B2 while connected allows to request pairing
With the WBA5x.Nucleo board, it is also possible to change RF PHY modulation
- Pressing B3 while connected allows to switch between 2 Mbits and 1 Mbits PHY