ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
GapEventHandler Class Reference

Minimal GAP event handler for example applications. More...

#include <gap_event_handler.hpp>

Inheritance diagram for GapEventHandler:
Inheritance graph
Collaboration diagram for GapEventHandler:
Collaboration graph

Public Member Functions

 GapEventHandler (c7222::Gap *gap=c7222::Gap::GetInstance(), c7222::AttributeServer *attribute_server=nullptr)
 Construct a handler with optional GAP and AttributeServer pointers.
 
void SetAttributeServer (c7222::AttributeServer *attribute_server)
 Attach an attribute server after construction.
 
void OnScanRequestReceived (uint8_t advertising_handle, const c7222::BleAddress &scanner_address) const override
 Logs scan requests received by the advertiser.
 
void OnAdvertisingStart (uint8_t status) const override
 Logs the start of advertising.
 
void OnAdvertisingEnd (uint8_t status, c7222::ConnectionHandle connection_handle) const override
 Logs the end of advertising.
 
void OnAdvertisingReport (const c7222::Gap::AdvertisingReport &report) const override
 Logs legacy advertising reports.
 
void OnExtendedAdvertisingReport (const c7222::Gap::ExtendedAdvertisingReport &report) const override
 Logs extended advertising reports.
 
void OnScanTimeout (uint8_t status) const override
 Logs a scan timeout event.
 
void OnPeriodicAdvertisingSyncEstablished (uint8_t status, c7222::ConnectionHandle sync_handle) const override
 Logs periodic advertising sync establishment.
 
void OnPeriodicAdvertisingReport (c7222::ConnectionHandle sync_handle, int8_t tx_power, int8_t rssi, uint8_t data_status, const uint8_t *data, uint8_t data_length) const override
 Logs a periodic advertising report.
 
void OnPeriodicAdvertisingSyncLoss (c7222::ConnectionHandle sync_handle) const override
 Logs loss of periodic advertising sync.
 
void OnConnectionComplete (uint8_t status, c7222::ConnectionHandle con_handle, const c7222::BleAddress &address, uint16_t conn_interval, uint16_t conn_latency, uint16_t supervision_timeout) const override
 Logs new connections and updates the attribute server handle.
 
void OnUpdateConnectionParametersRequest (c7222::ConnectionHandle con_handle, uint16_t min_interval, uint16_t max_interval, uint16_t latency, uint16_t supervision_timeout) const override
 Logs a request to update connection parameters.
 
void OnConnectionParametersUpdateComplete (uint8_t status, c7222::ConnectionHandle con_handle, uint16_t conn_interval, uint16_t conn_latency, uint16_t supervision_timeout) const override
 Logs completion of connection parameter updates.
 
void OnDisconnectionComplete (uint8_t status, c7222::ConnectionHandle con_handle, uint8_t reason) const override
 Logs disconnections and restarts advertising.
 
void OnReadPhy (uint8_t status, c7222::ConnectionHandle con_handle, c7222::Gap::Phy tx_phy, c7222::Gap::Phy rx_phy) const override
 Logs PHY read results.
 
void OnPhyUpdateComplete (uint8_t status, c7222::ConnectionHandle con_handle, c7222::Gap::Phy tx_phy, c7222::Gap::Phy rx_phy) const override
 Logs PHY update completion.
 
void OnDataLengthChange (c7222::ConnectionHandle con_handle, uint16_t tx_size, uint16_t rx_size) const override
 Logs data length changes.
 
void OnPrivacyEnabled () const override
 Logs that privacy mode has been enabled.
 
void OnSecurityLevel (c7222::ConnectionHandle con_handle, uint8_t security_level) const override
 Logs the negotiated security level.
 
void OnDedicatedBondingCompleted (uint8_t status, const c7222::BleAddress &address) const override
 Logs completion of dedicated bonding.
 
void OnInquiryResult (const c7222::Gap::InquiryResult &result) const override
 Logs inquiry results.
 
void OnInquiryComplete (uint8_t status) const override
 Logs completion of inquiry.
 
void OnRssiMeasurement (c7222::ConnectionHandle con_handle, int8_t rssi) const override
 Logs RSSI measurements.
 
void OnLocalOobData (bool oob_data_present, const uint8_t *c_192, const uint8_t *r_192, const uint8_t *c_256, const uint8_t *r_256) const override
 Logs presence of local OOB data.
 
void OnPairingStarted (c7222::ConnectionHandle con_handle, const c7222::BleAddress &address, bool ssp, bool initiator) const override
 Logs the start of pairing.
 
void OnPairingComplete (c7222::ConnectionHandle con_handle, const c7222::BleAddress &address, uint8_t status) const override
 Logs completion of pairing.
 

Additional Inherited Members

- Protected Member Functions inherited from c7222::Gap::EventHandler
 ~EventHandler ()=default
 

Detailed Description

Minimal GAP event handler for example applications.

Tracks and prints GAP events. Used in BLE examples as a lightweight way to observe advertising, scanning, and connection activity.

The stored Gap instance is used to restart advertising on disconnect. The optional AttributeServer instance is used to set the active connection handle when a connection completes, which is required for GATT operations.

Constructor & Destructor Documentation

◆ GapEventHandler()

GapEventHandler::GapEventHandler ( c7222::Gap gap = c7222::Gap::GetInstance(),
c7222::AttributeServer attribute_server = nullptr 
)
explicit

Construct a handler with optional GAP and AttributeServer pointers.

Parameters
gapGAP singleton used for actions like restarting advertising.
attribute_serverOptional attribute server updated on connect.

Member Function Documentation

◆ OnAdvertisingEnd()

void GapEventHandler::OnAdvertisingEnd ( uint8_t  status,
c7222::ConnectionHandle  connection_handle 
) const
overridevirtual

Logs the end of advertising.

Reimplemented from c7222::Gap::EventHandler.

◆ OnAdvertisingReport()

void GapEventHandler::OnAdvertisingReport ( const c7222::Gap::AdvertisingReport report) const
overridevirtual

Logs legacy advertising reports.

Reimplemented from c7222::Gap::EventHandler.

◆ OnAdvertisingStart()

void GapEventHandler::OnAdvertisingStart ( uint8_t  status) const
overridevirtual

Logs the start of advertising.

Reimplemented from c7222::Gap::EventHandler.

◆ OnConnectionComplete()

void GapEventHandler::OnConnectionComplete ( uint8_t  status,
c7222::ConnectionHandle  con_handle,
const c7222::BleAddress address,
uint16_t  conn_interval,
uint16_t  conn_latency,
uint16_t  supervision_timeout 
) const
overridevirtual

Logs new connections and updates the attribute server handle.

Reimplemented from c7222::Gap::EventHandler.

Here is the call graph for this function:

◆ OnConnectionParametersUpdateComplete()

void GapEventHandler::OnConnectionParametersUpdateComplete ( uint8_t  status,
c7222::ConnectionHandle  con_handle,
uint16_t  conn_interval,
uint16_t  conn_latency,
uint16_t  supervision_timeout 
) const
overridevirtual

Logs completion of connection parameter updates.

Reimplemented from c7222::Gap::EventHandler.

◆ OnDataLengthChange()

void GapEventHandler::OnDataLengthChange ( c7222::ConnectionHandle  con_handle,
uint16_t  tx_size,
uint16_t  rx_size 
) const
overridevirtual

Logs data length changes.

Reimplemented from c7222::Gap::EventHandler.

◆ OnDedicatedBondingCompleted()

void GapEventHandler::OnDedicatedBondingCompleted ( uint8_t  status,
const c7222::BleAddress address 
) const
overridevirtual

Logs completion of dedicated bonding.

Reimplemented from c7222::Gap::EventHandler.

◆ OnDisconnectionComplete()

void GapEventHandler::OnDisconnectionComplete ( uint8_t  status,
c7222::ConnectionHandle  con_handle,
uint8_t  reason 
) const
overridevirtual

Logs disconnections and restarts advertising.

Reimplemented from c7222::Gap::EventHandler.

Here is the call graph for this function:

◆ OnExtendedAdvertisingReport()

void GapEventHandler::OnExtendedAdvertisingReport ( const c7222::Gap::ExtendedAdvertisingReport report) const
overridevirtual

Logs extended advertising reports.

Reimplemented from c7222::Gap::EventHandler.

◆ OnInquiryComplete()

void GapEventHandler::OnInquiryComplete ( uint8_t  status) const
overridevirtual

Logs completion of inquiry.

Reimplemented from c7222::Gap::EventHandler.

◆ OnInquiryResult()

void GapEventHandler::OnInquiryResult ( const c7222::Gap::InquiryResult result) const
overridevirtual

Logs inquiry results.

Reimplemented from c7222::Gap::EventHandler.

◆ OnLocalOobData()

void GapEventHandler::OnLocalOobData ( bool  oob_data_present,
const uint8_t *  c_192,
const uint8_t *  r_192,
const uint8_t *  c_256,
const uint8_t *  r_256 
) const
overridevirtual

