ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
c7222::Characteristic::EventHandler Struct Reference

Characteristic event handler structure. More...

#include <characteristic.hpp>

Inheritance diagram for c7222::Characteristic::EventHandler:
Inheritance graph
Collaboration diagram for c7222::Characteristic::EventHandler:
Collaboration graph

Public Member Functions

virtual void OnUpdatesEnabled (bool is_indication)
 Called when notifications or indications are enabled by a client.
 
virtual void OnUpdatesDisabled ()
 Called when notifications or indications are disabled by a client.
 
virtual void OnIndicationComplete (uint8_t status)
 Called when an indication transaction completes.
 
virtual void OnBroadcastEnabled ()
 Called when broadcasts are enabled by a client.
 
virtual void OnBroadcastDisabled ()
 Called when broadcasts are disabled by a client.
 
virtual void OnRead ()
 Called when a read operation is performed on this characteristic.
 
virtual void OnWrite (const std::vector< uint8_t > &data)
 Called when a write operation is performed on this characteristic.
 
virtual void OnConfirmationReceived (bool status)
 Called when a confirmation for an indication is received.
 

Protected Member Functions

virtual ~EventHandler ()=default
 Virtual destructor for the EventHandlers interface.
 

Detailed Description

Characteristic event handler structure.

This structure contains callback functions for various characteristic events related to client configuration changes, value access, and confirmations.

These callbacks are fired by:

  • CCCD/SCCD writes (client enables/disables updates or broadcasts).
  • Attribute read/write on the value attribute.
  • HCI indication completion events passed via DispatchBleHciPacket().
Note
These Handlers are called before the data of the Attributes are updated!

Constructor & Destructor Documentation

◆ ~EventHandler()

virtual c7222::Characteristic::EventHandler::~EventHandler ( )
protectedvirtualdefault

Virtual destructor for the EventHandlers interface.

This ensures proper cleanup of derived classes when deleted through a base class pointer. It provides a default no-op implementation and allows implementing classes to define their own destructor behavior if needed.

Member Function Documentation

◆ OnBroadcastDisabled()

virtual void c7222::Characteristic::EventHandler::OnBroadcastDisabled ( )
inlinevirtual

Called when broadcasts are disabled by a client.

This callback is invoked when a client writes to the SCCD to disable broadcasts for this characteristic (or writes 0x0000). The SCCD value has already been written when this fires.

Reimplemented in CharacteristicEventHandler.

◆ OnBroadcastEnabled()

virtual void c7222::Characteristic::EventHandler::OnBroadcastEnabled ( )
inlinevirtual

Called when broadcasts are enabled by a client.

This callback is invoked when a client writes to the SCCD to enable broadcasts for this characteristic. The SCCD value has already been written when this fires.

Reimplemented in CharacteristicEventHandler.

◆ OnConfirmationReceived()

virtual void c7222::Characteristic::EventHandler::OnConfirmationReceived ( bool  status)
inlinevirtual

Called when a confirmation for an indication is received.

This callback is invoked when a confirmation is received for an indication previously sent to a client. The status parameter indicates whether the confirmation was successfully received or if there was an error (e.g., timeout, disconnect).

Parameters
statustrue if confirmation was received successfully, false otherwise
Note
Only applicable for characteristics with Indication property.

Reimplemented in CharacteristicEventHandler.

◆ OnIndicationComplete()

virtual void c7222::Characteristic::EventHandler::OnIndicationComplete ( uint8_t  status)
inlinevirtual

Called when an indication transaction completes.

This callback is invoked when the indication process finishes, regardless of outcome. The status parameter indicates whether the confirmation was successfully received, timed out, or the connection was lost. Fired after the HCI ATT_EVENT_HANDLE_VALUE_INDICATION_COMPLETE is received and parsed in DispatchBleHciPacket().

Parameters
status0 for success, non-zero for error (timeout, disconnect, etc.)
Note
Only applicable for characteristics with Indication property.
This provides additional status information beyond OnConfirmationReceived.

Reimplemented in CharacteristicEventHandler.

◆ OnRead()

virtual void c7222::Characteristic::EventHandler::OnRead ( )
inlinevirtual

Called when a read operation is performed on this characteristic.

This callback is invoked when a client attempts to read the characteristic value. This is a notification callback from the default read handler. Use this to update the characteristic value (via SetValue()) before it is copied into the read response.

Reimplemented in CharacteristicEventHandler.

◆ OnUpdatesDisabled()

virtual void c7222::Characteristic::EventHandler::OnUpdatesDisabled ( )
inlinevirtual

Called when notifications or indications are disabled by a client.

This callback is invoked when a client writes to the CCCD to disable updates for this characteristic (or writes 0x0000). The CCCD write has been validated, but the stored descriptor value is committed only after the write callback returns.

Reimplemented in CharacteristicEventHandler.

◆ OnUpdatesEnabled()

virtual void c7222::Characteristic::EventHandler::OnUpdatesEnabled ( bool  is_indication)
inlinevirtual

Called when notifications or indications are enabled by a client.

This callback is invoked when a client writes to the CCCD to enable updates for this characteristic. The CCCD write has been validated, but the stored descriptor value is committed only after the write callback returns. Use the is_indication argument to understand the requested mode instead of querying the CCCD inside this callback.

Parameters
is_indicationtrue if indications are enabled, false if notifications are enabled

Reimplemented in CharacteristicEventHandler.

◆ OnWrite()

virtual void c7222::Characteristic::EventHandler::OnWrite ( const std::vector< uint8_t > &  data)
inlinevirtual

Called when a write operation is performed on this characteristic.

This callback is invoked when a client writes data to the characteristic value. This is a notification callback from the default write handler with the written data provided for information. The data has already been stored in the value attribute (dynamic storage).

Parameters
dataThe data written by the client

Reimplemented in CharacteristicEventHandler.


The documentation for this struct was generated from the following file: