ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
c7222::Gap Class Reference

Manages Generic Access Profile (GAP) functionality for BLE. More...

#include <gap.hpp>

Inheritance diagram for c7222::Gap:
Inheritance graph
Collaboration diagram for c7222::Gap:
Collaboration graph

Classes

struct  AdvertisementParameters
 
struct  AdvertisingReport
 
struct  ConnectionParameters
 
struct  EventHandler
 
struct  ExtendedAdvertisingReport
 
struct  InquiryResult
 
struct  PreferredConnectionParameters
 

Public Types

enum class  EventId : uint8_t {
  kSecurityLevel , kDedicatedBondingCompleted , kAdvertisingReport , kExtendedAdvertisingReport ,
  kInquiryResult , kInquiryComplete , kRssiMeasurement , kLocalOobData ,
  kPairingStarted , kPairingComplete , kDisconnectionComplete , kCommandComplete ,
  kLeScanRequestReceived , kLeScanTimeout , kLePeriodicAdvertisingSyncEstablished , kLePeriodicAdvertisingReport ,
  kLePeriodicAdvertisingSyncLost , kLeConnectionComplete , kLeEnhancedConnectionComplete , kLeRemoteConnectionParameterRequest ,
  kLeConnectionUpdateComplete , kLePhyUpdateComplete , kLeDataLengthChange , kLeAdvertisingSetTerminated ,
  kL2capConnectionParameterUpdateRequest , kPrivacyEnabled
}
 Event IDs used by Gap::EventHandler. More...
 
enum class  AdvertisingEventType : uint16_t {
  kConnectable = 0x0001 , kScannable = 0x0002 , kDirected = 0x0004 , kHighDutyCycle = 0x0008 ,
  kLegacy = 0x0010 , kAnonymous = 0x0020 , kIncludeTxPower = 0x0040
}
 Extended advertising event properties (bitfield). More...
 
enum class  Phy : uint8_t { kNone = 0x00 , kLe1M = 0x01 , kLe2M = 0x02 , kLeCoded = 0x03 }
 LE PHY values reported in extended advertising reports. More...
 
enum class  AdvertisingType : uint8_t { kAdvInd = 0x00 , kAdvDirectInd = 0x01 , kAdvScanInd = 0x02 , kAdvNonConnInd = 0x03 }
 Legacy advertising types for LE advertising parameters. More...
 
enum class  DirectAddressType : uint8_t { kPublic = 0x00 , kRandom = 0x01 }
 Direct address type for directed advertising. More...
 
enum class  AdvertisingChannelMap : uint8_t { kChannel37 = 0x01 , kChannel38 = 0x02 , kChannel39 = 0x04 , kAll = 0x07 }
 Advertising channel map bitfield. More...
 
enum class  AdvertisingFilterPolicy : uint8_t { kScanAnyConnectAny = 0x00 , kScanWhitelistConnectAny = 0x01 , kScanAnyConnectWhitelist = 0x02 , kScanWhitelistConnectWhitelist = 0x03 }
 Advertising filter policy. More...
 

Public Member Functions

void SetRandomAddress (const BleAddress &address)
 Set a fixed random address for advertising.
 
void SetAdvertisingParameters (const AdvertisementParameters &params)
 Configure legacy advertising parameters.
 
void SetAdvertisingData (const uint8_t *data, size_t size)
 Set legacy advertising data payload.
 
void SetAdvertisingData (const std::vector< uint8_t > &data)
 Set legacy advertising data payload from a vector.
 
void SetAdvertisingData (const AdvertisementDataBuilder &data_builder)
 Set legacy advertising data payload from an AdvertisementDataBuilder.
 
void SetAdvertisingData ()
 Set legacy advertising data payload from the internal builder.
 
void SetScanResponseData (uint8_t length, const uint8_t *data)
 Set scan response data payload (ADV_SCAN_IND).
 
void EnableAdvertising (bool enabled)
 Enable or disable advertising.
 
void StartAdvertising ()
 Convenience helpers for starting/stopping advertising.
 
void StopAdvertising ()
 
BleError RequestConnectionParameterUpdate (ConnectionHandle con_handle, const PreferredConnectionParameters &params)
 Request a connection parameter update (peripheral role).
 
BleError UpdateConnectionParameters (ConnectionHandle con_handle, const PreferredConnectionParameters &params)
 Update connection parameters (central role).
 
BleError ReadRssi (ConnectionHandle con_handle)
 Read the RSSI for a connection.
 
BleError Disconnect (ConnectionHandle con_handle)
 Disconnect a connection by handle.
 
void SetLocalAddress (BleAddress &address)
 Read the local device address.
 
void AddEventHandler (const EventHandler &handler)
 Register an event handler.
 
bool RemoveEventHandler (const EventHandler &handler)
 Unregister an event handler.
 
void ClearEventHandlers ()
 Clear all registered event handlers.
 
std::list< const EventHandler * > GetEventHandlers () const
 Get the list of registered event handlers.
 
bool GetConnectionParameters (ConnectionHandle con_handle, ConnectionParameters &out) const
 Get cached connection parameters for a handle.
 
bool IsAdvertisingEnabled () const
 Check if advertising is currently enabled.
 
bool IsAdvertising () const
 Check if advertising is currently running on the controller.
 
bool IsAdvertisingParametersSet () const
 Check if advertising parameters have been set.
 
bool IsConnected () const
 Check if a connection is active.
 
bool GetRandomAddress (BleAddress &address) const
 Get the random address if set.
 
bool IsRandomAddressSet () const
 Check if a random address has been set.
 
bool GetAdvertisingParameters (AdvertisementParameters &params) const
 Get the current advertising parameters.
 
const std::vector< uint8_t > & GetAdvertisingData () const
 Get the advertising data payload.
 
AdvertisementDataBuilderGetAdvertisementDataBuilder ()
 Access the internal advertisement data builder.
 
const AdvertisementDataBuilderGetAdvertisementDataBuilder () const
 Access the internal advertisement data builder (const).
 
bool IsAdvertisingDataSet () const
 Check if advertising data has been set.
 
const std::vector< uint8_t > & scan_response_data () const
 Get the scan response data payload.
 
bool IsScanResponseDataSet () const
 Check if scan response data has been set.
 
const std::map< ConnectionHandle, ConnectionParameters > & GetConnectionParameters () const
 Access the cached connection parameter map.
 
virtual BleError DispatchBleHciPacket (uint8_t packet_type, const uint8_t *packet_data, uint16_t packet_data_size)
 Dispatch a raw HCI packet into the GAP event pipeline.
 
- Public Member Functions inherited from c7222::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=default
 
NonCopyableoperator= (NonCopyable &&)=default
 
- Public Member Functions inherited from c7222::NonMovable
 NonMovable (const NonMovable &)=default
 
NonMovableoperator= (const NonMovable &)=default
 
 NonMovable (NonMovable &&)=delete
 
NonMovableoperator= (NonMovable &&)=delete
 

Static Public Member Functions

static GapGetInstance ()
 Get the singleton instance.
 

Protected Member Functions

virtual BleError DispatchEvent (EventId event_id, const uint8_t *event_data, uint16_t event_data_size)
 Dispatch a mapped GAP event to registered handlers.
 
- Protected Member Functions inherited from c7222::NonCopyableNonMovable
 NonCopyableNonMovable ()=default
 
 ~NonCopyableNonMovable ()=default
 
- Protected Member Functions inherited from c7222::NonCopyable
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 
- Protected Member Functions inherited from c7222::NonMovable
 NonMovable ()=default
 
 ~NonMovable ()=default
 

Detailed Description

Manages Generic Access Profile (GAP) functionality for BLE.

This class provides a high-level, object-oriented interface for managing the BLE GAP layer, acting as a C++ wrapper around the underlying C-based BTstack API. It simplifies common GAP operations such as advertising and connection management by maintaining state and handling HCI event dispatching. Scanning is currently exposed only via events, not via public start/stop APIs.

The Gap class is implemented as a singleton, accessible via GetInstance(), ensuring a single point of control for the device's GAP layer.


Design Logic

The class abstracts away the low-level details of the BTstack. It works by:

  1. Configuration Caching: Storing advertising parameters, data, and other settings within the class.
  2. State Management: Tracking the advertising state (IsAdvertisingEnabled()) and connection status (IsConnected()).
  3. Event-Driven Callbacks: Using the EventHandler interface, which users can implement to react to BLE events (e.g., connection, disconnection, advertising reports) in a clean, C++ idiomatic way.
  4. HCI Event Dispatching: The DispatchBleHciPacket method is the entry point for raw HCI events from the BTstack, which are then parsed and forwarded to the appropriate EventHandler methods. Your application must call this for events to reach the handlers.

Advertising Configuration (Legacy)

To start advertising, you must configure three main components:

  1. Advertising Parameters: Define the "how" of advertising.
    • Type: Connectable, scannable, non-connectable, etc.
    • Interval: The frequency of advertising packets.
    • Channels: Which BLE channels to advertise on. This is configured using SetAdvertisingParameters().
  2. Advertising Data: The main payload (up to 31 bytes) that is broadcast to all listening devices. This typically includes flags and the device name. This is configured using SetAdvertisingData().
  3. Scan Response Data (Optional): An additional 31-byte payload that a central device can request after seeing the initial advertisement. This is often used for supplementary information that doesn't fit in the main payload. This is configured using SetScanResponseData().

Applying Configurations and Utilities

  • **SetAdvertisingParameters(const AdvertisementParameters& params):** Takes a struct that defines the advertising behavior. A default-constructed AdvertisementParameters provides standard connectable, undirected advertising settings.
  • **SetAdvertisingData(...) / SetScanResponseData(...):** These methods accept a raw pointer and length. For convenience, SetAdvertisingData is overloaded to accept a std::vector<uint8_t> or an AdvertisementDataBuilder instance, which is the recommended utility for safely constructing valid advertising payloads.
  • **StartAdvertising() / StopAdvertising():** Simple methods to enable or disable advertising.

Dynamic Data Updates

You can update advertising or scan response data at any time, even while advertising is active. The SetAdvertisingData and SetScanResponseData methods will automatically handle the underlying requirements of the RPi Pico BLE stack: they temporarily stop advertising, apply the new data, and restart advertising if it was previously enabled. This ensures a seamless update without manual intervention.


Limitations / Future Work

  • Extended advertising: not implemented in this wrapper yet. The API only supports legacy advertising (31-byte payloads, ADV_* types).
  • Scanning control: scan start/stop configuration is not exposed yet. Only scan-related events are surfaced via EventHandler.

Complete Code Example (Peripheral / Advertising)

Below is a complete example of setting up and starting a connectable BLE advertisement with a device name. It also shows a minimal event dispatch hook that forwards BTstack HCI events into the Gap instance.

#include "gap.hpp"
#include <iostream>
// --- 1. Implement an event handler ---
class MyGapEventHandler : public c7222::Gap::EventHandler {
public:
void OnAdvertisingStart(uint8_t status) const override {
if (status == 0) {
std::cout << "Advertising started successfully." << std::endl;
} else {
std::cout << "Failed to start advertising, status: " << (int)status << std::endl;
}
}
void OnConnectionComplete(uint8_t status, c7222::ConnectionHandle handle,
const c7222::BleAddress& address,
uint16_t, uint16_t, uint16_t) const override {
if (status == 0) {
std::cout << "Device connected: " << address << std::endl;
}
}
void OnDisconnectionComplete(uint8_t status, c7222::ConnectionHandle handle,
uint8_t reason) const override {
std::cout << "Device disconnected, reason: " << (int)reason << std::endl;
// After disconnection, we can restart advertising.
std::cout << "Advertising restarted." << std::endl;
}
};
// --- Main application logic ---
void setup_ble_advertising() {
// Get the singleton instance of the Gap class.
auto& gap = c7222::Gap::GetInstance();
// --- 2. Register the event handler ---
// Note: The handler instance must exist for the lifetime of the application.
static MyGapEventHandler my_handler;
gap.AddEventHandler(my_handler);
// --- 3. Configure advertising parameters ---
// We can use the default parameters for standard connectable advertising.
// Set a custom interval: 200ms to 250ms
// Interval is in units of 0.625 ms, so 320 * 0.625 = 200ms, 400 * 0.625 = 250ms
params.min_interval = 320;
params.max_interval = 400;
gap.SetAdvertisingParameters(params);
// --- 4. Build and set advertising data ---
gap.SetAdvertisingData(ad_builder);
// --- 5. Start advertising ---
gap.StartAdvertising();
}
// Forward BTstack HCI events to Gap. Call this from your BTstack callback.
void on_btstack_event(uint8_t packet_type, const uint8_t* packet, uint16_t size) {
c7222::Gap::GetInstance().DispatchBleHciPacket(packet_type, packet, size);
}
// In your main function, call setup_ble_advertising() and then
// process BLE events in your main loop (e.g., ble_stack_process()).
BLE GAP advertisement data builder.
Builder for assembling a complete advertising payload.
Definition advertisement_data.hpp:304
BLE address container with an associated address type.
Definition ble_address.hpp:43
void StartAdvertising()
Convenience helpers for starting/stopping advertising.
virtual BleError DispatchBleHciPacket(uint8_t packet_type, const uint8_t *packet_data, uint16_t packet_data_size)
Dispatch a raw HCI packet into the GAP event pipeline.
static Gap * GetInstance()
Get the singleton instance.
Provides a C++ wrapper for the BTstack Generic Access Profile (GAP).
uint16_t ConnectionHandle
Definition gap.hpp:23
uint16_t min_interval
Minimum advertising interval (unit: 0.625 ms).
Definition gap.hpp:969
uint16_t max_interval
Maximum advertising interval (unit: 0.625 ms).
Definition gap.hpp:973
Definition gap.hpp:617

Minimal Event-Only Example (e.g., central role)

If another component configures scanning or connections, you can still use Gap for event handling by registering a handler and dispatching HCI events.

#include "gap.hpp"
class MyGapEventHandler : public c7222::Gap::EventHandler {
public:
void OnConnectionComplete(uint8_t status, c7222::ConnectionHandle handle,
const c7222::BleAddress&, uint16_t, uint16_t, uint16_t) const
override { if (status == 0) { (void)handle;
}
}
};
void init_gap_events() {
static MyGapEventHandler handler;
}
void AddEventHandler(const EventHandler &handler)
Register an event handler.

Member Enumeration Documentation

◆ AdvertisingChannelMap

enum class c7222::Gap::AdvertisingChannelMap : uint8_t
strong

Advertising channel map bitfield.

Enumerator
kChannel37 

Channel 37 enabled.

kChannel38 

Channel 38 enabled.

kChannel39 

Channel 39 enabled.

kAll 

All advertising channels enabled (37, 38, 39).

◆ AdvertisingEventType

enum class c7222::Gap::AdvertisingEventType : uint16_t
strong

Extended advertising event properties (bitfield).

Enumerator
kConnectable 

Advertising is connectable.

kScannable 

Advertising is scannable.

kDirected 

Advertising is directed to a specific peer.

kHighDutyCycle 

High duty cycle directed advertising.

kLegacy 

Legacy advertising PDUs.

kAnonymous 

Advertiser address is omitted from the report.

kIncludeTxPower 

Include the TX power in the report.

◆ AdvertisingFilterPolicy

enum class c7222::Gap::AdvertisingFilterPolicy : uint8_t
strong

Advertising filter policy.

Enumerator
kScanAnyConnectAny 

Allow any scan and any connect request.

kScanWhitelistConnectAny 

Allow scan from whitelist, connect from any.

kScanAnyConnectWhitelist 

Allow scan from any, connect from whitelist.

kScanWhitelistConnectWhitelist 

Allow scan and connect from whitelist only.

◆ AdvertisingType

enum class c7222::Gap::AdvertisingType : uint8_t
strong

Legacy advertising types for LE advertising parameters.

Enumerator
kAdvInd 

Connectable undirected advertising (ADV_IND).

kAdvDirectInd 

Connectable directed advertising (ADV_DIRECT_IND).

kAdvScanInd 

Scannable undirected advertising (ADV_SCAN_IND).

kAdvNonConnInd 

Non-connectable undirected advertising (ADV_NONCONN_IND).

◆ DirectAddressType

enum class c7222::Gap::DirectAddressType : uint8_t
strong

Direct address type for directed advertising.

Enumerator
kPublic 

Public device address.

kRandom 

Random device address.

◆ EventId

enum class c7222::Gap::EventId : uint8_t
strong

Event IDs used by Gap::EventHandler.

Enumerator
kSecurityLevel 

Security level update for an active connection. BTstack event: GAP_EVENT_SECURITY_LEVEL.

kDedicatedBondingCompleted 

Dedicated bonding procedure finished with status and peer address. BTstack event: GAP_EVENT_DEDICATED_BONDING_COMPLETED.

kAdvertisingReport 

Legacy advertising report while scanning. BTstack event: GAP_EVENT_ADVERTISING_REPORT.

kExtendedAdvertisingReport 

Extended advertising report while scanning. BTstack event: GAP_EVENT_EXTENDED_ADVERTISING_REPORT.

kInquiryResult 

Classic inquiry result payload received. BTstack event: GAP_EVENT_INQUIRY_RESULT.

kInquiryComplete 

Inquiry procedure completed. BTstack event: GAP_EVENT_INQUIRY_COMPLETE.

kRssiMeasurement 

RSSI measurement result for a connection. BTstack event: GAP_EVENT_RSSI_MEASUREMENT.

kLocalOobData 

Local out-of-band data generated or available. BTstack event: GAP_EVENT_LOCAL_OOB_DATA.

kPairingStarted 

Pairing procedure has started. BTstack event: GAP_EVENT_PAIRING_STARTED.

kPairingComplete 

Pairing procedure has completed with status. BTstack event: GAP_EVENT_PAIRING_COMPLETE.

kDisconnectionComplete 

A connection was terminated with a reason code. BTstack event: HCI_EVENT_DISCONNECTION_COMPLETE.

kCommandComplete 

Generic HCI command completion event (check opcode for details). BTstack event: HCI_EVENT_COMMAND_COMPLETE.

kLeScanRequestReceived 

Scan request received by an advertiser. BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_SCAN_REQUEST_RECEIVED.

kLeScanTimeout 

LE scan procedure timed out. BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_SCAN_TIMEOUT.

kLePeriodicAdvertisingSyncEstablished 

Periodic advertising sync established. BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_PERIODIC_ADVERTISING_SYNC_ESTABLISHMENT.

kLePeriodicAdvertisingReport 

Periodic advertising report received. BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_PERIODIC_ADVERTISING_REPORT.

kLePeriodicAdvertisingSyncLost 

Periodic advertising sync lost. BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_PERIODIC_ADVERTISING_SYNC_LOST.

kLeConnectionComplete 

LE connection complete (legacy subevent). BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_CONNECTION_COMPLETE.

kLeEnhancedConnectionComplete 

LE enhanced connection complete (addresses included). BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_ENHANCED_CONNECTION_COMPLETE.

kLeRemoteConnectionParameterRequest 

Remote device requests connection parameter updates. BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_REMOTE_CONNECTION_PARAMETER_REQUEST.

kLeConnectionUpdateComplete 

Connection parameters update completed. BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE.

kLePhyUpdateComplete 

LE PHY update procedure completed. BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_PHY_UPDATE_COMPLETE.

kLeDataLengthChange 

LE data length update reported for a connection. BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_DATA_LENGTH_CHANGE.

kLeAdvertisingSetTerminated 

Extended advertising set terminated (timeout or connection). BTstack event: HCI_EVENT_LE_META + HCI_SUBEVENT_LE_ADVERTISING_SET_TERMINATED.

kL2capConnectionParameterUpdateRequest 

L2CAP connection parameter update request event. BTstack event: L2CAP_EVENT_CONNECTION_PARAMETER_UPDATE_REQUEST.

kPrivacyEnabled 

Privacy enabled and ready; raised after successful configuration. BTstack: no dedicated event.

◆ Phy

enum class c7222::Gap::Phy : uint8_t
strong

LE PHY values reported in extended advertising reports.

Enumerator
kNone 

No PHY specified / not available.

kLe1M 

LE 1M PHY.

kLe2M 

LE 2M PHY.

kLeCoded 

LE Coded PHY.

Member Function Documentation

◆ AddEventHandler()

void c7222::Gap::AddEventHandler ( const EventHandler handler)

Register an event handler.

The handler is stored as a pointer; it must outlive the Gap instance.

Here is the caller graph for this function:

◆ ClearEventHandlers()

void c7222::Gap::ClearEventHandlers ( )

Clear all registered event handlers.

Note
The handler instances are not deleted by this method. Therefore, the caller must delete the objects if they were dynamically allocated.
Here is the caller graph for this function:

◆ Disconnect()

BleError c7222::Gap::Disconnect ( ConnectionHandle  con_handle)

Disconnect a connection by handle.

Here is the caller graph for this function:

◆ DispatchBleHciPacket()

virtual BleError c7222::Gap::DispatchBleHciPacket ( uint8_t  packet_type,
const uint8_t *  packet_data,
uint16_t  packet_data_size 
)
virtual

Dispatch a raw HCI packet into the GAP event pipeline.

Parameters
packet_typeHCI packet type (expected HCI_EVENT_PACKET).
packet_dataPointer to packet bytes.
packet_data_sizePacket length in bytes.
Returns
BLE error status.

◆ DispatchEvent()

virtual BleError c7222::Gap::DispatchEvent ( EventId  event_id,
const uint8_t *  event_data,
uint16_t  event_data_size 
)
protectedvirtual

Dispatch a mapped GAP event to registered handlers.

Parameters
event_idMapped GAP event ID.
event_dataPointer to event data bytes.
event_data_sizeEvent length in bytes.
Returns
BLE error status.

◆ EnableAdvertising()

void c7222::Gap::EnableAdvertising ( bool  enabled)

Enable or disable advertising.

Here is the caller graph for this function:

◆ GetAdvertisementDataBuilder() [1/2]

AdvertisementDataBuilder & c7222::Gap::GetAdvertisementDataBuilder ( )
inline

Access the internal advertisement data builder.

Use this to assemble the legacy advertising payload before applying it with SetAdvertisingData().

Here is the caller graph for this function:

◆ GetAdvertisementDataBuilder() [2/2]

const AdvertisementDataBuilder & c7222::Gap::GetAdvertisementDataBuilder ( ) const
inline

Access the internal advertisement data builder (const).

◆ GetAdvertisingData()

const std::vector< uint8_t > & c7222::Gap::GetAdvertisingData ( ) const
inline

Get the advertising data payload.

Returns
Pointer to advertising data, or nullptr if not set.
Here is the call graph for this function:

◆ GetAdvertisingParameters()

bool c7222::Gap::GetAdvertisingParameters ( AdvertisementParameters params) const

Get the current advertising parameters.

Parameters
paramsOutput parameters.
Returns
true if advertising parameters have been set.

◆ GetConnectionParameters() [1/2]

const std::map< ConnectionHandle, ConnectionParameters > & c7222::Gap::GetConnectionParameters ( ) const
inline

Access the cached connection parameter map.

The map is populated from connection-related events.

◆ GetConnectionParameters() [2/2]

bool c7222::Gap::GetConnectionParameters ( ConnectionHandle  con_handle,
ConnectionParameters out 
) const

Get cached connection parameters for a handle.

Parameters
con_handleConnection handle.
outParameters output.
Returns
true if parameters are known for the handle.

◆ GetEventHandlers()

std::list< const EventHandler * > c7222::Gap::GetEventHandlers ( ) const
inline

Get the list of registered event handlers.

◆ GetInstance()

static Gap * c7222::Gap::GetInstance ( )
static

Get the singleton instance.

◆ GetRandomAddress()

bool c7222::Gap::GetRandomAddress ( BleAddress address) const

Get the random address if set.

Parameters
addressOutput address.
Returns
true if a random address has been set.

◆ IsAdvertising()

bool c7222::Gap::IsAdvertising ( ) const
inline

Check if advertising is currently running on the controller.

This follows stack events and is set true after a successful OnAdvertisingStart callback, and set false before an OnAdvertisingEnd callback.

◆ IsAdvertisingDataSet()

bool c7222::Gap::IsAdvertisingDataSet ( ) const
inline

Check if advertising data has been set.

◆ IsAdvertisingEnabled()

bool c7222::Gap::IsAdvertisingEnabled ( ) const
inline

Check if advertising is currently enabled.

