cancel
Showing results for 
Search instead for 
Did you mean: 

What is the correct way to update a custom BLE characteristic on STM32WB50CG?

tj.1
Associate

I have a question about how to correctly update a value of characteristic of custom BLE service on STM32WB50CG. The project was set up with CubeMX following their official tutorial:

https://www.youtube.com/watch?v=i10X4Blr8ns.

My main application is running on M4 core. It uses multiple sensors and then does various statistics with data taken from them. BLE stack is running on M0+ core. I can see all the services & characteristics I defined in the app (BLE Toolbox from STM) on my Android phone. Now I am trying to figure out how to update characteristics from main application. I tried to call those functions bellow with predefined value in my main app, but read value of characteristic on my Android phone is always 0.

Result status of aci_gatt_update_char_value is "success" when Custom_STM_App_Update_Char is called.

Functions I tried to call in my main application on M4 core to update characteristics (with fixed value of 5 for testing purposes)

Custom_STM_App_Update_Char(CUSTOM_STM_CVOLTAGE, (uint8_t*)5);
Custom_STM_App_Update_Char(CUSTOM_STM_CCURRENT, (uint8_t*)5);

Example of two update value functions for my characteristics

case CUSTOM_STM_CVOLTAGE:
  result = aci_gatt_update_char_value(CustomContext.CustomVsHdle,
                                      CustomContext.CustomCvoltageHdle,
                                      0, /* charValOffset */
                                      SizeCvoltage, /* charValueLen */
                                      (uint8_t *)  pPayload);
  /* USER CODE BEGIN CUSTOM_STM_Service_1_Char_1*/
 
  /* USER CODE END CUSTOM_STM_Service_1_Char_1*/
  break;
 
case CUSTOM_STM_CCURRENT:
  result = aci_gatt_update_char_value(CustomContext.CustomCsHdle,
                                      CustomContext.CustomCcurrentHdle,
                                      0, /* charValOffset */
                                      SizeCcurrent, /* charValueLen */
                                      (uint8_t *)  pPayload);
  /* USER CODE BEGIN CUSTOM_STM_Service_3_Char_1*/
 
  /* USER CODE END CUSTOM_STM_Service_3_Char_1*/
  break;

1 REPLY 1
Remy ISSALYS
ST Employee

Hello,

Can you give more details about characteristics properties, please ?

If your characteristic have Notify property, you shall enable the notification on client side (e.g. on ST BLE Toolbox) in order to receive characteristic value update.

Best Regards