Mistake on this page?
Report an issue in GitHub or email us
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 
34 public:
35 
37 
39 
40  void onScanRequestReceived(const ble::ScanRequestEvent &event) override {
41  execute_on_all(&ble::Gap::EventHandler::onScanRequestReceived, event);
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 
52  void onAdvertisingReport(const ble::AdvertisingReportEvent &event) override {
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 
61  const ble::PeriodicAdvertisingSyncEstablishedEvent &event) override {
63  }
64 
66  const ble::PeriodicAdvertisingReportEvent &event) override {
68  }
69 
71  const ble::PeriodicAdvertisingSyncLoss &event) override {
73  }
74 
75  void onConnectionComplete(const ble::ConnectionCompleteEvent &event) override {
76  execute_on_all(&ble::Gap::EventHandler::onConnectionComplete, event);
77  }
78 
80  const ble::UpdateConnectionParametersRequestEvent &event) override {
82  }
83 
85  const ble::ConnectionParametersUpdateCompleteEvent &event) override {
87  }
88 
91  }
92 
93  void onReadPhy(
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_ */
Event generated when a connection initiation ends (successfully or not).
Definition: Events.h:211
Gap::EventHandler implementation that allows the application to register multiple separate EventHandl...
Event produced when advertising ends.
Definition: Events.h:624
virtual void onPrivacyEnabled()
Function invoked when the privacy subsystem has been enabled and is ready to be used.
Definition: Gap.h:557
virtual void onScanRequestReceived(const ScanRequestEvent &event)
Called when an advertising device receive a scan response.
Definition: Gap.h:313
void onConnectionComplete(const ble::ConnectionCompleteEvent &event) override
Called when connection attempt ends or an advertising device has been connected.
Event received when connection parameters have been updated.
Definition: Events.h:888
Event generated when periodic advertising sync is lost.
Definition: Events.h:545
void onPrivacyEnabled() override
Function invoked when the privacy subsystem has been enabled and is ready to be used.
uintptr_t connection_handle_t
Opaque reference to a connection.
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:490
Event produced when advertising start.
Definition: Events.h:583
Event generated when an advertising packet is seen during passive scanning or a scan response is rece...
Definition: Events.h:40
virtual void onUpdateConnectionParametersRequest(const UpdateConnectionParametersRequestEvent &event)
Called when the peer request connection parameters updates.
Definition: Gap.h:441
void onScanRequestReceived(const ble::ScanRequestEvent &event) override
Called when an advertising device receive a scan response.
void onScanTimeout(const ble::ScanTimeoutEvent &event) override
Called when scan times out.
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...
virtual void onConnectionComplete(const ConnectionCompleteEvent &event)
Called when connection attempt ends or an advertising device has been connected.
Definition: Gap.h:420
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:545
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.
virtual void onAdvertisingStart(const AdvertisingStartEvent &event)
Called when advertising starts.
Definition: Gap.h:324
void onAdvertisingEnd(const ble::AdvertisingEndEvent &event) override
Called when advertising ends.
void onPeriodicAdvertisingSyncLoss(const ble::PeriodicAdvertisingSyncLoss &event) override
Called when a periodic advertising sync has been lost.
Type that describes a bluetooth PHY(sical) transport.
virtual void onAdvertisingEnd(const AdvertisingEndEvent &event)
Called when advertising ends.
Definition: Gap.h:340
void onAdvertisingStart(const ble::AdvertisingStartEvent &event) override
Called when advertising starts.
virtual void onScanTimeout(const ScanTimeoutEvent &event)
Called when scan times out.
Definition: Gap.h:362
virtual void onConnectionParametersUpdateComplete(const ConnectionParametersUpdateCompleteEvent &event)
Called when connection parameters have been updated.
Definition: Gap.h:455
Base class for chainable EventHandlers.
Event generated when you first receive a periodic advertisement.
Definition: Events.h:373
void onPeriodicAdvertisingSyncEstablished(const ble::PeriodicAdvertisingSyncEstablishedEvent &event) override
Called when first advertising packet in periodic advertising is received.
void onPeriodicAdvertisingReport(const ble::PeriodicAdvertisingReportEvent &event) override
Called when a periodic advertising packet is received.
Event generated when scan times out.
Definition: Events.h:576
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 onDisconnectionComplete(const DisconnectionCompleteEvent &event)
Called when a connection has been disconnected.
Definition: Gap.h:468
Event generated when periodic advertising packet is received.
Definition: Events.h:474
Event received when a peer wants to change the connection parameters.
Definition: Events.h:815
virtual void onPeriodicAdvertisingSyncLoss(const PeriodicAdvertisingSyncLoss &event)
Called when a periodic advertising sync has been lost.
Definition: Gap.h:405
virtual void onPeriodicAdvertisingReport(const PeriodicAdvertisingReportEvent &event)
Called when a periodic advertising packet is received.
Definition: Gap.h:390
virtual void onAdvertisingReport(const AdvertisingReportEvent &event)
Called when a scanner receives an advertising or a scan response packet.
Definition: Gap.h:351
void onAdvertisingReport(const ble::AdvertisingReportEvent &event) override
Called when a scanner receives an advertising or a scan response packet.
void onConnectionParametersUpdateComplete(const ble::ConnectionParametersUpdateCompleteEvent &event) override
Called when connection parameters have been updated.
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:524
void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &event) override
Called when a connection has been disconnected.
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.
Event produced when a peer requests a scan response from the advertiser.
Definition: Events.h:725
virtual void onPeriodicAdvertisingSyncEstablished(const PeriodicAdvertisingSyncEstablishedEvent &event)
Called when first advertising packet in periodic advertising is received.
Definition: Gap.h:375
ble_error_t
Error codes for the BLE API.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.