cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement the Bluetooth server on STM32WB55 board for both sided data exchange with smartphone ?

AlexFj
Associate II

Looking for the either code examples (possibly simplified for understanding), or a guide for Bluetooth server implementation on a Nucleo STM32WB55 board for data reception and transmission.

The sample demo for purchased P-Nucleo STM32WB55 pack (board and dongle) with switching LED was tested and works fine. However, it's code does not seem to make it clear at all.

8 REPLIES 8
Stecklo
Senior

Basically you need to call aci_gatt_add_char() with Char_Properties = CHAR_PROP_NOTIFY, to create characteristic , then aci_gatt_update_char_value() to transmit data from server.

To receive data you need to call aci_gatt_add_char() with Char_Properties = CHAR_PROP_READ, then register handler SVCCTL_RegisterSvcHandler(service_event_handler) (you better look for implementation of the handler in the sample demo). And finally in the service_event_handler you wait for EVT_BLUE_GATT_ATTRIBUTE_MODIFIED event with Attr_Handle == your_characteristic_handle + 1

These are basics. AN5270 can help. As well as Bluetooth Core Specification

Stecklo
Senior

I ment CHAR_PROP_WRITE, not CHAR_PROP_READ is needed to recieve data

Stecklo
Senior

You could also make use of AN5289. ​It is roughly a description/guide of sample demo

AlexFj
Associate II

Thank you for the response. But how do I initiate the Bluetooth on the WB55 board in the first place ? If using the STM32cubeMX / IDE, i assume the corresponding code should be automatically generated by enabling the Connectivity->RF option (as for UART for exmaple). RF activation, however, returns "Warning: stm32cubemx does not support the configuration of this mode of this ip. However, this IP can be configured manually.", generates empty MX_RF_Init() function in the main code and ends there.

Stecklo
Senior

Yes, that's confusing. You need to activate Connectivity->RF so that RF pin is configured properly. To generate BLE code you need to activate Middlewares->STMWPAN. And I recommend you to activate P2P_server in STMWPAN settings. At least until you figure out how to make everything work.

AlexFj
Associate II

Okey, so BT is being activated in STMWPAN mode. Apparently it is using several side source files called in APPE_Init(); function. (BT requires functions of the Sequencer and LPM, which by default are not being recognized (app_ble and app_entry are missing the corresponding SEQ and LPM functions - solved by moving sequencer and lpm source and header files from Utility folder to Core->Src and Inc accordingly).

Wierd happens when the code is being build, debugged and uploaded without any errors, but apparently crashes somewhere inside the APPE_Init() function after running on a board - process is either not returning from the APPE_Init function, or stops right after. Board itself doesn't show up for another BT devices either. What may be an issue in this case ?

Stecklo
Senior

Moving files is not a wise desision. If you are using TrueStudio or CubeIDE the best way is:

  • in Project Explorer right click on any source folder (for examlple Core->Src or Middlewares)
  • New->File
  • Advanced >>
  • Link to file in file system
  • Browse to the desired source file

That will create a link to the library folder and your project will be more flexible in case of library update

You also need to add an include path Project->Properties->C/C++ general->Includes->Add

Stecklo
Senior

Read this article to enable sending debug info from board to PC