22#include "ble/common/CallChainOfFunctionPointersWithContext.h"
24#include "ble/common/BLERoles.h"
25#include "ble/common/BLETypes.h"
26#include "ble/gap/AdvertisingDataBuilder.h"
27#include "ble/gap/AdvertisingDataParser.h"
28#include "ble/gap/AdvertisingDataSimpleBuilder.h"
29#include "ble/gap/AdvertisingDataTypes.h"
30#include "ble/gap/AdvertisingParameters.h"
31#include "ble/gap/ConnectionParameters.h"
32#include "ble/gap/ScanParameters.h"
33#include "ble/gap/Events.h"
34#include "ble/gap/Types.h"
38#if !defined(DOXYGEN_ONLY)
643#if BLE_ROLE_BROADCASTER
672#if BLE_FEATURE_EXTENDED_ADVERTISING
686 advertising_handle_t *handle,
710 advertising_handle_t handle,
728 advertising_handle_t handle,
747 advertising_handle_t handle,
767 advertising_handle_t handle,
768 adv_duration_t maxDuration = adv_duration_t::forever(),
769 uint8_t maxEvents = 0
790#if BLE_ROLE_BROADCASTER
791#if BLE_FEATURE_PERIODIC_ADVERTISING
803 advertising_handle_t handle,
804 periodic_interval_t periodicAdvertisingIntervalMin,
805 periodic_interval_t periodicAdvertisingIntervalMax,
806 bool advertiseTxPower =
true
825 advertising_handle_t handle,
885 scan_duration_t duration = scan_duration_t::forever(),
886 duplicates_filter_t filtering = duplicates_filter_t::DISABLE,
887 scan_period_t period = scan_period_t(0)
901#if BLE_FEATURE_PERIODIC_ADVERTISING
927 slave_latency_t maxPacketSkip,
928 sync_timeout_t timeout
950 slave_latency_t maxPacketSkip,
951 sync_timeout_t timeout
977 advertising_sid_t sid
990 advertising_sid_t sid
1042#if BLE_FEATURE_CONNECTABLE
1071 conn_interval_t minConnectionInterval,
1072 conn_interval_t maxConnectionInterval,
1073 slave_latency_t slaveLatency,
1074 supervision_timeout_t supervision_timeout,
1075 conn_event_length_t minConnectionEventLength = conn_event_length_t(0),
1076 conn_event_length_t maxConnectionEventLength = conn_event_length_t(0)
1100 ble_error_t manageConnectionParametersUpdateRequest(
1101 bool userManageConnectionUpdateRequest
1135 conn_interval_t minConnectionInterval,
1136 conn_interval_t maxConnectionInterval,
1137 slave_latency_t slaveLatency,
1138 supervision_timeout_t supervision_timeout,
1139 conn_event_length_t minConnectionEventLength = conn_event_length_t(0),
1140 conn_event_length_t maxConnectionEventLength = conn_event_length_t(0)
1181 local_disconnection_reason_t reason
1184#if BLE_FEATURE_PHY_MANAGEMENT
1255#if BLE_FEATURE_PRIVACY
1301#if BLE_ROLE_BROADCASTER
1310 const peripheral_privacy_configuration_t *configuration
1322 peripheral_privacy_configuration_t *configuration
1326#if BLE_ROLE_OBSERVER
1335 const central_privacy_configuration_t *configuration
1347 central_privacy_configuration_t *configuration
1352#if BLE_FEATURE_WHITELIST
1405 own_address_type_t &typeP,
1464 template<
typename T>
1480#if !defined(DOXYGEN_ONLY)
1484 Gap(impl::Gap* impl) : impl(impl) {}
1489 Gap(
const Gap&) =
delete;
1490 Gap& operator=(
const Gap&) =
delete;
Function like object hosting a list of FunctionPointerWithContext.
Function like object adapter over freestanding and member functions.
Parameters defining the advertising process.
Parameters defining the connection initiation process.
Define device discovery, connection and link management procedures.
ble_error_t getPeripheralPrivacyConfiguration(peripheral_privacy_configuration_t *configuration)
Get the privacy configuration used by the peripheral role.
bool isPeriodicAdvertisingActive(advertising_handle_t handle)
Check if periodic advertising is active for a given advertising set.
void onShutdown(const GapShutdownCallback_t &callback)
Register a Gap shutdown event handler.
ble_error_t removeDeviceFromPeriodicAdvertiserList(peer_address_type_t peerAddressType, const address_t &peerAddress, advertising_sid_t sid)
Remove device from the periodic advertiser list.
ble_error_t getAddress(own_address_type_t &typeP, address_t &address)
Fetch the current address and its type.
ble_error_t connect(peer_address_type_t peerAddressType, const address_t &peerAddress, const ConnectionParameters &connectionParams)
Initiate a connection to a peer.
ble_error_t createAdvertisingSet(advertising_handle_t *handle, const AdvertisingParameters ¶meters)
Create an advertising set and apply the passed in parameters.
ble_error_t setPeripheralPrivacyConfiguration(const peripheral_privacy_configuration_t *configuration)
Set the privacy configuration used by the peripheral role.
ble_error_t terminateSync(periodic_sync_handle_t handle)
Stop reception of the periodic advertising identified by the handle.
ble_error_t setPreferredPhys(const phy_set_t *txPhys, const phy_set_t *rxPhys)
Set the preferred PHYs to use in a connection.
ble_error_t setPeriodicAdvertisingParameters(advertising_handle_t handle, periodic_interval_t periodicAdvertisingIntervalMin, periodic_interval_t periodicAdvertisingIntervalMax, bool advertiseTxPower=true)
Set periodic advertising parameters for a given advertising set.
ble_error_t startPeriodicAdvertising(advertising_handle_t handle)
Start periodic advertising for a given set.
ble_error_t startAdvertising(advertising_handle_t handle, adv_duration_t maxDuration=adv_duration_t::forever(), uint8_t maxEvents=0)
Start advertising using the given advertising set.
FunctionPointerWithContext< const Gap * > GapShutdownCallback_t
Gap shutdown event handler.
ble_error_t setWhitelist(const whitelist_t &whitelist)
Set the value of the whitelist to be used during GAP procedures.
ble_error_t setAdvertisingPayload(advertising_handle_t handle, mbed::Span< const uint8_t > payload)
Set new advertising payload for a given advertising set.
void setEventHandler(EventHandler *handler)
Assign the event handler implementation that will be used by the gap module to signal events back to ...
ble_error_t setAdvertisingScanResponse(advertising_handle_t handle, mbed::Span< const uint8_t > response)
Set new advertising scan response for a given advertising set.
ble_error_t stopPeriodicAdvertising(advertising_handle_t handle)
Stop periodic advertising for a given set.
static ble_error_t getRandomAddressType(ble::address_t address, ble::random_address_type_t *addressType)
Return the type of a random address.
ble_error_t reset()
Reset the Gap instance.
uint8_t getMaxPeriodicAdvertiserListSize()
Get number of devices that can be added to the periodic advertiser list.
ble_error_t cancelConnect()
Cancel the connection attempt.
ble_error_t startScan(scan_duration_t duration=scan_duration_t::forever(), duplicates_filter_t filtering=duplicates_filter_t::DISABLE, scan_period_t period=scan_period_t(0))
Start scanning.
ble_error_t clearPeriodicAdvertiserList()
Remove all devices from periodic advertiser list.
ble_error_t getCentralPrivacyConfiguration(central_privacy_configuration_t *configuration)
Get the privacy configuration used by the central role.
ble_error_t setScanParameters(const ScanParameters ¶ms)
Set new scan parameters.
ble_error_t cancelCreateSync()
Cancel sync attempt.
ble_error_t setCentralPrivacyConfiguration(const central_privacy_configuration_t *configuration)
Set the privacy configuration used by the central role.
ble_error_t setPeriodicAdvertisingPayload(advertising_handle_t handle, mbed::Span< const uint8_t > payload)
Set new periodic advertising payload for a given advertising set.
uint8_t getMaxAdvertisingSetNumber()
Return currently available number of supported advertising sets.
uint16_t getMaxConnectableAdvertisingDataLength()
Return maximum advertising data length supported for connectable advertising.
ble_error_t destroyAdvertisingSet(advertising_handle_t handle)
Remove the advertising set (resets its set parameters).
ble_error_t createSync(peer_address_type_t peerAddressType, const address_t &peerAddress, uint8_t sid, slave_latency_t maxPacketSkip, sync_timeout_t timeout)
Synchronize with periodic advertising from an advertiser and begin receiving periodic advertising pac...
uint16_t getMaxActiveSetAdvertisingDataLength()
Return maximum advertising data length you may set if advertising set is active.
bool isFeatureSupported(controller_supported_features_t feature)
Check controller support for a specific feature.
ble_error_t addDeviceToPeriodicAdvertiserList(peer_address_type_t peerAddressType, const address_t &peerAddress, advertising_sid_t sid)
Add device to the periodic advertiser list.
ble_error_t createSync(slave_latency_t maxPacketSkip, sync_timeout_t timeout)
Synchronize with periodic advertising from an advertiser and begin receiving periodic advertising pac...
uint16_t getMaxAdvertisingDataLength()
Return maximum advertising data length supported.
ble_error_t stopScan()
Stop the ongoing scanning procedure.
CallChainOfFunctionPointersWithContext< const Gap * > GapShutdownCallbackChain_t
Callchain of gap shutdown event handler.
ble_error_t setAdvertisingParameters(advertising_handle_t handle, const AdvertisingParameters ¶ms)
Set advertising parameters of an existing set.
GapShutdownCallbackChain_t & onShutdown()
Access the callchain of shutdown event handler.
void onShutdown(T *objPtr, void(T::*memberPtr)(const Gap *))
Register a Gap shutdown event handler.
ble_error_t getWhitelist(whitelist_t &whitelist) const
Get the Link Layer to use the internal whitelist when scanning, advertising or initiating a connectio...
ble_error_t setPhy(connection_handle_t connection, const phy_set_t *txPhys, const phy_set_t *rxPhys, coded_symbol_per_bit_t codedSymbol)
Update the PHY used by a connection.
bool isAdvertisingActive(advertising_handle_t handle)
Check if advertising is active for a given advertising set.
ble_error_t readPhy(connection_handle_t connection)
Read the PHY used by the transmitter and the receiver on a connection.
ble_error_t stopAdvertising(advertising_handle_t handle)
Stop advertising given advertising set.
ble_error_t enablePrivacy(bool enable)
Enable or disable privacy mode of the local device.
uint8_t getMaxWhitelistSize() const
Get the maximum size of the whitelist.
Parameters defining the scan process.
Type that describe a set of PHY(sical) transports.
ble_error_t
Error codes for the BLE API.
Entry namespace for all BLE API definitions.
uintptr_t connection_handle_t
Opaque reference to a connection.
Event produced when advertising ends.
Event generated when an advertising packet is seen during passive scanning or a scan response is rece...
Event produced when advertising start.
Event generated when a connection initiation ends (successfully or not).
Event received when connection parameters have been updated.
Event produced when a disconnection is complete.
Definition of the general handler of Gap related events.
virtual void onAdvertisingStart(const AdvertisingStartEvent &event)
Called when advertising starts.
virtual void onAdvertisingReport(const AdvertisingReportEvent &event)
Called when a scanner receives an advertising or a scan response packet.
virtual void onPeriodicAdvertisingReport(const PeriodicAdvertisingReportEvent &event)
Called when a periodic advertising packet is received.
virtual void onPeriodicAdvertisingSyncEstablished(const PeriodicAdvertisingSyncEstablishedEvent &event)
Called when first advertising packet in periodic advertising is received.
virtual void onDataLengthChange(connection_handle_t connectionHandle, uint16_t txSize, uint16_t rxSize)
Function invoked when the connections changes the maximum number of octets that can be sent or receiv...
virtual void onScanTimeout(const ScanTimeoutEvent &event)
Called when scan times out.
~EventHandler()=default
Prevent polymorphic deletion and avoid unnecessary virtual destructor as the Gap class will never del...
virtual void onPrivacyEnabled()
Function invoked when the privacy subsystem has been enabled and is ready to be used.
virtual void onAdvertisingEnd(const AdvertisingEndEvent &event)
Called when advertising ends.
virtual void onReadPhy(ble_error_t status, connection_handle_t connectionHandle, phy_t txPhy, phy_t rxPhy)
Function invoked when the current transmitter and receiver PHY have been read for a given connection.
virtual void onUpdateConnectionParametersRequest(const UpdateConnectionParametersRequestEvent &event)
Called when the peer request connection parameters updates.
virtual void onConnectionComplete(const ConnectionCompleteEvent &event)
Called when connection attempt ends.
virtual void onDisconnectionComplete(const DisconnectionCompleteEvent &event)
Called when a connection has been disconnected.
virtual void onPhyUpdateComplete(ble_error_t status, connection_handle_t connectionHandle, phy_t txPhy, phy_t rxPhy)
Function invoked when the update process of the PHY has been completed.
virtual void onConnectionParametersUpdateComplete(const ConnectionParametersUpdateCompleteEvent &event)
Called when connection parameters have been updated.
virtual void onScanRequestReceived(const ScanRequestEvent &event)
Called when an advertising device receive a scan request.
virtual void onPeriodicAdvertisingSyncLoss(const PeriodicAdvertisingSyncLoss &event)
Called when a periodic advertising sync has been lost.
Preferred connection parameter display in Generic Access Service.
uint16_t maxConnectionInterval
Maximum interval between two connection events allowed for a connection.
uint16_t minConnectionInterval
Minimum interval between two connection events allowed for a connection.
uint16_t slaveLatency
Number of connection events the slave can drop if it has nothing to communicate to the master.
uint16_t connectionSupervisionTimeout
Link supervision timeout for the connection.
Event generated when periodic advertising packet is received.
Event generated when you first receive a periodic advertisement.
Event generated when periodic advertising sync is lost.
Event produced when a peer requests a scan response from the advertiser.
Event generated when scan times out.
Event received when a peer wants to change the connection parameters.
Type describing the number of symbols per bit in le coded PHY.
Features supported by the controller.
Type that describes a peer device address type.
Type that describes a bluetooth PHY(sical) transport.
Type that describes a random device address type.
Representation of a whitelist of addresses.
Nonowning view to a sequence of contiguous elements.