1. STM32WB - Bluetooth® LE Coprocessor Binaries
This is a description about the Bluetooth® LE Wireless stack available for the secure CM0+ coprocessor of the STM32WB Most of the information can be found within the Release Note for STM32WBxx Copro Wireless Binaries. https://github.com/STMicroelectronics/STM32CubeWB/tree/master/Projects/STM32WB_Copro_Wireless_Binaries
1.1. CubeWB v1.14.0 - Bluetooth® LE Wireless stack Summary
For Bluetooth® LE applications, 6 binaries are available. According to the type of application, the size of the flash, it is up to the developer to load the right binary:
- stm32wb5x_BLE_Stack_full_extended_fw.bin
- Full BLE Stack 5.3 certified : Link Layer, HCI, L2CAP, ATT, SM, GAP and GATT database
- BT SIG Certification listing : Declaration ID ??
- To be used for Adverting/Scanning Extension - Full HCI/ACI/DTM commands/Event support
- stm32wb5x_BLE_Stack_full_fw.bin
- Full BLE Stack 5.3 certified : Link Layer, HCI(limited), L2CAP, ATT, SM, GAP and GATT database
- BT SIG Certification listing : Declaration ID ??
- To be used for GAP Central/Peripheral & GATT Server/Client applications
- stm32wb5x_BLE_Stack_light_fw.bin
- BLE Stack 5.3 certified : Link Layer, HCI(limited), L2CAP, ATT, SM, GAP(limited) and GATT(limited) database
- BT SIG Certification listing : Declaration ID ??
- To be used for GAP Peripheral & GATT Server applications
- stm32wb5x_BLE_HCILayer_fw.bin
- HCI Layer only mode 5.3 certified : Link Layer, HCI, DTM
- BT SIG Certification listing : Declaration ID ??
- To be used for BLE Host Stack running on CM4 application processor (Arduino, Zephyr,..)
- stm32wb5x_BLE_HCILayer_extended_fw.bin
- HCI Layer only mode 5.3 certified : Link Layer, HCI, DTM, Extended Advertising/Scanning
- BT SIG Certification listing : Declaration ID ??
- To be used for BLE Host Stack running on CM4 application processor (Arduino, Zephyr,..)
- stm32wb5x_BLE_HCI_AdvScan_fw.bin
- HCI Layer only mode 5.3 certified : Link Layer, HCI
- BT SIG Certification listing : Declaration ID ??
- To be used for advertising and scanning through HCI interface
test blalla
STM32 BLE Stack | GAP Peripheral | GAP Central | GATT Server | GATT Client | PHY 2M | Data Length Extension | Legacy Pairing, LE secure connection | Privacy | White List | HCI Interface | DTM | L2CAP Connection Oriented channels support | Channel Selection #2 | Extended Advertising Scanning | BT SIG Declaration ID |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Full Extended | style="text-align: center; "|● | ● | ● | ● | ● | ● | 177KB | ● | ● | ● | ● | ● | ● | ● | id123456 |
Full | style="text-align: center; "|● | ● | ● | ● | ● | ● | ● | ● | ● | reduced | id123456 | ||||
Light | style="text-align: center; "|●' | ● | ● | ?? | ● | ● | ● | reduced | id123456 | ||||||
STM32 BLE Stack | Example | Example | Example | Example | Example | Example | Example | Example | Example | Example | Example | Example | Example | Example | Example |
stm32wb5x_BLE_Stack_full_fw.bin [MODIFIED]
Full BLE Stack 5.2 certified : Link Layer, HCI, L2CAP, ATT, SM, GAP and GATT database
BT SIG Certification listing : Declaration ID D042164
Following features are kept (based on Basic stack library compared to previous deliveries):
GAP peripheral, central (LL Master up to 6 links with Slave up to 2 links/ Master up to 7 links with Slave up to 1 links/ Master up to 8 links )
GATT server, client
Data length extension
2Mbit PHY / PHY update
Privacy
White list
Legacy Pairing, LE secure connections
HCI interface (full, like stm32wb5x_BLE_HCILayer_fw.bin)
Following features are removed:
Direct test mode
L2Cap Connection - oriented channels support (IP over BLE enabler)
Channel selection #2 (under application flag selection)
Some HCI interface features (won’t be able to process through HCI interface)
stm32wb5x_BLE_Stack_full_extended_fw.bin Full BLE Stack 5.2 certified : Link Layer, HCI, L2CAP, ATT, SM, GAP and GATT database BT SIG Certification listing : Declaration ID D042164 Following features are kept: GAP peripheral, central (LL Master up to 6 links with Slave up to 2 links/ Master up to 7 links with Slave up to 1 links/ Master up to 8 links ) GATT server, client Data length extension 2Mbit PHY / PHY update Privacy White list Legacy Pairing, LE secure connections HCI interface (full, like stm32wb5x_BLE_HCILayer_fw.bin) Direct Test Mode L2CAP connection oriented channels support (IP over BLE enabler) Channel selection #2 (under application flag selection) BLE Extended advertising (under application flag selection with predefined fixed configuration: 3 sets maximum number, 1650 bytes maximum advertising data length) Warning: To use this binary, it is necessary to adapt the scatter file in the BLE applications as: The RAM_A shared range shall be reduced to memory range [0x20030000:0x200307FF] The Mail-box buffers(MB_MEM1, MB_MEM2) shall be located in RAM_B shared defined in memory range [0x20038000:0x2003A7FF] The RAM_B shared shall be added to Total_RAM_region
stm32wb5x_BLE_Stack_light_fw.bin Full BLE Stack 5.2 certified : Link Layer, HCI, L2CAP, ATT, SM, GAP and GATT database BT SIG Certification listing : Declaration ID D042164 Wireless Ble stack Light configuration – Slave Only Following features are kept: GAP peripheral only (LL Slave up to 2 links) GATT server Data length extension Privacy White list Legacy Pairing, LE secure connections HCI interface (reduced) Additional beacon Following features are removed: - Direct Test Mode BLE “Slave Only” stack implies that with this stack configuration, STM32WB is not able to scan and request a BLE connection. It will just advertise, and accept incoming connection request from other master devices (e.g. Smartphone) (Slave up to 2 links). While with the “full feature” BLE stack, STM32WB5xx is able to support both master and slave roles on different links (with the limitation of max 8 links in parallel, from which max 2 slave links).
stm32wb5x_BLE_Stack_basic_fw.bin [MODIFIED] Full BLE Stack 5.2 certified : Link Layer, HCI, L2CAP, ATT, SM, GAP and GATT database BT SIG Certification listing : Declaration ID D042164 Wireless Ble stack Basic configuration Following features are kept: GAP peripheral & Central (8 links - LL slave up to 2 links) GATT server, client Data length extension Privacy White list Legacy Pairing, LE secure connections HCI interface (reduced) Phy update (2Mb/s) Additional beacon Following features are removed: L2Cap Connection - oriented channel (Chip/ Ip over BLE,…) Some HCI interface features (won’t be able to process through HCI interface) Direct test mode
stm32wb5x_BLE_HCILayer_fw.bin HCI Layer only mode 5.2 certified : Link Layer, HCI with Direct Test Mode BT SIG Certification listing : Declaration ID D042213 stm32wb5x_BLE_HCILayer_extended_fw.bin [NEW] HCI Layer only mode 5.2 certified : Link Layer, HCI with Direct Test Mode BT SIG Certification listing : Declaration ID D042213 BLE Extended advertising (under application flag selection with predefined fixed configuration: 3 sets maximum number, 1650 bytes maximum advertising data length)
stm32wb5x_BLE_Stack_full_extended_fw.bin Full BLE Stack 5.2 certified : Link Layer, HCI, L2CAP, ATT, SM, GAP and GATT database BT SIG Certification listing : Declaration ID D042164 Following features are kept: GAP peripheral, central (LL Master up to 6 links with Slave up to 2 links/ Master up to 7 links with Slave up to 1 links/ Master up to 8 links ) GATT server, client Data length extension 2Mbit PHY / PHY update Privacy White list Legacy Pairing, LE secure connections HCI interface (full, like stm32wb5x_BLE_HCILayer_fw.bin) Direct Test Mode L2CAP connection oriented channels support (IP over BLE enabler) Channel selection #2 BLE Extended advertising/scanning
HCI Layer only mode 5.2 certified : Link Layer, HCI BT SIG Certification listing : Declaration ID D042213 To be used for advertising and scanning through HCI interface
stm32wb5x_BLE_HCILayer_fw.bin HCI Layer only mode 5.2 certified : Link Layer, HCI with Direct Test Mode BT SIG Certification listing : Declaration ID D042213
- Add the support of STM32 MCU in Arduino IDE[1]:
- Include STM32duinoBLE library:
- STM32duinoBLE[4]
- From the "Tools > Manage Librairies..." menu, select the STM32duinoBLE library:
- STM32duinoBLE[4]
STM32duinoBLE library |
---|
- Configuring IDE:
- Connect the Nucleo-64 WB55 board to the computer USB port.
- Launch the Arduino software
- Select the Nucleo-64 WB55 board in two steps:
- From the "Tools > Board" menu, select the STM32 boards groups: Nucleo-64
- Then from the "Tools > Board part number" menu, select the P-Nucleo WB55RG
Arduino Nucleo-64 WB55 Configuration |
---|
1.2. BLE Stack Configuration for P-NUCLEO-WB55
BLE Stack configuration for P-NUCLEO-WB55:
- For release v1.12.0 and previous use full stack (stm32wb5x_BLE_Stack_full_fw.bin)
- For release v1.13.0 and next use HCI Layer stack (stm32wb5x_BLE_HCILayer_fw.bin) and do the following modification in stm32BLEDuino library:
- In HCISharedMemTransport.cpp file comment the following lines:
HCISharedMemTransport.cpp modification |
---|
1.3. Sketch STM32WB_P2P_Server.ino
The following Arduino's Sketch demonstrates the P2P Server application including debug traces on the UART hyperterminal.
- compile and upload STM32WB_P2P_Server.ino
/**
******************************************************************************
* @file STM32WB_P2P_Server.ino
* @author WBL BLE Application Team
* @brief Arduino STM32WB P2P Server Application (Custom STM)
******************************************************************************
* @attention
* This example creates a P2P server Application
* P2P service - 0000FE40-cc7a-482a-984a-7f2ed5b3e58f
* Led control Characteristic - 0000FE41-8e22-4541-9d4c-21edae82ed19 (Read|WritewithoutResponse)
* Byte 0 - Board Selection
* Byte 1 - LED Status (1 : ON; 0 : OFF)
* Button control Characteristic - 0000FE42-8e22-4541-9d4c-21edae82ed19 (Notify)
* Byte 0 - Board Selection
* Byte 1 - LED Status (1 : ON; 0 : OFF)
* To be supported by Smart Phone application ST BLE Sensor, the advertsing data shall contain the AD element Manufacturer as following:
* Manufacturer_data:
* 0x01, // SKD version
* 0x83, // CFG_DEV_ID_P2P_SERVER1
* 0x00, // GROUP A Feature
* 0x00, // GROUP A Feature
* 0x00, // GROUP B Feature
* 0x00, // GROUP B Feature
* };
*
* The two characteristics are used :
* -- to control (Write) the LED1 of Nucleo64-WB55 board LED
* -- or to Notify the Remote device by pushing SW1 f Nucleo68-WB55 board.
*
* The Circuit:
* - Nucleo68-WB55
* You can use a generic BLE central app, like ST BLE Sensor or ST BLE Toolbox, to interact with the services and characteristics
* created in this sketch.
*
* This example code is in the public domain.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include <STM32duinoBLE.h>
/* Private typedef -----------------------------------------------------------*/
typedef struct __attribute__((packed)) {
byte boardSelection;
byte ledStatus;
} P2P_STM32WB_led_t;
P2P_STM32WB_led_t ledControl;
typedef struct __attribute__((packed)) {
byte boardSelection;
byte ButtonStatus;
} P2P_STM32WB_button_t;
P2P_STM32WB_button_t buttonInfo;
/* Private variables ---------------------------------------------------------*/
const int buttonPin = PC4; // set buttonPin to digital pin PC4
const int ledPin = LED_BUILTIN; // set ledPin to on-board LED
const int buttonPushed = 1;
const int boardWB_1 = 1;
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 1; // previous state of the button
/* Private variables ---------------------------------------------------------*/
/* UUID for P2P Service-------------------------------------------------------*/
BLEService P2PService("0000FE40-cc7a-482a-984a-7f2ed5b3e58f");
/* create switch characteristic and allow remote device to read and write -----*/
BLECharacteristic ledCharacteristic("0000FE41-8e22-4541-9d4c-21edae82ed19", BLERead | BLEWriteWithoutResponse,sizeof(ledControl),true);
/* create button characteristic and allow remote device to get notifications --*/
BLECharacteristic buttonCharacteristic("0000FE42-8e22-4541-9d4c-21edae82ed19", BLENotify,sizeof(buttonInfo),true);
/* Manufacturer Advertising Data element structure ----------------------------*/
static const uint8_t manufacturer_data[6] = {
0x01, // BlueST Protocol - SDK Version
0x83, // Device ID - STM32WB P2P Server
0x00, // GROUP A Feature
0x00, // GROUP A Feature
0x00, // GROUP B Feature
0x00, // GROUP B Feature
};
HCISharedMemTransportClass HCISharedMemTransport;
BLELocalDevice BLEObj(&HCISharedMemTransport);
BLELocalDevice& BLE = BLEObj;
/**
* @brief Connection Event Handler
* @param BLE Central Device
* @retval None
*/
void blePeripheralConnectHandler(BLEDevice central) {
// central connected event handler
Serial.print("==> Connection established with central: ");
Serial.print(central.address());
if (BLE.connected()) {
Serial.print(" -- RSSI = ");
Serial.println(BLE.rssi());
}
}
/**
* @brief Disconnection Event Handler
* @param BLE Central Device
* @retval None
*/
void blePeripheralDisconnectHandler(BLEDevice central) {
// central disconnected event handler
Serial.print("==> Disconnection event with central: ");
Serial.println(central.address());
}
/**
* @brief Event Handler when Characteristic Written
* @param BLE Central Device
* @param Characteritic
* @retval None
*/
void LedCharacteristicWritten(BLEDevice central, BLECharacteristic characteristic) {
byte data[sizeof(ledControl)];
// central wrote new value to characteristic, update LED
if (ledCharacteristic.written()) {
Serial.println("==>Led Characteritics written:");
Serial.print("Data Received: ");
ledCharacteristic.readValue(data, sizeof(ledControl));
Serial.print(ledCharacteristic.valueLength());
Serial.print(" ");
Serial.print("bytes -- ");
for (int i = 0; i < sizeof(ledControl); i++) {
Serial.print("0x");
Serial.print(data[i], HEX);
Serial.print(" ");
}
Serial.println();
ledControl.boardSelection=data[0];
ledControl.ledStatus=data[1];
Serial.print("Board Selected:");
Serial.println(ledControl.boardSelection);
Serial.print("Value:");
Serial.println(ledControl.ledStatus);
if(ledControl.ledStatus){
Serial.println("==>LED1 ON");
digitalWrite(ledPin, HIGH);
}
if(!ledControl.ledStatus){
Serial.println("==>LED1 OFF");
digitalWrite(ledPin, LOW);
}
}
}
/**
* @brief Arduino main Setup
* @param None
* @retval None
*/
void setup() {
Serial.begin(115200);
while (!Serial);
pinMode(ledPin, OUTPUT); // use the LED as an output
pinMode(buttonPin, INPUT_PULLUP); // use button pin as an input
//Project P2P server
Serial.println("======================================");
Serial.println("== STM32WB - P2P Server Application ==");
Serial.println("======================================");
// begin initialization
if (!BLE.begin()) {
Serial.println("==>starting BLE failed!");
while (1);
}
//Set the device name in the built in device name characteristic.
BLE.setDeviceName("STM32WB-Arduino");
//set the local name peripheral advertises
Serial.println("==> Advertising Name - P2P_Server");
BLE.setLocalName("P2P_Server");
//Set the manufacturer data value used when advertising.
BLE.setManufacturerData(manufacturer_data, sizeof(manufacturer_data));
//Set the advertising interval in units of 0.625 ms.
//Defaults to 100ms (160 * 0.625 ms) if not provided.
BLE.setAdvertisingInterval(160); // 160 * 0.625 ms
// set the UUID for the service this peripheral advertises:
//BLE.setAdvertisedService(P2PService);
// add the characteristics to the service
P2PService.addCharacteristic(ledCharacteristic);
P2PService.addCharacteristic(buttonCharacteristic);
// assign event handlers for characteristic
ledCharacteristic.setEventHandler(BLEWritten, LedCharacteristicWritten);
// add the service
BLE.addService(P2PService);
//configure data to Notify when SW1 pushed
buttonInfo.boardSelection = boardWB_1;
buttonInfo.ButtonStatus=buttonPushed;
// start advertising
BLE.advertise();
String address = BLE.address();
Serial.print("==>Local address is: ");
Serial.println(address);
Serial.println("==>Advertising Started, waiting for connections...");
// assign event handlers for connected, disconnected to peripheral
BLE.setEventHandler(BLEConnected, blePeripheralConnectHandler);
BLE.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
}
/**
* @brief Arduino Loop
* @param None
* @retval None
*/
void loop() {
// poll for BLE events
BLE.poll();
// read the SW1 Button input pin:
buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == LOW) {
// if the current state is HIGH then the button went from off to on:
buttonPushCounter++;
//Serial.println("on");
Serial.print("==> Number of time button is pushes: ");
Serial.println(buttonPushCounter);
//check if connection is established by Central device
if(BLE.central()){
//check if Notification is enabled
if (buttonCharacteristic.subscribed()) {
Serial.println("buttonCharacteristic is subscribed:");
Serial.println("==>Notification of Button Pushed is sent");
buttonCharacteristic.writeValue((byte*) &buttonInfo, sizeof(buttonInfo));
} else {
Serial.println("buttonCharacteristic is NOT subscribed:");
Serial.println("==>Notification is NOT sent");
}
}
} else {
// if the current state is LOW then the button went from on to off:
//Serial.println("off");
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
lastButtonState = buttonState;
}
/************************************ STMicroelectronics *****END OF FILE****/
1.4. Debug Traces
At the startup, the HyperTerminal displays the following Traces
Startup Debug Trace |
---|
2. Smart Phone Application - ST BLE Sensor
- Download ST BLE Sensor or ST BLE ToolBox application on the smartphone.
- Scan and Connect to P2P_Server
- Toggle SmartPhone LED or Push SW1 Button of the Nucleo-64 WB55 board.
ST BLE Sensor Scan | ST BLE Sensor Connect |
---|---|
- Debug Trace displays all the sequences at application level
Arduino Nucleo-64 WB55 Traces |
---|