Here is the caller graph for this function:

◆ IsAdvertisingParametersSet()

bool c7222::Gap::IsAdvertisingParametersSet ( ) const
inline

Check if advertising parameters have been set.

◆ IsConnected()

bool c7222::Gap::IsConnected ( ) const
inline

Check if a connection is active.

Here is the caller graph for this function:

◆ IsRandomAddressSet()

bool c7222::Gap::IsRandomAddressSet ( ) const
inline

Check if a random address has been set.

◆ IsScanResponseDataSet()

bool c7222::Gap::IsScanResponseDataSet ( ) const
inline

Check if scan response data has been set.

◆ ReadRssi()

BleError c7222::Gap::ReadRssi ( ConnectionHandle  con_handle)

Read the RSSI for a connection.

Here is the caller graph for this function:

◆ RemoveEventHandler()

bool c7222::Gap::RemoveEventHandler ( const EventHandler handler)

Unregister an event handler.

Returns
true if the handler was found and removed.
Note
Handlers are compared by pointer address. If multiple identical handlers were added, only the first is removed.
Removing a handler that was not registered has no effect.
Do not remove handlers while iterating through the handler list (e.g. during event dispatch). It is NOT safe to remove handlers from within event callbacks.
The handler instance is not deleted by this method. Therefore, the caller must delete the object if it was dynamically allocated.
Here is the caller graph for this function:

◆ RequestConnectionParameterUpdate()

BleError c7222::Gap::RequestConnectionParameterUpdate ( ConnectionHandle  con_handle,
const PreferredConnectionParameters params 
)

Request a connection parameter update (peripheral role).

Here is the caller graph for this function:

◆ scan_response_data()

const std::vector< uint8_t > & c7222::Gap::scan_response_data ( ) const
inline

Get the scan response data payload.

Returns
Pointer to scan response data, or nullptr if not set.

◆ SetAdvertisingData() [1/4]

void c7222::Gap::SetAdvertisingData ( )
inline

Set legacy advertising data payload from the internal builder.

Asserts that the builder contains at least one AD structure and validates.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetAdvertisingData() [2/4]

void c7222::Gap::SetAdvertisingData ( const AdvertisementDataBuilder data_builder)

Set legacy advertising data payload from an AdvertisementDataBuilder.

Parameters
data_builderAdvertisementDataBuilder instance containing the payload.
Note
The data from the builder is copied.

◆ SetAdvertisingData() [3/4]

void c7222::Gap::SetAdvertisingData ( const std::vector< uint8_t > &  data)
inline

Set legacy advertising data payload from a vector.

Parameters
dataAdvertising data payload.
Here is the call graph for this function:

◆ SetAdvertisingData() [4/4]

void c7222::Gap::SetAdvertisingData ( const uint8_t *  data,
size_t  size 
)

Set legacy advertising data payload.

The payload is copied into the internal advertisement data builder and then applied to BTstack immediately.

Here is the caller graph for this function:

◆ SetAdvertisingParameters()

void c7222::Gap::SetAdvertisingParameters ( const AdvertisementParameters params)

Configure legacy advertising parameters.

Here is the caller graph for this function:

◆ SetLocalAddress()

void c7222::Gap::SetLocalAddress ( BleAddress address)

Read the local device address.

◆ SetRandomAddress()

void c7222::Gap::SetRandomAddress ( const BleAddress address)

Set a fixed random address for advertising.

Here is the caller graph for this function:

◆ SetScanResponseData()

void c7222::Gap::SetScanResponseData ( uint8_t  length,
const uint8_t *  data 
)

Set scan response data payload (ADV_SCAN_IND).

Here is the caller graph for this function:

◆ StartAdvertising()

void c7222::Gap::StartAdvertising ( )

Convenience helpers for starting/stopping advertising.

Here is the caller graph for this function:

◆ StopAdvertising()

void c7222::Gap::StopAdvertising ( )
Here is the caller graph for this function:

◆ UpdateConnectionParameters()

BleError c7222::Gap::UpdateConnectionParameters ( ConnectionHandle  con_handle,
const PreferredConnectionParameters params 
)

Update connection parameters (central role).

Here is the caller graph for this function:

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