Logs presence of local OOB data.

Reimplemented from c7222::Gap::EventHandler.

◆ OnPairingComplete()

void GapEventHandler::OnPairingComplete ( c7222::ConnectionHandle  con_handle,
const c7222::BleAddress address,
uint8_t  status 
) const
overridevirtual

Logs completion of pairing.

Reimplemented from c7222::Gap::EventHandler.

◆ OnPairingStarted()

void GapEventHandler::OnPairingStarted ( c7222::ConnectionHandle  con_handle,
const c7222::BleAddress address,
bool  ssp,
bool  initiator 
) const
overridevirtual

Logs the start of pairing.

Reimplemented from c7222::Gap::EventHandler.

◆ OnPeriodicAdvertisingReport()

void GapEventHandler::OnPeriodicAdvertisingReport ( c7222::ConnectionHandle  sync_handle,
int8_t  tx_power,
int8_t  rssi,
uint8_t  data_status,
const uint8_t *  data,
uint8_t  data_length 
) const
overridevirtual

Logs a periodic advertising report.

Reimplemented from c7222::Gap::EventHandler.

◆ OnPeriodicAdvertisingSyncEstablished()

void GapEventHandler::OnPeriodicAdvertisingSyncEstablished ( uint8_t  status,
c7222::ConnectionHandle  sync_handle 
) const
overridevirtual

Logs periodic advertising sync establishment.

Reimplemented from c7222::Gap::EventHandler.

◆ OnPeriodicAdvertisingSyncLoss()

void GapEventHandler::OnPeriodicAdvertisingSyncLoss ( c7222::ConnectionHandle  sync_handle) const
overridevirtual

Logs loss of periodic advertising sync.

Reimplemented from c7222::Gap::EventHandler.

◆ OnPhyUpdateComplete()

void GapEventHandler::OnPhyUpdateComplete ( uint8_t  status,
c7222::ConnectionHandle  con_handle,
c7222::Gap::Phy  tx_phy,
c7222::Gap::Phy  rx_phy 
) const
overridevirtual

Logs PHY update completion.

Reimplemented from c7222::Gap::EventHandler.

◆ OnPrivacyEnabled()

void GapEventHandler::OnPrivacyEnabled ( ) const
overridevirtual

Logs that privacy mode has been enabled.

Reimplemented from c7222::Gap::EventHandler.

◆ OnReadPhy()

void GapEventHandler::OnReadPhy ( uint8_t  status,
c7222::ConnectionHandle  con_handle,
c7222::Gap::Phy  tx_phy,
c7222::Gap::Phy  rx_phy 
) const
overridevirtual

Logs PHY read results.

Reimplemented from c7222::Gap::EventHandler.

◆ OnRssiMeasurement()

void GapEventHandler::OnRssiMeasurement ( c7222::ConnectionHandle  con_handle,
int8_t  rssi 
) const
overridevirtual

Logs RSSI measurements.

Reimplemented from c7222::Gap::EventHandler.

◆ OnScanRequestReceived()

void GapEventHandler::OnScanRequestReceived ( uint8_t  advertising_handle,
const c7222::BleAddress scanner_address 
) const
overridevirtual

Logs scan requests received by the advertiser.

Reimplemented from c7222::Gap::EventHandler.

◆ OnScanTimeout()

void GapEventHandler::OnScanTimeout ( uint8_t  status) const
overridevirtual

Logs a scan timeout event.

Reimplemented from c7222::Gap::EventHandler.

◆ OnSecurityLevel()

void GapEventHandler::OnSecurityLevel ( c7222::ConnectionHandle  con_handle,
uint8_t  security_level 
) const
overridevirtual

Logs the negotiated security level.

Reimplemented from c7222::Gap::EventHandler.

◆ OnUpdateConnectionParametersRequest()

void GapEventHandler::OnUpdateConnectionParametersRequest ( c7222::ConnectionHandle  con_handle,
uint16_t  min_interval,
uint16_t  max_interval,
uint16_t  latency,
uint16_t  supervision_timeout 
) const
overridevirtual

Logs a request to update connection parameters.

Reimplemented from c7222::Gap::EventHandler.

◆ SetAttributeServer()

void GapEventHandler::SetAttributeServer ( c7222::AttributeServer attribute_server)

Attach an attribute server after construction.

When a connection is established, the handler will call AttributeServer::SetConnectionHandle() with the active handle.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: