Mbed OS Reference
Loading...
Searching...
No Matches
ChainableGapEventHandler.h
1/* mbed Microcontroller Library
2 * Copyright (c) 2006-2020 ARM Limited
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef MBED_CHAINABLEGAPEVENTHANDLER_H_
20#define MBED_CHAINABLEGAPEVENTHANDLER_H_
21
22#include "ble/Gap.h"
23#include "ble/common/ChainableEventHandler.h"
24
25/**
26 * Gap::EventHandler implementation that allows the application
27 * to register multiple separate EventHandlers to be called when
28 * Gap events happen.
29 */
31 public ChainableEventHandler<ble::Gap::EventHandler>
32{
33
34public:
35
37
39
40 void onScanRequestReceived(const ble::ScanRequestEvent &event) override {
42 }
43
44 void onAdvertisingStart(const ble::AdvertisingStartEvent &event) override {
45 execute_on_all(&ble::Gap::EventHandler::onAdvertisingStart, event);
46 }
47
48 void onAdvertisingEnd(const ble::AdvertisingEndEvent &event) override {
49 execute_on_all(&ble::Gap::EventHandler::onAdvertisingEnd, event);
50 }
51
53 execute_on_all(&ble::Gap::EventHandler::onAdvertisingReport, event);
54 }
55
56 void onScanTimeout(const ble::ScanTimeoutEvent &event) override {
57 execute_on_all(&ble::Gap::EventHandler::onScanTimeout, event);
58 }
59
63 }
64
66 const ble::PeriodicAdvertisingReportEvent &event) override {
68 }
69
71 const ble::PeriodicAdvertisingSyncLoss &event) override {
73 }
74
77 }
78
80 const ble::UpdateConnectionParametersRequestEvent &event) override {
82 }
83
87 }
88
91 }
92
94 ble_error_t status,
95 ble::connection_handle_t connectionHandle,
96 ble::phy_t txPhy,
97 ble::phy_t rxPhy) override {
98 execute_on_all(&ble::Gap::EventHandler::onReadPhy, status,
99 connectionHandle, txPhy, rxPhy);
100 }
101
103 ble_error_t status,
104 ble::connection_handle_t connectionHandle,
105 ble::phy_t txPhy,
106 ble::phy_t rxPhy) override {
107 execute_on_all(&ble::Gap::EventHandler::onPhyUpdateComplete, status,
108 connectionHandle, txPhy, rxPhy);
109 }
110
112 ble::connection_handle_t connectionHandle,
113 uint16_t txSize,
114 uint16_t rxSize) override {
116 connectionHandle, txSize, rxSize);
117 }
118
119 void onPrivacyEnabled() override {
121 }
122
123};
124
125#endif /* MBED_CHAINABLEGAPEVENTHANDLER_H_ */
Base class for chainable EventHandlers.
Gap::EventHandler implementation that allows the application to register multiple separate EventHandl...
void onDataLengthChange(ble::connection_handle_t connectionHandle, uint16_t txSize, uint16_t rxSize) override
Function invoked when the connections changes the maximum number of octets that can be sent or receiv...
void onReadPhy(ble_error_t status, ble::connection_handle_t connectionHandle, ble::phy_t txPhy, ble::phy_t rxPhy) override
Function invoked when the current transmitter and receiver PHY have been read for a given connection.
void onUpdateConnectionParametersRequest(const ble::UpdateConnectionParametersRequestEvent &event) override
Called when the peer request connection parameters updates.
void onAdvertisingStart(const ble::AdvertisingStartEvent &event) override
Called when advertising starts.
void onScanRequestReceived(const ble::ScanRequestEvent &event) override
Called when an advertising device receive a scan request.
void onPeriodicAdvertisingSyncLoss(const ble::PeriodicAdvertisingSyncLoss &event) override
Called when a periodic advertising sync has been lost.
void onPeriodicAdvertisingReport(const ble::PeriodicAdvertisingReportEvent &event) override
Called when a periodic advertising packet is received.
void onScanTimeout(const ble::ScanTimeoutEvent &event) override
Called when scan times out.
void onPrivacyEnabled() override
Function invoked when the privacy subsystem has been enabled and is ready to be used.
void onPhyUpdateComplete(ble_error_t status, ble::connection_handle_t connectionHandle, ble::phy_t txPhy, ble::phy_t rxPhy) override
Function invoked when the update process of the PHY has been completed.
void onAdvertisingReport(const ble::AdvertisingReportEvent &event) override
Called when a scanner receives an advertising or a scan response packet.
void onAdvertisingEnd(const ble::AdvertisingEndEvent &event) override
Called when advertising ends.
void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &event) override
Called when a connection has been disconnected.
void onConnectionComplete(const ble::ConnectionCompleteEvent &event) override
Called when connection attempt ends.
void onPeriodicAdvertisingSyncEstablished(const ble::PeriodicAdvertisingSyncEstablishedEvent &event) override
Called when first advertising packet in periodic advertising is received.
void onConnectionParametersUpdateComplete(const ble::ConnectionParametersUpdateCompleteEvent &event) override
Called when connection parameters have been updated.
ble_error_t
Error codes for the BLE API.
uintptr_t connection_handle_t
Opaque reference to a connection.
Event produced when advertising ends.
Definition: Events.h:624
Event generated when an advertising packet is seen during passive scanning or a scan response is rece...
Definition: Events.h:40
Event produced when advertising start.
Definition: Events.h:583
Event generated when a connection initiation ends (successfully or not).
Definition: Events.h:211
Event received when connection parameters have been updated.
Definition: Events.h:888
Event produced when a disconnection is complete.
Definition: Events.h:776
Definition of the general handler of Gap related events.
Definition: Gap.h:303
virtual void onAdvertisingStart(const AdvertisingStartEvent &event)
Called when advertising starts.
Definition: Gap.h:326
virtual void onAdvertisingReport(const AdvertisingReportEvent &event)
Called when a scanner receives an advertising or a scan response packet.
Definition: Gap.h:354
virtual void onPeriodicAdvertisingReport(const PeriodicAdvertisingReportEvent &event)
Called when a periodic advertising packet is received.
Definition: Gap.h:393
virtual void onPeriodicAdvertisingSyncEstablished(const PeriodicAdvertisingSyncEstablishedEvent &event)
Called when first advertising packet in periodic advertising is received.
Definition: Gap.h:378
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...
Definition: Gap.h:549
virtual void onScanTimeout(const ScanTimeoutEvent &event)
Called when scan times out.
Definition: Gap.h:365
virtual void onPrivacyEnabled()
Function invoked when the privacy subsystem has been enabled and is ready to be used.
Definition: Gap.h:563
virtual void onAdvertisingEnd(const AdvertisingEndEvent &event)
Called when advertising ends.
Definition: Gap.h:343
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.
Definition: Gap.h:494
virtual void onUpdateConnectionParametersRequest(const UpdateConnectionParametersRequestEvent &event)
Called when the peer request connection parameters updates.
Definition: Gap.h:445
virtual void onConnectionComplete(const ConnectionCompleteEvent &event)
Called when connection attempt ends.
Definition: Gap.h:424
virtual void onDisconnectionComplete(const DisconnectionCompleteEvent &event)
Called when a connection has been disconnected.
Definition: Gap.h:472
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.
Definition: Gap.h:528
virtual void onConnectionParametersUpdateComplete(const ConnectionParametersUpdateCompleteEvent &event)
Called when connection parameters have been updated.
Definition: Gap.h:459
virtual void onScanRequestReceived(const ScanRequestEvent &event)
Called when an advertising device receive a scan request.
Definition: Gap.h:313
virtual void onPeriodicAdvertisingSyncLoss(const PeriodicAdvertisingSyncLoss &event)
Called when a periodic advertising sync has been lost.
Definition: Gap.h:408
Event generated when periodic advertising packet is received.
Definition: Events.h:474
Event generated when you first receive a periodic advertisement.
Definition: Events.h:373
Event generated when periodic advertising sync is lost.
Definition: Events.h:545
Event produced when a peer requests a scan response from the advertiser.
Definition: Events.h:725
Event generated when scan times out.
Definition: Events.h:576
Event received when a peer wants to change the connection parameters.
Definition: Events.h:815
Type that describes a bluetooth PHY(sical) transport.