Skip to content

abluethinginthecloud/STM32WB-custom-ble-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

STM32WB Custom BLE Examples

Custom Bluetooth Low Energy (BLE) UART service examples for STM32WB15 and STM32WB55 microcontrollers.

Build your own custom BLE GATT profile on top of the STMicroelectronics STM32WB wireless MCU family, using practical firmware examples for both a small bare-metal device and a larger FreeRTOS-based target.


STM32WB BLE STM32CubeIDE Language

Read the full technical article · Visit A Blue Thing In The Cloud · YouTube channel


Overview

This repository shows how to create a custom BLE peripheral device using the STM32WB15 and STM32WB55 wireless microcontrollers from STMicroelectronics.

The examples implement a simple but useful BLE UART-style service with two custom GATT characteristics:

Characteristic Direction BLE property Purpose
RX Central → STM32WB Write Receives data sent by the BLE central device
TX STM32WB → Central Read + Notify Sends data back to the BLE central device

The demo firmware implements an echo application: when a BLE central writes data to the RX characteristic, the STM32WB device sends the same data back through the TX characteristic.

This makes the project a practical starting point for custom BLE products such as:

  • Wireless sensors
  • BLE configuration interfaces
  • Mobile-app-controlled devices
  • Industrial BLE peripherals
  • Low-power connected products
  • Custom GATT services for embedded systems

Repository structure

STM32WB-custom-ble-examples/
├── STM32WB15_BLE/      # STM32WB15 custom BLE UART example
├── STM32WB55_BLE/      # STM32WB55 custom BLE UART example
└── README.md

Examples included

Example Target board / MCU Firmware style Description
STM32WB15_BLE STM32WB15CC Nucleo / STM32WB15CCU6 Bare-metal style application Custom BLE UART service for the smaller STM32WB15 device
STM32WB55_BLE STM32WB55 Nucleo Pack FreeRTOS-based application Custom BLE UART service for the larger STM32WB55 device

Both examples expose the same custom BLE UART-style service and are designed to help you understand how to add your own services and characteristics to an STM32WB BLE peripheral.


Development environment

The original examples were created and tested with:

Tool Version
STM32CubeIDE 1.9.0
STM32CubeWB Firmware Package 1.13.2
Language C
Connectivity Bluetooth Low Energy

Newer STM32CubeIDE and STM32CubeWB versions may work, but depending on ST middleware changes you may need to update generated files, linker scripts or middleware configuration.


BLE GATT profile

The example implements one custom service with two custom characteristics:

Custom UART Service
├── RX Characteristic
│   └── Write property
└── TX Characteristic
    ├── Read property
    └── Notify property

RX characteristic

The RX characteristic is written by the BLE central device. In a real product, this is where you would receive commands, configuration packets or application data.

TX characteristic

The TX characteristic is used by the STM32WB device to send data back to the central device. It supports both:

  • Read, so the central can read the latest value.
  • Notify, so the central can automatically receive new values when they are updated.

Maximum characteristic length

The example sets the RX and TX characteristic maximum length to 64 bytes.

The characteristic length definitions are located in:

Services/Service_UART.h

Look for:

SERVICE_UART_UART_RX_LONG_MAX
SERVICE_UART_UART_TX_LONG_MAX

The example notes that these values should not exceed 248 bytes.


Main files to study

The most relevant files for understanding and adapting the custom BLE service are:

File Purpose
STM32_WPAN/App/app_ble.c BLE stack initialization and BLE application setup
Configuration/Device_Configuration.h Device-level configuration, including BLE advertising name
Services/Service_UART.h Custom service UUIDs, characteristic UUIDs and public service definitions
Services/Service_UART.c Custom BLE service implementation, GATT service creation, characteristic creation and event handling

The full technical explanation is available in the companion article:

Custom BLE profile on STM32WB microcontrollers


How it works

The BLE application flow is:

  1. The STM32WB initializes the BLE stack.
  2. The firmware registers the custom UART service handler.
  3. The custom BLE service is added to the GATT database.
  4. The RX and TX characteristics are added to the service.
  5. The device starts advertising.
  6. A BLE central device connects to the STM32WB peripheral.
  7. The central writes data to the RX characteristic.
  8. The firmware receives the write event.
  9. The demo echoes the received data back through the TX characteristic.

In the demo application, the echo behavior is implemented through:

void Service_UART_Test_Echo(const uint8_t *pData, uint8_t nData);

For your own product, this is the kind of location where you would replace the echo logic with your real application logic.


Getting started

1. Clone the repository

git clone https://github.com/abluethinginthecloud/STM32WB-custom-ble-examples.git
cd STM32WB-custom-ble-examples

2. Open the project in STM32CubeIDE

Open the example that matches your hardware:

  • STM32WB15_BLE
  • STM32WB55_BLE

3. Build the project

In STM32CubeIDE:

  1. Import the selected project.
  2. Clean the project.
  3. Build the project.
  4. Check that the firmware compiles without errors.

4. Flash the board

Connect your STM32WB development board and flash the generated firmware using STM32CubeIDE.

5. Test the BLE UART echo service

Use a BLE central device such as a smartphone BLE scanner application.

Recommended test flow:

  1. Power or reset the STM32WB board.
  2. Scan for BLE devices.
  3. Connect to the STM32WB peripheral.
  4. Discover the custom UART service.
  5. Subscribe to notifications on the TX characteristic.
  6. Write sample data to the RX characteristic, for example:
20 21 22
  1. The same data should be received back through the TX characteristic.

Customizing the BLE service

Change the BLE advertising name

The advertising name is configured in:

Configuration/Device_Configuration.h

Change the custom UUIDs

About

This repository is used to explain how to add custom BLE services and characteristics for STM32WB55 and STM32WB15.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages