cancel
Showing results for 
Search instead for 
Did you mean: 

BLE Server Side read Event nevers happens

oga
Associate III

hi all,

I'm working on a STM32WB5MMGHX and I have play with p2p demos and other

I'm trying now to build a Battery service with only a battery level caracteristic

I've set the caracteristic as shown below

oga_0-1698937290193.png

my custom app event handler is as folow :

 

void Custom_STM_App_Notification(Custom_STM_App_Notification_evt_t *pNotification) { /* USER CODE BEGIN CUSTOM_STM_App_Notification_1 */ /* USER CODE END CUSTOM_STM_App_Notification_1 */ switch (pNotification->Custom_Evt_Opcode) { /* USER CODE BEGIN CUSTOM_STM_App_Notification_Custom_Evt_Opcode */ /* USER CODE END CUSTOM_STM_App_Notification_Custom_Evt_Opcode */ /* BatteryService */ case CUSTOM_STM_BATT_LVL_READ_EVT: /* USER CODE BEGIN CUSTOM_STM_BATT_LVL_READ_EVT */ APP_BATT_Single_Action(); /* USER CODE END CUSTOM_STM_BATT_LVL_READ_EVT */ break; case CUSTOM_STM_BATT_LVL_NOTIFY_ENABLED_EVT: /* USER CODE BEGIN CUSTOM_STM_BATT_LVL_NOTIFY_ENABLED_EVT */ Custom_App_Context.Batt_lvl_Notification_Status = 1; /* USER CODE END CUSTOM_STM_BATT_LVL_NOTIFY_ENABLED_EVT */ break; case CUSTOM_STM_BATT_LVL_NOTIFY_DISABLED_EVT: /* USER CODE BEGIN CUSTOM_STM_BATT_LVL_NOTIFY_DISABLED_EVT */ Custom_App_Context.Batt_lvl_Notification_Status = 0; /* USER CODE END CUSTOM_STM_BATT_LVL_NOTIFY_DISABLED_EVT */ break;

 

I'm using a standard ble test tool on my phone to request notification and reading of my characteristic (nrf connect)

it works perfectly for notification requests but for read requests I never fall into CUSTOM_STM_BATT_LVL_READ_EVT

I've try to dig into Custom stm handler mecanism to find out if evet occur or not but I didnt get any results when sending a read request

I've try with or without enabling GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP it doesnt change anything strangely when enabling GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP I have no case event pre-defined by cube mx into my event handler

in a more general question :

I've read st wiki https://wiki.st.com/stm32mcu/wiki/Connectivity:STM32WB_BLE_STM32CubeMX

and other user/beginners guides on ble but I don't find any details on cube my STM32_WPAN parameters

if you can orient me to find something more detailed I would be very grateful

1 ACCEPTED SOLUTION

Accepted Solutions
_Joe_
ST Employee

Hi @oga!
You can try to enable in STM32CubeMX :
GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP
And then in :
custom_stm.c > Custom_STM_Event_Handler() > case ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE :
add the 2 following lines :

 

 

/*USER CODE BEGIN CUSTOM_STM_BATT_LVL_ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE_2 */ Notification.Custom_Evt_Opcode = CUSTOM_STM_BATT_LVL_READ_EVT; Custom_STM_App_Notification(&Notification); /*USER CODE END CUSTOM_STM_BATT_LVL_ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE_2*/

 

 

 Please don't hesitate to let me know if it has resolved your issue!

Regarding the details of the STM32WPAN parameters, when you click on the parameters in STM32CubeMX, a small explanation window should open.
Is this the case for you? On which type of parameter would you like to have more information?

View solution in original post

1 REPLY 1
_Joe_
ST Employee

Hi @oga!
You can try to enable in STM32CubeMX :
GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP
And then in :
custom_stm.c > Custom_STM_Event_Handler() > case ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE :
add the 2 following lines :

 

 

/*USER CODE BEGIN CUSTOM_STM_BATT_LVL_ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE_2 */ Notification.Custom_Evt_Opcode = CUSTOM_STM_BATT_LVL_READ_EVT; Custom_STM_App_Notification(&Notification); /*USER CODE END CUSTOM_STM_BATT_LVL_ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE_2*/

 

 

 Please don't hesitate to let me know if it has resolved your issue!

Regarding the details of the STM32WPAN parameters, when you click on the parameters in STM32CubeMX, a small explanation window should open.
Is this the case for you? On which type of parameter would you like to have more information?