Skip to main content
Associate III
January 8, 2025
Solved

Programattically Enable/Disable Characteristic Notification

  • January 8, 2025
  • 1 reply
  • 994 views

I have two custom STM32WB55 boards that I initially started with the P2P_Client/Server projects.  I have the two devices communicating with each other.  Once the communication is established, the notification characteristic is enabled from the P2P_Client, and data starts flowing from the server to the client.  Next step is to try and disable/enable the notification programmatically from the P2P_Client.  I see in the p2p_client_app.c file, there is an event handler for, APP_BLE_ENABLE_NOTIFICATION_DESC and APP_BLE_DISABLE_NOTIFICATION_DESC.

Can anyone point me to the correct process for either setting the status somehow so that the event handler is utilized or what is the recommended process for enabling/disabling a notification programmatically from the P2P_Client?

Kindest regards.

Best answer by STTwo-32

Hello @kumaichi 

To Enable/Disable notifications, you can use the aci_gatt_write_char_desc function on the context of update_Service() in p2p_Client_app.c. This will set the Client Characteristic Configuration Descriptor (CCCD) of the "Notify" Service to enabled or disabled. 

For more details, you can have a look at the p2p_Client_app.c file of the ST Client node example.

Best Regards.

STTwo-32

1 reply

STTwo-32
STTwo-32Best answer
Technical Moderator
January 31, 2025

Hello @kumaichi 

To Enable/Disable notifications, you can use the aci_gatt_write_char_desc function on the context of update_Service() in p2p_Client_app.c. This will set the Client Characteristic Configuration Descriptor (CCCD) of the "Notify" Service to enabled or disabled. 

For more details, you can have a look at the p2p_Client_app.c file of the ST Client node example.

Best Regards.

STTwo-32