Skip to main content
Associate II
Jul 17, 2025 1:04 PM UTC
Solved

Connect two STM32WB MCUs via BLE

Hello everyone,
I’m working on a BLE project using two STM32WB55 boards.
My goal is to create a connection between them without using the ST BLE Toolbox App.
One board is configured as a Custom Server (Peripheral), and the other as a P2P Client (Central).

I want to ensure that I am properly connected to my server and receiving notifications.
But I am not sure about how using:

Start scanning

Identify the correct server

Connect

Discover services

Enable notifications

Receive data

 

 

Please without saying follow the P2p example, because I didn't catch it

This topic has been closed for replies.
FilipKremen
FilipKremenBest answer
ST Employee
Jul 23, 2025 1:32 PM UTC

Hello,

the characteristic property CHAR_PROP_NOTIFY needs to be enabled. Then if you press button 1, it sends the notification to the client via Custom_Switch_c_Send_Notification() function. (BLE_Custom example, custom_app.c)

Best regards,

Filip Kremen

 

9 replies

FilipKremen
ST Employee
Jul 17, 2025 2:10 PM UTC

Hello,

have you read this Wiki page?

It provides more information regarding P2P application. It's meant for WBA series, however the structure is similar to WB series.

STM32WBA Bluetooth® LE – Peer 2 Peer Applications - stm32mcu

I also recommend reading this document below.

Guidelines for Bluetooth® LE stack programming on STM32WB/STM32WBA MCUs - Programming manual

If you have any other question, please don't hesitate to ask.

 

Best regards,

Filip Kremen

Associate II
Jul 17, 2025 2:48 PM UTC

My objective is to send some sensor data from an MCU to other one, so what is the best solution for me, and I didn't catch the BLE_p2pClient example, so if there is any other clear tutorial or reference to follow ? (I reached to send the data to ST Toolbox App) 

FilipKremen
ST Employee
Jul 18, 2025 8:33 AM UTC

Hello,

I recommend reading a readme file in the BLE_p2pClient example for overview.

Also, if you have a look at p2p_client_app.c file you can find there Button_Trigger_Received() function which writes to a characteristic on server side, and you can toggle LED based on this value. You can also add your own characteristic to the server for your own data. 

Section 7 in the document also provides additional information for building BLE application.

How to build wireless applications with STM32WB MCUs - Application note

Best regards,

Filip Kremen

Associate II
Jul 21, 2025 11:00 AM UTC

After reading the BLE_p2pClient example, how can I modify the example to start the scanning without pressing the button B1? and how this scan is done exactly in software?

 

FilipKremen
ST Employee
Jul 21, 2025 11:16 AM UTC

Hello,

you could for example call UTIL_SEQ_SetTask(1 << CFG_TASK_START_SCAN_ID, CFG_SCH_PRIO_0) function at the end of APP_BLE_Init() or you could use a timerserver that would run the function above after certain interval.

Regarding the scan, the task CFG_TASK_START_SCAN_ID is registered in the sequencer and then it can be run with the function mentioned above. The scan starts with aci_gap_start_general_discovery_proc() command from Scan_request() function. I hope you can understand it better now, please don't hesitate to ask further.

 

Best regards,

Filip Kremen

Associate II
Jul 21, 2025 11:35 AM UTC

Great, and how can the scanning detect the right server exactly? with the UUID ? 

FilipKremen
ST Employee
Jul 21, 2025 2:23 PM UTC

The found devices are returned via HCI_LE_ADVERTISING_REPORT_SUBEVT_CODE in app_ble.c file.

In the switch case (SVCCTL_App_Notification() function) you can see how the server is found according to

AD_TYPE_MANUFACTURER_SPECIFIC_DATA.

 

Best regards,

Filip Kremen

Associate II
Jul 21, 2025 2:48 PM UTC

I appreciate really your time, I would a full guideline to receive some data from the server part to the client part, so exactly I need the code from the client part.

The function which I am using in custom_app.c file is myTask(void):

 

void myTask(void)

{

if( abs(prevCOPx + COPx) >= 5 || abs(prevCOPy + COPy) >= 5 ){

strcpy(NotifyCharData, message);

Custom_Mycharnotify_Send_Notification();

}

prevCOPx = COPx;

prevCOPy = COPy;

UTIL_SEQ_SetTask(1 << CFG_TASK_MY_TASK, CFG_SCH_PRIO_0);

}

 I want a way to how receive this notification on my other client MCU, thanks in advance.

FilipKremen
FilipKremenBest answer
ST Employee
Jul 23, 2025 1:32 PM UTC

Hello,

the characteristic property CHAR_PROP_NOTIFY needs to be enabled. Then if you press button 1, it sends the notification to the client via Custom_Switch_c_Send_Notification() function. (BLE_Custom example, custom_app.c)

Best regards,

Filip Kremen