1. Serial Port application
The Serial Port Application is a Generic Attribute Profile (GATT) based low-energy application defined by STMicroelectronics with proprietary UUIDs(128 bits).The Serial Port application can be used to demonstrate Point-to-Point communication using Bluetooth Low Energy GATT component. It is used to exchange data entered on the UART of each board.
The Serial Port Application defines the communication between a GATT-server of a STM32WB0 Serial Port Server device, and a GATT-client Collector device, such as a smartphone or STM32WB0 Serial Port Client device.
Serial Port applications are named BLE_SerialPort_Server and BLE_SerialPort_Client. One board is configured as a GAP central using BLE_SerialPort_Client application. The other board is configured as GAP peripheral using BLE_SerialPort_Server application.
Both applications require to open an HyperTerminal as follow:
- Open VT100 terminals on client and server sides.
- Connect to ST-LINK via the COM port @115200 bauds/s, 8 data bits, with no parity and 1 stop bit:
Bluetooth® Serial port configuration |
---|
- Configure the terminal with local echo settings:
Bluetooth® Terminal setup |
---|
This wiki page is the description of the SerialPort Server and SerialPort Client projects provided within the STM32CubeWB0 MCU Package[1]
Bluetooth® LE SerialPort Profile & STM32WB0 |
---|
1.1. STM32WB0 Serial Port Server application
Serial Port Server exports a Service with the following two characteristics:
- TX characteristic:
- RX Characteristic:
The table below describes the structure of Serial Port service:
Bluetooth® LE Serial Port Service specification | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
1.2. Advertising data
At startup, Serial Port Server application starts advertising.
Data advertised are composed as follows:
Serial Port Server Advertising packet | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Manufacturer data are encoded following STMicroelectronics BlueST SDK v2 as described below:
STMicroelectronics Manufacturer Advertising data | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
The Serial Port Server application acts as a Peripheral device with the support of GATT Server Layer.
Once connected with a Serial Port Client application, the Serial Port Server application:
- Allows to enter data using keyboard when LF or CR is encountered or data buffer is full (20 bytes), and data are sent to the peer client device.
1.3. STM32WB0 Serial Port Client application
It acts as a Central device with the support of GATT Client Layer.
At startup, by pressing the B1 button, Serial Port Client application:
- Starts scanning to detect Serial Port Server application by filtering the Firmware ID of the STMicroelectronics Manufacturer advertising data
- Stops Scanning once P2P server detected
- Connects to the Serial Port Server to establish the connection.
- Discovers GATT Service & Characteristics of the Serial Port server
- Enable all GATT server notification characteristics
Once connected, the Serial Port Client application:
- Allows to enter data using keyboard when LF or CR is encountered or data buffer is full (20 bytes), data are sent to the peer server device.
Example of communication between STM32WB0 Serial Port Server & Serial Port Client |
---|
2. Requirements
2.1. Software and Hardware requirements
For software and hardware requirements refer to the STM32WB0 Build BLE Project wiki page.
2.2. Collector applications compatible
The STM32CubeWB0 Serial Port Server project is compatible with the following collector:
3. STM32WB0 Serial Port Server & Serial Port Client examples description
3.1. Project directory
The "BLE_p2pServer" & "BLE_p2pClient"applications are available by downloading STM32CubeWB0 MCU Package[1].
Refer to How to Build a Bluetooth® LE project wiki page for project directory information.
3.2. Project description
3.2.1. Structure
Software project structure with the most important parts:
Serial Port Server / Client project structure |
---|
WARNING: Do not modify the files in Middlewares folder |
4. Serial Port Server vs smartphone application
4.1. ST BLE ToolBox application
Once the BLE Serial Port Server application is installed on the STM32WB0 platform, launch the ST BLE ToolBox smartphone application. The application starts scanning and allows to see advertisement data or to connect to the device. Once the device is connected user is able to sends message from hyper terminal (TX characteristic notification) and receives messages from the ST Toobox (RX characteristic write without response)
BLE Serial Port Server application vs ST BLE ToolBox |
---|
5. References