Blocking Functions Called in BLE Callback?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JoYa_4324706
Level 3
Level 3
5 sign-ins First solution authored 10 replies posted

As mentioned in BLE Middleware Library and this document "PSoC 6 MCU- Firmware Design for BLE Applications" p.23: https://www.cypress.com/file/446566/download , Cy_BLE_SetSecurityKeys() should be called after devices are connected. However, is it thread safe to call this kind of blocking function in this interrupt based BLE callback function? Or is the callback function not necessarily "called" by an interrupt?

Thank you!

0 Likes
1 Solution
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

The application is informed of the BLE events( which are generated from controller) through the use of Callback function. The callback function is used for handling the BLE stack events. Some of the events are CY_BLE_EVT_STACK_ON, CY_BLE_EVT_GAPP_ADVERTISEMENT_START_STOP, CY_BLE_EVT_GAP_DEVICE_CONNECTED etc. please refer to the list of BLE Stack events in "cy_ble_stack.h" file. The application Host callback function processes the pending events by calling Cy_BLE_ProcessEvents().

Yes, we can call Cy_BLE_SetSecurityKeys() after devices are connected in CY_BLE_EVT_GAP_DEVICE_CONNECTED event. Please refer to the code example "CE212742_BLE_4.2_DataLength_Security_Privacy" in PSoC Creator for more information.

Thanks,

P Yugandhar.

View solution in original post

0 Likes
1 Reply
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

The application is informed of the BLE events( which are generated from controller) through the use of Callback function. The callback function is used for handling the BLE stack events. Some of the events are CY_BLE_EVT_STACK_ON, CY_BLE_EVT_GAPP_ADVERTISEMENT_START_STOP, CY_BLE_EVT_GAP_DEVICE_CONNECTED etc. please refer to the list of BLE Stack events in "cy_ble_stack.h" file. The application Host callback function processes the pending events by calling Cy_BLE_ProcessEvents().

Yes, we can call Cy_BLE_SetSecurityKeys() after devices are connected in CY_BLE_EVT_GAP_DEVICE_CONNECTED event. Please refer to the code example "CE212742_BLE_4.2_DataLength_Security_Privacy" in PSoC Creator for more information.

Thanks,

P Yugandhar.

0 Likes