1. Serial Com Profile
SerialCom applications (BLE_SerialCom_Central and BLE_SerialCom_Peripheral) are proprietary applications used to exchange data entered on UART of each board.
One board is configured as central thanks to BLE_SerialCom_Central and the other as peripheral thanks to BLE_SerialCom_Peripheral.
Both boards support data transfer by sending L2CAP data through a COC link.
Open VT100 Terminals on Client and Server sides, connected to ST Link COM port @115200.
Configure the terminal with settings local echo.
- When Append LF is configured, enter data using keyboard, check that data are correctly received on peer device.
- When Append nothing is configured, enter data using keyboard, data are sent when buffer of 20 bytes is full.
No service is added.
After BLE link is established, a Connection Oriented Channel (COC) is established.
Data are exchanged through the COC link.
This wiki page is the description of the SerialCom projects provided within the STM32CubeWBA MCU Package[1]
Bluetooth® LE Serial Com projects & STM32WBA |
---|
Example of COC link establishment between a SerialCom central (STM32WBA) & a SerialCom peripheral (STM32WBA) |
---|
Example of COC exchanged data between a SerialCom peripheral (STM32WBA) & a SerialCom central (STM32WBA) |
---|
1.1. On board buttons configuration
SerialCom Peripheral Application Nucleo-WBA buttons configuration | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SerialCom Central 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, plus a patch available in Utilities/PC_Software/EWARMv8_STM32WBAx_V1.2.zip
- RealView Microcontroller Development Kit (MDK-ARM) toolchain V5.37, plus a patch available in Utilities/PC_Software/Keil.STM32WBAx_DFP.1.0.0.zip
- STM32CubeIDE toolchain V1.12.0 [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 SerialCom peripheral application is compatible with the following collector:
- STM32CubeWBA and SerialCom central application
3. STM32WBA SerialCom peripheral description
3.1. Project directory
The "BLE_SerialCom_Peripheral" application is available by downloading STM32CubeWBA MCU Package[5].
Refer to How to Build a BLE Project wiki page for project directory information.
3.2. Project description
3.2.1. Structure
Software project structure with the most important parts:
SerialCom Peripheral 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:
SerialCom Peripheral project initialization |
---|
3.2.3. GAP and GATT initialization and interaction
and The Bluetooth LE SerialCom peripheral 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 SerialCom peripheral is done with coc_peripheral_app.c:
- Initialization of the context of the application
- Manage COC link establishment
Initializes Rx UART to process data from terminal
SerialCom peripheral software module interaction |
---|
3.3. How to use
Once the BLE SerialCom Peripheral application is installed on the STM32WBA platform, use BLE SerialCom Central application on STM32WBA.
Open a VT100 terminal on Central and Peripheral sides (ST Link Com Port, @115200 bauds).
Configure the terminal with settings local echo and configure "Append LF".
Press B1 on central to scan, connect and establish COC link .
When link is ready, "CONNECTION READY" is displayed.
Enter data on UART on peripheral or central side, check that data are correctly received on peer device.
If "Append nothing" is configured on terminal, data are sent when buffer of 20 bytes is full.
- Pressing B2 while not connected allows to clear the security database
- Pressing B2 while connected allows to send peripheral security request
3.4. 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)
SerialCom Peripheral - 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: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 - 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
==>> 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:9d
- Connection Interval: 50.00 ms
- Connection latency: 0
- Supervision Timeout: 5000 ms
BLE_SVC_L2CAP_Conn_Update(), Successfully
>>== HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE
- Connection Interval: 45.00 ms
- Connection latency: 0
- Supervision Timeout: 10000 ms
>>== ACI_L2CAP_COC_CONNECT_VSEVT_CODE
==>> aci_l2cap_coc_connect_confirm : Success
Success: change MTU
>>== MTU_size = 247
>>== CONNECTION READY
|
SerialCom Peripheral - Receive data | SerialCom Central - push B1 - Enter data through UART |
---|---|
asdfghjklzxcvbn
|
asdfghjklzxcvbn
|
4. STM32WBA SerialCom Central example description
4.1. Project directory
The "BLE_SerialCom_Central" application is available by downloading STM32CubeWBA MCU Package[6]
Refer to How to Build a BLE Project wiki page for project directory information.
4.2. Project description
4.2.1. Structure
Software project structure with the most important parts:
SerialCom Central 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:
SerialCom Central project initialization |
---|
4.2.3. GAP and GATT initialization and interaction
and The Bluetooth LE SerialCom central 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 SerialCom central is done with gatt_client_app.c:
- Initialize Gatt Client Application
- Manage COC link establishment
- Initialize Rx UART to process data from terminal
SerialCom central 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_SerialCom_Central project.
4.4. How to use
Once the BLE SerialCom Central application is installed on the STM32WBA platform, use BLE SerialCom Peripheral application on other STM32WBA.
Open a VT100 terminal on Central and Peripheral sides (ST Link Com Port, @115200 bauds).
Configure the terminal with settings local echo and Append LF.
Press B1 on central side to scan, connect and establish COC.
Once the link is ready: "CONNECTION READY" is displayed.
Enter data on one side (central or peripheral), check that data are correctly received on peer device.
If the terminal is configured with settings local echo and Append nothing, data are sent when buffer of 20 bytes is full.
- Pressing B2 while not connected allows to clear the security database
- Pressing B2 while connected allows to send pairing request
- Pressing B3 while connected allows to send connection update
4.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)
SerialCom Central - 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: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 - 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
-- CENTRAL INITIALIZED
|
** START GENERAL DISCOVERY (SCAN) **
--- ST MANUFACTURER data BlueSTv2
-- COC peripheral detected, db addr 0x00:80:E1:2A:7E:6E
>>== ACI_GAP_PROC_COMPLETE_VSEVT_CODE
-- GAP_GENERAL_DISCOVERY_PROC completed
==>> Success: Create connection to SC_WBAxx
>>== ACI_GAP_PROC_COMPLETE_VSEVT_CODE
>>== HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE - Connection handle: 0x0001
- Connection established with @:00:80:e1:2a:7e:6e
- Connection Interval: 50.00 ms
- Connection latency: 0
- Supervision Timeout: 5000 ms
GATT services discovery
Success: aci_l2cap_connection_parameter_update_resp command
Success: aci_hal_set_radio_activity_mask command
Fail : aci_l2cap_connection_parameter_update_resp 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
PROC_GATT_DISC_ALL_PRIMARY_SERVICES services discovered Successfully
DISCOVER_ALL_CHARS ConnHdl=0x0001 ALLServiceHandle[0x0001 - 0x000B]
ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE - ConnHdl=0x0001
ConnHdl=0x0001, number of value pair = 3
1/3 short UUID=0x2A05, Properties=0x0020, CharHandle [0x0002 - 0x0003], GATT SERVICE_CHANGED_CHARACTERISTIC_UUID charac found
2/3 short UUID=0x2A00, Properties=0x000A, CharHandle [0x0006 - 0x0007], GAP DEVICE_NAME charac found
3/3 short UUID=0x2A01, Properties=0x0002, CharHandle [0x0008 - 0x0009], GAP APPEARANCE charac found
ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE - ConnHdl=0x0001
ConnHdl=0x0001, number of value pair = 1
1/1 short UUID=0x2A04, Properties=0x0002, CharHandle [0x000A - 0x000B]
All characteristics discovered Successfully
DISCOVER_ALL_CHAR_DESCS [0x0001 - 0x000B]
>>== HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE
- Connection Interval: 45.00 ms
- Connection latency: 0
- Supervision Timeout: 10000 ms
==>> Start Connection Oriented Channel
Success: aci_l2cap_coc_connect command
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
>>== ACI_L2CAP_COC_CONNECT_CONFIRM_VSEVT_CODE
==>> Connection Oriented Channel established
MTU exchanged size = 247
Success: set data length command
>>== MTU_size = 247
>>== CONNECTION READY
ACI_ATT_FIND_INFO_RESP_VSEVT_CODE - ConnHdl=0x0001
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
All characteristic descriptors discovered Successfully
ServiceChangedCharDescHdl =0x0004
All notifications enabled Successfully
|
SerialCom Peripheral - enter data through UART | SerialCom Central - Receives data |
---|---|
qwertyuiopasdfghjkl
|
qwertyuiopasdfghjkl
|