mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Move Gap event types in dedicated file.
parent
3737e385af
commit
6f21326b6a
|
@ -25,6 +25,7 @@
|
||||||
#include "ble/gap/ConnectionParameters.h"
|
#include "ble/gap/ConnectionParameters.h"
|
||||||
#include "ble/gap/ScanParameters.h"
|
#include "ble/gap/ScanParameters.h"
|
||||||
#include "ble/gap/AdvertisingParameters.h"
|
#include "ble/gap/AdvertisingParameters.h"
|
||||||
|
#include "ble/gap/Events.h"
|
||||||
|
|
||||||
// leagacy gap headers
|
// leagacy gap headers
|
||||||
#include "ble/GapAdvertisingData.h"
|
#include "ble/GapAdvertisingData.h"
|
||||||
|
@ -1162,128 +1163,6 @@ public:
|
||||||
* Definition of the general handler of Gap related events.
|
* Definition of the general handler of Gap related events.
|
||||||
*/
|
*/
|
||||||
struct EventHandler {
|
struct EventHandler {
|
||||||
|
|
||||||
/** Event generated when an advertising packet is seen during passive scanning
|
|
||||||
* or a scan response is received during active scanning.
|
|
||||||
*/
|
|
||||||
struct AdvertisingReportEvent {
|
|
||||||
/** Create a advertising report event.
|
|
||||||
*
|
|
||||||
* @param type Type of advertising used.
|
|
||||||
* @param peerAddressType Peer address type of advertiser.
|
|
||||||
* @param peerAddress Peer address of advertiser.
|
|
||||||
* @param primaryPhy PHY used on the primary channels.
|
|
||||||
* @param secondaryPhy PHY used on secondary channels.
|
|
||||||
* @param SID Set identification number.
|
|
||||||
* @param txPower Transmission power reported by the packet.
|
|
||||||
* @param rssi Measured signal strength.
|
|
||||||
* @param periodicInterval Interval of periodic advertising.
|
|
||||||
* @param directAddressType Directed advertising target address type.
|
|
||||||
* @param directAddress Directed advertising target address.
|
|
||||||
* @param advertisingData Advertising payload.
|
|
||||||
*/
|
|
||||||
AdvertisingReportEvent(
|
|
||||||
const AdvertisingEventType_t &type,
|
|
||||||
const PeerAddressType_t &peerAddressType,
|
|
||||||
const ble::address_t &peerAddress,
|
|
||||||
const Phy_t &primaryPhy,
|
|
||||||
const Phy_t &secondaryPhy,
|
|
||||||
ble::advertising_sid_t SID,
|
|
||||||
ble::advertising_power_t txPower,
|
|
||||||
ble::rssi_t rssi,
|
|
||||||
UnitPeriodicInterval_t periodicInterval,
|
|
||||||
const PeerAddressType_t &directAddressType,
|
|
||||||
const ble::address_t &directAddress,
|
|
||||||
const mbed::Span<const uint8_t> &advertisingData
|
|
||||||
) :
|
|
||||||
type(type),
|
|
||||||
peerAddressType(peerAddressType),
|
|
||||||
peerAddress(peerAddress),
|
|
||||||
primaryPhy(primaryPhy),
|
|
||||||
secondaryPhy(secondaryPhy),
|
|
||||||
SID(SID),
|
|
||||||
txPower(txPower),
|
|
||||||
rssi(rssi),
|
|
||||||
periodicInterval(periodicInterval),
|
|
||||||
directAddressType(directAddressType),
|
|
||||||
directAddress(directAddress),
|
|
||||||
advertisingData(advertisingData) { }
|
|
||||||
|
|
||||||
/** Get event type. */
|
|
||||||
const AdvertisingEventType_t &getType() const {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get peer address type. */
|
|
||||||
const PeerAddressType_t &getPeerAddressType() const {
|
|
||||||
return peerAddressType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get peer address. */
|
|
||||||
const ble::address_t &getPeerAddress() const {
|
|
||||||
return peerAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get primary PHY. */
|
|
||||||
const Phy_t &getPrimaryPhy() const {
|
|
||||||
return primaryPhy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get secondary PHY. */
|
|
||||||
const Phy_t &getSecondaryPhy() const {
|
|
||||||
return secondaryPhy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get advertising set identifier. */
|
|
||||||
ble::advertising_sid_t getSID() const {
|
|
||||||
return SID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get TX power. */
|
|
||||||
ble::advertising_power_t getTxPower() const {
|
|
||||||
return txPower;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get received signal strength. */
|
|
||||||
ble::rssi_t getRssi() const {
|
|
||||||
return rssi;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get interval. */
|
|
||||||
UnitPeriodicInterval_t getPeriodicInterval() const {
|
|
||||||
return periodicInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get target address type in directed advertising. */
|
|
||||||
const PeerAddressType_t &getDirectAddressType() const {
|
|
||||||
return directAddressType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get target address in directed advertising. */
|
|
||||||
const ble::address_t &getDirectAddress() const {
|
|
||||||
return directAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get payload. */
|
|
||||||
const mbed::Span<const uint8_t> &getAdvertisingData() const {
|
|
||||||
return advertisingData;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
AdvertisingEventType_t type;
|
|
||||||
PeerAddressType_t peerAddressType;
|
|
||||||
ble::address_t const &peerAddress;
|
|
||||||
Phy_t primaryPhy;
|
|
||||||
Phy_t secondaryPhy;
|
|
||||||
ble::advertising_sid_t SID;
|
|
||||||
ble::advertising_power_t txPower;
|
|
||||||
ble::rssi_t rssi;
|
|
||||||
UnitPeriodicInterval_t periodicInterval;
|
|
||||||
PeerAddressType_t directAddressType;
|
|
||||||
const ble::address_t &directAddress;
|
|
||||||
mbed::Span<const uint8_t> advertisingData;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Called when scanning reads an advertising packet during passive scan or receives
|
/** Called when scanning reads an advertising packet during passive scan or receives
|
||||||
* a scan response during an active scan.
|
* a scan response during an active scan.
|
||||||
*
|
*
|
||||||
|
@ -1295,117 +1174,6 @@ public:
|
||||||
(void) event;
|
(void) event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event generated when a connection initiation end (successfully or not).
|
|
||||||
*/
|
|
||||||
struct ConnectionCompleteEvent {
|
|
||||||
/** Create a connection complete event.
|
|
||||||
*
|
|
||||||
* @param success BLE_ERROR_NONE if connection succeeded.
|
|
||||||
* @param connectionHandle Connection handle if successful.
|
|
||||||
* @param ownRole Role of the local device.
|
|
||||||
* @param peerAddressType Peer address type.
|
|
||||||
* @param peerAddress Peer address.
|
|
||||||
* @param localResolvablePrivateAddress Local address type if privacy enabled.
|
|
||||||
* @param peerResolvablePrivateAddress Peer address type if privacy enabled.
|
|
||||||
* @param connectionInterval Connection interval.
|
|
||||||
* @param connectionLatency Connection latency in events.
|
|
||||||
* @param supervisionTimeout Supervision timeout.
|
|
||||||
* @param masterClockAccuracy Peer clock accuracy in parts per million.
|
|
||||||
*/
|
|
||||||
ConnectionCompleteEvent(
|
|
||||||
ble_error_t status,
|
|
||||||
Handle_t connectionHandle,
|
|
||||||
Role_t ownRole,
|
|
||||||
const PeerAddressType_t &peerAddressType,
|
|
||||||
const ble::address_t &peerAddress,
|
|
||||||
const ble::address_t &localResolvablePrivateAddress,
|
|
||||||
const ble::address_t &peerResolvablePrivateAddress,
|
|
||||||
UnitConnInterval_t connectionInterval,
|
|
||||||
UnitSlaveLatency_t connectionLatency,
|
|
||||||
UnitSupervisionTimeout_t supervisionTimeout,
|
|
||||||
uint16_t masterClockAccuracy
|
|
||||||
) :
|
|
||||||
status(status),
|
|
||||||
connectionHandle(connectionHandle),
|
|
||||||
ownRole(ownRole),
|
|
||||||
peerAddressType(peerAddressType),
|
|
||||||
peerAddress(peerAddress),
|
|
||||||
localResolvablePrivateAddress(localResolvablePrivateAddress),
|
|
||||||
peerResolvablePrivateAddress(peerResolvablePrivateAddress),
|
|
||||||
connectionInterval(connectionInterval),
|
|
||||||
connectionLatency(connectionLatency),
|
|
||||||
supervisionTimeout(supervisionTimeout),
|
|
||||||
masterClockAccuracy(masterClockAccuracy) { }
|
|
||||||
|
|
||||||
/** Get connection complete event status. */
|
|
||||||
ble_error_t getStatus() const {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get connection handle (valid only when successful). */
|
|
||||||
Handle_t getConnectionHandle() const {
|
|
||||||
return connectionHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get own role. */
|
|
||||||
Role_t getOwnRole() const {
|
|
||||||
return ownRole;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get peer address type. */
|
|
||||||
const PeerAddressType_t &getPeerAddressType() const {
|
|
||||||
return peerAddressType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get peer address. */
|
|
||||||
const ble::address_t &getPeerAddress() const {
|
|
||||||
return peerAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get get local resolvable random address if privacy is used. */
|
|
||||||
const ble::address_t &getLocalResolvablePrivateAddress() const {
|
|
||||||
return localResolvablePrivateAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get peer resolvable private address if privacy is used. */
|
|
||||||
const ble::address_t &getPeerResolvablePrivateAddress() const {
|
|
||||||
return peerResolvablePrivateAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get connection interval. */
|
|
||||||
UnitConnInterval_t getConnectionInterval() const {
|
|
||||||
return connectionInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get connection latency. */
|
|
||||||
UnitSlaveLatency_t getConnectionLatency() const {
|
|
||||||
return connectionLatency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get supervision timeout. */
|
|
||||||
UnitSupervisionTimeout_t getSupervisionTimeout() const {
|
|
||||||
return supervisionTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get clock accuracy in parts per million. */
|
|
||||||
uint16_t getMasterClockAccuracy() const {
|
|
||||||
return masterClockAccuracy;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ble_error_t status;
|
|
||||||
Handle_t connectionHandle;
|
|
||||||
Role_t ownRole;
|
|
||||||
PeerAddressType_t peerAddressType;
|
|
||||||
const ble::address_t &peerAddress;
|
|
||||||
const ble::address_t &localResolvablePrivateAddress;
|
|
||||||
const ble::address_t &peerResolvablePrivateAddress;
|
|
||||||
UnitConnInterval_t connectionInterval;
|
|
||||||
UnitSlaveLatency_t connectionLatency;
|
|
||||||
UnitSupervisionTimeout_t supervisionTimeout;
|
|
||||||
uint16_t masterClockAccuracy;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Called when connection attempt ends.
|
/** Called when connection attempt ends.
|
||||||
*
|
*
|
||||||
* @param event Connection event @see ConnectionCompleteEvent_t for details.
|
* @param event Connection event @see ConnectionCompleteEvent_t for details.
|
||||||
|
@ -1416,90 +1184,6 @@ public:
|
||||||
(void)event;
|
(void)event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event generated when we first receive a periodic advertisement.
|
|
||||||
*/
|
|
||||||
struct PeriodicAdvertisingSyncEstablishedEvent {
|
|
||||||
/** Create advertising sync event.
|
|
||||||
*
|
|
||||||
* @param success BLE_ERROR_NONE if synchronisation was achieved.
|
|
||||||
* @param syncHandle Advertising sync handle.
|
|
||||||
* @param sid Advertising set identifier.
|
|
||||||
* @param peerAddressType Peer address type.
|
|
||||||
* @param peerAddress Peer address.
|
|
||||||
* @param peerPhy PHY used for advertisements.
|
|
||||||
* @param advertisingInterval Periodic advertising interval.
|
|
||||||
* @param masterClockAccuracy Peer clock accuracy in parts per million.
|
|
||||||
*/
|
|
||||||
PeriodicAdvertisingSyncEstablishedEvent(
|
|
||||||
ble_error_t status,
|
|
||||||
ble::periodic_sync_handle_t syncHandle,
|
|
||||||
ble::advertising_sid_t sid,
|
|
||||||
const PeerAddressType_t &peerAddressType,
|
|
||||||
const ble::address_t &peerAddress,
|
|
||||||
const Phy_t &peerPhy,
|
|
||||||
uint16_t advertisingInterval,
|
|
||||||
const ble::clock_accuracy_t &peerClockAccuracy
|
|
||||||
) :
|
|
||||||
status(status),
|
|
||||||
syncHandle(syncHandle),
|
|
||||||
sid(sid),
|
|
||||||
peerAddressType(peerAddressType),
|
|
||||||
peerAddress(peerAddress),
|
|
||||||
peerPhy(peerPhy),
|
|
||||||
advertisingInterval(advertisingInterval),
|
|
||||||
peerClockAccuracy(peerClockAccuracy) { }
|
|
||||||
|
|
||||||
/** Get sync establishment status. */
|
|
||||||
ble_error_t getStatus() const {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get periodic advertising sync handle. */
|
|
||||||
ble::periodic_sync_handle_t getSyncHandle() const {
|
|
||||||
return syncHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get advertising set identifier. */
|
|
||||||
ble::advertising_sid_t getSid() const {
|
|
||||||
return sid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get peer address type. */
|
|
||||||
const PeerAddressType_t &getPeerAddressType() const {
|
|
||||||
return peerAddressType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get peer address. */
|
|
||||||
const ble::address_t &getPeerAddress() const {
|
|
||||||
return peerAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get PHY used. */
|
|
||||||
const Phy_t &getPeerPhy() const {
|
|
||||||
return peerPhy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get interval. */
|
|
||||||
uint16_t getAdvertisingInterval() const {
|
|
||||||
return advertisingInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get clock accuracy in parts per million. */
|
|
||||||
const ble::clock_accuracy_t &getPeerClockAccuracy() const {
|
|
||||||
return peerClockAccuracy;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ble_error_t status;
|
|
||||||
ble::periodic_sync_handle_t syncHandle;
|
|
||||||
ble::advertising_sid_t sid;
|
|
||||||
PeerAddressType_t peerAddressType;
|
|
||||||
const ble::address_t& peerAddress;
|
|
||||||
Phy_t peerPhy;
|
|
||||||
uint16_t advertisingInterval;
|
|
||||||
ble::clock_accuracy_t peerClockAccuracy;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Called when first advertising packet in periodic advertising is received.
|
/** Called when first advertising packet in periodic advertising is received.
|
||||||
*
|
*
|
||||||
* @param event Periodic advertising sync event @see PeriodicAdvertisingSyncEstablishedEvent.
|
* @param event Periodic advertising sync event @see PeriodicAdvertisingSyncEstablishedEvent.
|
||||||
|
@ -1510,63 +1194,6 @@ public:
|
||||||
(void) event;
|
(void) event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event generated when periodic advertising packet is received.
|
|
||||||
*/
|
|
||||||
struct PeriodicAdvertisingReportEvent {
|
|
||||||
/** Create periodic advertising report event.
|
|
||||||
*
|
|
||||||
* @param syncHandle Periodic advertising sync handle
|
|
||||||
* @param txPower TX power.
|
|
||||||
* @param rssi Received signal strength.
|
|
||||||
* @param dataStatus Status to indicate the completeness of the payload.
|
|
||||||
* @param payload Periodic advertisement payload.
|
|
||||||
*/
|
|
||||||
PeriodicAdvertisingReportEvent(
|
|
||||||
ble::periodic_sync_handle_t syncHandle,
|
|
||||||
ble::advertising_power_t txPower,
|
|
||||||
ble::rssi_t rssi,
|
|
||||||
ble::advertising_data_status_t dataStatus,
|
|
||||||
const mbed::Span<const uint8_t> &payload
|
|
||||||
) :
|
|
||||||
syncHandle(syncHandle),
|
|
||||||
txPower(txPower),
|
|
||||||
rssi(rssi),
|
|
||||||
dataStatus(dataStatus),
|
|
||||||
payload(payload) { }
|
|
||||||
|
|
||||||
/** Get periodic advertising sync handle. */
|
|
||||||
ble::periodic_sync_handle_t getSyncHandle() const {
|
|
||||||
return syncHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get TX power as reported by the advertising packet. */
|
|
||||||
ble::advertising_power_t getTxPower() const {
|
|
||||||
return txPower;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get received signal strength. */
|
|
||||||
ble::rssi_t getRssi() const {
|
|
||||||
return rssi;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get data completeness status. */
|
|
||||||
const ble::advertising_data_status_t &getDataStatus() const {
|
|
||||||
return dataStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get payload. */
|
|
||||||
const mbed::Span<const uint8_t> &getPayload() const {
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ble::periodic_sync_handle_t syncHandle;
|
|
||||||
ble::advertising_power_t txPower;
|
|
||||||
ble::rssi_t rssi;
|
|
||||||
ble::advertising_data_status_t dataStatus;
|
|
||||||
mbed::Span<const uint8_t> payload;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Called when a periodic advertising packet is received.
|
/** Called when a periodic advertising packet is received.
|
||||||
*
|
*
|
||||||
* @param event Periodic advertisement event.
|
* @param event Periodic advertisement event.
|
||||||
|
@ -1577,89 +1204,16 @@ public:
|
||||||
(void) event;
|
(void) event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event generated when periodic advertising sync is lost.
|
|
||||||
*/
|
|
||||||
struct PeriodicAdvertisingSyncLoss {
|
|
||||||
/** Create periodic advertising sync loss event.
|
|
||||||
*
|
|
||||||
* @param syncHandle Periodic advertising sync handle.
|
|
||||||
*/
|
|
||||||
PeriodicAdvertisingSyncLoss(
|
|
||||||
ble::periodic_sync_handle_t syncHandle
|
|
||||||
) :
|
|
||||||
syncHandle(syncHandle) { }
|
|
||||||
|
|
||||||
/** Get periodic sync handle. */
|
|
||||||
ble::periodic_sync_handle_t getSyncHandle() const {
|
|
||||||
return syncHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ble::periodic_sync_handle_t syncHandle;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual void onPeriodicAdvertisingSyncLoss(
|
virtual void onPeriodicAdvertisingSyncLoss(
|
||||||
const PeriodicAdvertisingSyncLoss &event
|
const PeriodicAdvertisingSyncLoss &event
|
||||||
) {
|
) {
|
||||||
(void) event;
|
(void) event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event generated when scan times out.
|
|
||||||
*/
|
|
||||||
struct ScanTimeoutEvent { };
|
|
||||||
|
|
||||||
/** Called when scan times out.
|
/** Called when scan times out.
|
||||||
*/
|
*/
|
||||||
virtual void onScanTimeout(const ScanTimeoutEvent &) { }
|
virtual void onScanTimeout(const ScanTimeoutEvent &) { }
|
||||||
|
|
||||||
/** Event produced when advertising ends.
|
|
||||||
*/
|
|
||||||
struct AdvertisingEndEvent_t {
|
|
||||||
/** Create advertising end event.
|
|
||||||
*
|
|
||||||
* @param advHandle Advertising set handle.
|
|
||||||
* @param connection Connection handle.
|
|
||||||
* @param completed_events Number of events created during before advertising end.
|
|
||||||
* @param connected True if connection has been established.
|
|
||||||
*/
|
|
||||||
AdvertisingEndEvent_t(
|
|
||||||
AdvHandle_t advHandle,
|
|
||||||
Handle_t connection,
|
|
||||||
uint8_t completed_events,
|
|
||||||
bool connected
|
|
||||||
) :
|
|
||||||
advHandle(advHandle),
|
|
||||||
connection(connection),
|
|
||||||
completed_events(completed_events),
|
|
||||||
connected(connected) { }
|
|
||||||
|
|
||||||
/** Get advertising handle. */
|
|
||||||
AdvHandle_t getAdvHandle() const {
|
|
||||||
return advHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get connection handle (valid only if connected successfully). */
|
|
||||||
Handle_t getConnection() const {
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get how many events advertising created. */
|
|
||||||
uint8_t getCompleted_events() const {
|
|
||||||
return completed_events;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Has the advertising ended with a connection. */
|
|
||||||
bool isConnected() const {
|
|
||||||
return connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
AdvHandle_t advHandle;
|
|
||||||
Handle_t connection;
|
|
||||||
uint8_t completed_events;
|
|
||||||
bool connected;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Called when advertising ends.
|
/** Called when advertising ends.
|
||||||
*
|
*
|
||||||
* @param event Advertising end event: @see AdvertisingEndEvent_t for details.
|
* @param event Advertising end event: @see AdvertisingEndEvent_t for details.
|
||||||
|
@ -1670,45 +1224,6 @@ public:
|
||||||
(void) event;
|
(void) event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event produced when a peer requests a scan response from the advertiser.
|
|
||||||
*/
|
|
||||||
struct ScanRequestEvent_t {
|
|
||||||
/** Create scan request event.
|
|
||||||
*
|
|
||||||
* @param advHandle Advertising handle.
|
|
||||||
* @param peerAddressType Peer address type.
|
|
||||||
* @param peerAddress Peer address.
|
|
||||||
*/
|
|
||||||
ScanRequestEvent_t(
|
|
||||||
AdvHandle_t advHandle,
|
|
||||||
const PeerAddressType_t &peerAddressType,
|
|
||||||
const ble::address_t &peerAddress
|
|
||||||
) :
|
|
||||||
advHandle(advHandle),
|
|
||||||
peerAddressType(peerAddressType),
|
|
||||||
peerAddress(peerAddress) { }
|
|
||||||
|
|
||||||
/** Get advertising handle. */
|
|
||||||
AdvHandle_t getAdvHandle() const {
|
|
||||||
return advHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get peer address type. */
|
|
||||||
const PeerAddressType_t &getPeerAddressType() const {
|
|
||||||
return peerAddressType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get peer address. */
|
|
||||||
const ble::address_t &getPeerAddress() const {
|
|
||||||
return peerAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
AdvHandle_t advHandle;
|
|
||||||
PeerAddressType_t peerAddressType;
|
|
||||||
const ble::address_t &peerAddress;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Called when a scanning device request a scan response.
|
/** Called when a scanning device request a scan response.
|
||||||
*
|
*
|
||||||
* @param event Scan request event: @see ScanRequestEvent_t for details.
|
* @param event Scan request event: @see ScanRequestEvent_t for details.
|
||||||
|
|
|
@ -0,0 +1,509 @@
|
||||||
|
/* mbed Microcontroller Library
|
||||||
|
* Copyright (c) 2018-2018 ARM Limited
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BLE_GAP_EVENTS_H
|
||||||
|
#define BLE_GAP_EVENTS_H
|
||||||
|
|
||||||
|
#include "ble/blecommon.h"
|
||||||
|
#include "ble/BLETypes.h"
|
||||||
|
#include "platform/Span.h"
|
||||||
|
|
||||||
|
/** Event generated when an advertising packet is seen during passive scanning
|
||||||
|
* or a scan response is received during active scanning.
|
||||||
|
*/
|
||||||
|
struct AdvertisingReportEvent {
|
||||||
|
/** Create a advertising report event.
|
||||||
|
*
|
||||||
|
* @param type Type of advertising used.
|
||||||
|
* @param peerAddressType Peer address type of advertiser.
|
||||||
|
* @param peerAddress Peer address of advertiser.
|
||||||
|
* @param primaryPhy PHY used on the primary channels.
|
||||||
|
* @param secondaryPhy PHY used on secondary channels.
|
||||||
|
* @param SID Set identification number.
|
||||||
|
* @param txPower Transmission power reported by the packet.
|
||||||
|
* @param rssi Measured signal strength.
|
||||||
|
* @param periodicInterval Interval of periodic advertising.
|
||||||
|
* @param directAddressType Directed advertising target address type.
|
||||||
|
* @param directAddress Directed advertising target address.
|
||||||
|
* @param advertisingData Advertising payload.
|
||||||
|
*/
|
||||||
|
AdvertisingReportEvent(
|
||||||
|
const ble::advertising_event_t &type,
|
||||||
|
const ble::peer_address_type_t &peerAddressType,
|
||||||
|
const ble::address_t &peerAddress,
|
||||||
|
const ble::phy_t &primaryPhy,
|
||||||
|
const ble::phy_t &secondaryPhy,
|
||||||
|
ble::advertising_sid_t SID,
|
||||||
|
ble::advertising_power_t txPower,
|
||||||
|
ble::rssi_t rssi,
|
||||||
|
ble::unit_periodic_interval_t periodicInterval,
|
||||||
|
const ble::peer_address_type_t &directAddressType,
|
||||||
|
const ble::address_t &directAddress,
|
||||||
|
const mbed::Span<const uint8_t> &advertisingData
|
||||||
|
) :
|
||||||
|
type(type),
|
||||||
|
peerAddressType(peerAddressType),
|
||||||
|
peerAddress(peerAddress),
|
||||||
|
primaryPhy(primaryPhy),
|
||||||
|
secondaryPhy(secondaryPhy),
|
||||||
|
SID(SID),
|
||||||
|
txPower(txPower),
|
||||||
|
rssi(rssi),
|
||||||
|
periodicInterval(periodicInterval),
|
||||||
|
directAddressType(directAddressType),
|
||||||
|
directAddress(directAddress),
|
||||||
|
advertisingData(advertisingData) { }
|
||||||
|
|
||||||
|
/** Get event type. */
|
||||||
|
const ble::advertising_event_t &getType() const {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get peer address type. */
|
||||||
|
const ble::peer_address_type_t &getPeerAddressType() const {
|
||||||
|
return peerAddressType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get peer address. */
|
||||||
|
const ble::address_t &getPeerAddress() const {
|
||||||
|
return peerAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get primary PHY. */
|
||||||
|
const ble::phy_t &getPrimaryPhy() const {
|
||||||
|
return primaryPhy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get secondary PHY. */
|
||||||
|
const ble::phy_t &getSecondaryPhy() const {
|
||||||
|
return secondaryPhy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get advertising set identifier. */
|
||||||
|
ble::advertising_sid_t getSID() const {
|
||||||
|
return SID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get TX power. */
|
||||||
|
ble::advertising_power_t getTxPower() const {
|
||||||
|
return txPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get received signal strength. */
|
||||||
|
ble::rssi_t getRssi() const {
|
||||||
|
return rssi;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get interval. */
|
||||||
|
ble::unit_periodic_interval_t getPeriodicInterval() const {
|
||||||
|
return periodicInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get target address type in directed advertising. */
|
||||||
|
const ble::peer_address_type_t &getDirectAddressType() const {
|
||||||
|
return directAddressType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get target address in directed advertising. */
|
||||||
|
const ble::address_t &getDirectAddress() const {
|
||||||
|
return directAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get payload. */
|
||||||
|
const mbed::Span<const uint8_t> &getAdvertisingData() const {
|
||||||
|
return advertisingData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ble::advertising_event_t type;
|
||||||
|
ble::peer_address_type_t peerAddressType;
|
||||||
|
ble::address_t const &peerAddress;
|
||||||
|
ble::phy_t primaryPhy;
|
||||||
|
ble::phy_t secondaryPhy;
|
||||||
|
ble::advertising_sid_t SID;
|
||||||
|
ble::advertising_power_t txPower;
|
||||||
|
ble::rssi_t rssi;
|
||||||
|
ble::unit_periodic_interval_t periodicInterval;
|
||||||
|
ble::peer_address_type_t directAddressType;
|
||||||
|
const ble::address_t &directAddress;
|
||||||
|
mbed::Span<const uint8_t> advertisingData;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Event generated when a connection initiation end (successfully or not).
|
||||||
|
*/
|
||||||
|
struct ConnectionCompleteEvent {
|
||||||
|
/** Create a connection complete event.
|
||||||
|
*
|
||||||
|
* @param success BLE_ERROR_NONE if connection succeeded.
|
||||||
|
* @param connectionHandle Connection handle if successful.
|
||||||
|
* @param ownRole Role of the local device.
|
||||||
|
* @param peerAddressType Peer address type.
|
||||||
|
* @param peerAddress Peer address.
|
||||||
|
* @param localResolvablePrivateAddress Local address type if privacy enabled.
|
||||||
|
* @param peerResolvablePrivateAddress Peer address type if privacy enabled.
|
||||||
|
* @param connectionInterval Connection interval.
|
||||||
|
* @param connectionLatency Connection latency in events.
|
||||||
|
* @param supervisionTimeout Supervision timeout.
|
||||||
|
* @param masterClockAccuracy Peer clock accuracy in parts per million.
|
||||||
|
*/
|
||||||
|
ConnectionCompleteEvent(
|
||||||
|
ble_error_t status,
|
||||||
|
ble::connection_handle_t connectionHandle,
|
||||||
|
ble::connection_role_t ownRole,
|
||||||
|
const ble::peer_address_type_t &peerAddressType,
|
||||||
|
const ble::address_t &peerAddress,
|
||||||
|
const ble::address_t &localResolvablePrivateAddress,
|
||||||
|
const ble::address_t &peerResolvablePrivateAddress,
|
||||||
|
ble::unit_conn_interval_t connectionInterval,
|
||||||
|
ble::unit_slave_latency_t connectionLatency,
|
||||||
|
ble::unit_supervision_timeout_t supervisionTimeout,
|
||||||
|
uint16_t masterClockAccuracy
|
||||||
|
) :
|
||||||
|
status(status),
|
||||||
|
connectionHandle(connectionHandle),
|
||||||
|
ownRole(ownRole),
|
||||||
|
peerAddressType(peerAddressType),
|
||||||
|
peerAddress(peerAddress),
|
||||||
|
localResolvablePrivateAddress(localResolvablePrivateAddress),
|
||||||
|
peerResolvablePrivateAddress(peerResolvablePrivateAddress),
|
||||||
|
connectionInterval(connectionInterval),
|
||||||
|
connectionLatency(connectionLatency),
|
||||||
|
supervisionTimeout(supervisionTimeout),
|
||||||
|
masterClockAccuracy(masterClockAccuracy) { }
|
||||||
|
|
||||||
|
/** Get connection complete event status. */
|
||||||
|
ble_error_t getStatus() const {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get connection handle (valid only when successful). */
|
||||||
|
ble::connection_handle_t getConnectionHandle() const {
|
||||||
|
return connectionHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get own role. */
|
||||||
|
ble::connection_role_t getOwnRole() const {
|
||||||
|
return ownRole;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get peer address type. */
|
||||||
|
const ble::peer_address_type_t &getPeerAddressType() const {
|
||||||
|
return peerAddressType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get peer address. */
|
||||||
|
const ble::address_t &getPeerAddress() const {
|
||||||
|
return peerAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get get local resolvable random address if privacy is used. */
|
||||||
|
const ble::address_t &getLocalResolvablePrivateAddress() const {
|
||||||
|
return localResolvablePrivateAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get peer resolvable private address if privacy is used. */
|
||||||
|
const ble::address_t &getPeerResolvablePrivateAddress() const {
|
||||||
|
return peerResolvablePrivateAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get connection interval. */
|
||||||
|
ble::unit_conn_interval_t getConnectionInterval() const {
|
||||||
|
return connectionInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get connection latency. */
|
||||||
|
ble::unit_slave_latency_t getConnectionLatency() const {
|
||||||
|
return connectionLatency;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get supervision timeout. */
|
||||||
|
ble::unit_supervision_timeout_t getSupervisionTimeout() const {
|
||||||
|
return supervisionTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get clock accuracy in parts per million. */
|
||||||
|
uint16_t getMasterClockAccuracy() const {
|
||||||
|
return masterClockAccuracy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ble_error_t status;
|
||||||
|
ble::connection_handle_t connectionHandle;
|
||||||
|
ble::connection_role_t ownRole;
|
||||||
|
ble::peer_address_type_t peerAddressType;
|
||||||
|
const ble::address_t &peerAddress;
|
||||||
|
const ble::address_t &localResolvablePrivateAddress;
|
||||||
|
const ble::address_t &peerResolvablePrivateAddress;
|
||||||
|
ble::unit_conn_interval_t connectionInterval;
|
||||||
|
ble::unit_slave_latency_t connectionLatency;
|
||||||
|
ble::unit_supervision_timeout_t supervisionTimeout;
|
||||||
|
uint16_t masterClockAccuracy;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Event generated when we first receive a periodic advertisement.
|
||||||
|
*/
|
||||||
|
struct PeriodicAdvertisingSyncEstablishedEvent {
|
||||||
|
/** Create advertising sync event.
|
||||||
|
*
|
||||||
|
* @param success BLE_ERROR_NONE if synchronisation was achieved.
|
||||||
|
* @param syncHandle Advertising sync handle.
|
||||||
|
* @param sid Advertising set identifier.
|
||||||
|
* @param peerAddressType Peer address type.
|
||||||
|
* @param peerAddress Peer address.
|
||||||
|
* @param peerPhy PHY used for advertisements.
|
||||||
|
* @param advertisingInterval Periodic advertising interval.
|
||||||
|
* @param masterClockAccuracy Peer clock accuracy in parts per million.
|
||||||
|
*/
|
||||||
|
PeriodicAdvertisingSyncEstablishedEvent(
|
||||||
|
ble_error_t status,
|
||||||
|
ble::periodic_sync_handle_t syncHandle,
|
||||||
|
ble::advertising_sid_t sid,
|
||||||
|
const ble::peer_address_type_t &peerAddressType,
|
||||||
|
const ble::address_t &peerAddress,
|
||||||
|
const ble::phy_t &peerPhy,
|
||||||
|
uint16_t advertisingInterval,
|
||||||
|
const ble::clock_accuracy_t &peerClockAccuracy
|
||||||
|
) :
|
||||||
|
status(status),
|
||||||
|
syncHandle(syncHandle),
|
||||||
|
sid(sid),
|
||||||
|
peerAddressType(peerAddressType),
|
||||||
|
peerAddress(peerAddress),
|
||||||
|
peerPhy(peerPhy),
|
||||||
|
advertisingInterval(advertisingInterval),
|
||||||
|
peerClockAccuracy(peerClockAccuracy) { }
|
||||||
|
|
||||||
|
/** Get sync establishment status. */
|
||||||
|
ble_error_t getStatus() const {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get periodic advertising sync handle. */
|
||||||
|
ble::periodic_sync_handle_t getSyncHandle() const {
|
||||||
|
return syncHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get advertising set identifier. */
|
||||||
|
ble::advertising_sid_t getSid() const {
|
||||||
|
return sid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get peer address type. */
|
||||||
|
const ble::peer_address_type_t &getPeerAddressType() const {
|
||||||
|
return peerAddressType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get peer address. */
|
||||||
|
const ble::address_t &getPeerAddress() const {
|
||||||
|
return peerAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get PHY used. */
|
||||||
|
const ble::phy_t &getPeerPhy() const {
|
||||||
|
return peerPhy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get interval. */
|
||||||
|
uint16_t getAdvertisingInterval() const {
|
||||||
|
return advertisingInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get clock accuracy in parts per million. */
|
||||||
|
const ble::clock_accuracy_t &getPeerClockAccuracy() const {
|
||||||
|
return peerClockAccuracy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ble_error_t status;
|
||||||
|
ble::periodic_sync_handle_t syncHandle;
|
||||||
|
ble::advertising_sid_t sid;
|
||||||
|
ble::peer_address_type_t peerAddressType;
|
||||||
|
const ble::address_t& peerAddress;
|
||||||
|
ble::phy_t peerPhy;
|
||||||
|
uint16_t advertisingInterval;
|
||||||
|
ble::clock_accuracy_t peerClockAccuracy;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Event generated when periodic advertising packet is received.
|
||||||
|
*/
|
||||||
|
struct PeriodicAdvertisingReportEvent {
|
||||||
|
/** Create periodic advertising report event.
|
||||||
|
*
|
||||||
|
* @param syncHandle Periodic advertising sync handle
|
||||||
|
* @param txPower TX power.
|
||||||
|
* @param rssi Received signal strength.
|
||||||
|
* @param dataStatus Status to indicate the completeness of the payload.
|
||||||
|
* @param payload Periodic advertisement payload.
|
||||||
|
*/
|
||||||
|
PeriodicAdvertisingReportEvent(
|
||||||
|
ble::periodic_sync_handle_t syncHandle,
|
||||||
|
ble::advertising_power_t txPower,
|
||||||
|
ble::rssi_t rssi,
|
||||||
|
ble::advertising_data_status_t dataStatus,
|
||||||
|
const mbed::Span<const uint8_t> &payload
|
||||||
|
) :
|
||||||
|
syncHandle(syncHandle),
|
||||||
|
txPower(txPower),
|
||||||
|
rssi(rssi),
|
||||||
|
dataStatus(dataStatus),
|
||||||
|
payload(payload) { }
|
||||||
|
|
||||||
|
/** Get periodic advertising sync handle. */
|
||||||
|
ble::periodic_sync_handle_t getSyncHandle() const {
|
||||||
|
return syncHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get TX power as reported by the advertising packet. */
|
||||||
|
ble::advertising_power_t getTxPower() const {
|
||||||
|
return txPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get received signal strength. */
|
||||||
|
ble::rssi_t getRssi() const {
|
||||||
|
return rssi;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get data completeness status. */
|
||||||
|
const ble::advertising_data_status_t &getDataStatus() const {
|
||||||
|
return dataStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get payload. */
|
||||||
|
const mbed::Span<const uint8_t> &getPayload() const {
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ble::periodic_sync_handle_t syncHandle;
|
||||||
|
ble::advertising_power_t txPower;
|
||||||
|
ble::rssi_t rssi;
|
||||||
|
ble::advertising_data_status_t dataStatus;
|
||||||
|
mbed::Span<const uint8_t> payload;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Event generated when periodic advertising sync is lost.
|
||||||
|
*/
|
||||||
|
struct PeriodicAdvertisingSyncLoss {
|
||||||
|
/** Create periodic advertising sync loss event.
|
||||||
|
*
|
||||||
|
* @param syncHandle Periodic advertising sync handle.
|
||||||
|
*/
|
||||||
|
PeriodicAdvertisingSyncLoss(
|
||||||
|
ble::periodic_sync_handle_t syncHandle
|
||||||
|
) :
|
||||||
|
syncHandle(syncHandle) { }
|
||||||
|
|
||||||
|
/** Get periodic sync handle. */
|
||||||
|
ble::periodic_sync_handle_t getSyncHandle() const {
|
||||||
|
return syncHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ble::periodic_sync_handle_t syncHandle;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Event generated when scan times out.
|
||||||
|
*/
|
||||||
|
struct ScanTimeoutEvent { };
|
||||||
|
|
||||||
|
/** Event produced when advertising ends.
|
||||||
|
*/
|
||||||
|
struct AdvertisingEndEvent_t {
|
||||||
|
/** Create advertising end event.
|
||||||
|
*
|
||||||
|
* @param advHandle Advertising set handle.
|
||||||
|
* @param connection Connection handle.
|
||||||
|
* @param completed_events Number of events created during before advertising end.
|
||||||
|
* @param connected True if connection has been established.
|
||||||
|
*/
|
||||||
|
AdvertisingEndEvent_t(
|
||||||
|
ble::advertising_handle_t advHandle,
|
||||||
|
ble::connection_handle_t connection,
|
||||||
|
uint8_t completed_events,
|
||||||
|
bool connected
|
||||||
|
) :
|
||||||
|
advHandle(advHandle),
|
||||||
|
connection(connection),
|
||||||
|
completed_events(completed_events),
|
||||||
|
connected(connected) { }
|
||||||
|
|
||||||
|
/** Get advertising handle. */
|
||||||
|
ble::advertising_handle_t getAdvHandle() const {
|
||||||
|
return advHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get connection handle (valid only if connected successfully). */
|
||||||
|
ble::connection_handle_t getConnection() const {
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get how many events advertising created. */
|
||||||
|
uint8_t getCompleted_events() const {
|
||||||
|
return completed_events;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Has the advertising ended with a connection. */
|
||||||
|
bool isConnected() const {
|
||||||
|
return connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ble::advertising_handle_t advHandle;
|
||||||
|
ble::connection_handle_t connection;
|
||||||
|
uint8_t completed_events;
|
||||||
|
bool connected;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Event produced when a peer requests a scan response from the advertiser.
|
||||||
|
*/
|
||||||
|
struct ScanRequestEvent_t {
|
||||||
|
/** Create scan request event.
|
||||||
|
*
|
||||||
|
* @param advHandle Advertising handle.
|
||||||
|
* @param peerAddressType Peer address type.
|
||||||
|
* @param peerAddress Peer address.
|
||||||
|
*/
|
||||||
|
ScanRequestEvent_t(
|
||||||
|
ble::advertising_handle_t advHandle,
|
||||||
|
const ble::peer_address_type_t &peerAddressType,
|
||||||
|
const ble::address_t &peerAddress
|
||||||
|
) :
|
||||||
|
advHandle(advHandle),
|
||||||
|
peerAddressType(peerAddressType),
|
||||||
|
peerAddress(peerAddress) { }
|
||||||
|
|
||||||
|
/** Get advertising handle. */
|
||||||
|
ble::advertising_handle_t getAdvHandle() const {
|
||||||
|
return advHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get peer address type. */
|
||||||
|
const ble::peer_address_type_t &getPeerAddressType() const {
|
||||||
|
return peerAddressType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get peer address. */
|
||||||
|
const ble::address_t &getPeerAddress() const {
|
||||||
|
return peerAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ble::advertising_handle_t advHandle;
|
||||||
|
ble::peer_address_type_t peerAddressType;
|
||||||
|
const ble::address_t &peerAddress;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //BLE_GAP_EVENTS_H
|
|
@ -1227,7 +1227,7 @@ void GenericGap::on_scan_timeout()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventHandler->onScanTimeout(::Gap::EventHandler::ScanTimeoutEvent());
|
_eventHandler->onScanTimeout(ScanTimeoutEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericGap::process_scan_timeout()
|
void GenericGap::process_scan_timeout()
|
||||||
|
@ -2190,10 +2190,10 @@ void GenericGap::on_enhanced_connection_complete(
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventHandler->onConnectionComplete(
|
_eventHandler->onConnectionComplete(
|
||||||
Gap::EventHandler::ConnectionCompleteEvent(
|
ConnectionCompleteEvent(
|
||||||
(status == pal::hci_error_code_t::SUCCESS) ? BLE_ERROR_NONE : BLE_ERROR_INTERNAL_STACK_FAILURE,
|
(status == pal::hci_error_code_t::SUCCESS) ? BLE_ERROR_NONE : BLE_ERROR_INTERNAL_STACK_FAILURE,
|
||||||
(ble::connection_handle_t)connection_handle,
|
(ble::connection_handle_t)connection_handle,
|
||||||
(Gap::Role_t)own_role.value(),
|
own_role,
|
||||||
(ble::peer_address_type_t::type)peer_address_type.value(),
|
(ble::peer_address_type_t::type)peer_address_type.value(),
|
||||||
peer_address,
|
peer_address,
|
||||||
local_resolvable_private_address,
|
local_resolvable_private_address,
|
||||||
|
@ -2227,7 +2227,7 @@ void GenericGap::on_extended_advertising_report(
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventHandler->onAdvertisingReport(
|
_eventHandler->onAdvertisingReport(
|
||||||
::Gap::EventHandler::AdvertisingReportEvent(
|
AdvertisingReportEvent(
|
||||||
event_type,
|
event_type,
|
||||||
(PeerAddressType_t::type)(address_type ? address_type->value() : PeerAddressType_t::ANONYMOUS),
|
(PeerAddressType_t::type)(address_type ? address_type->value() : PeerAddressType_t::ANONYMOUS),
|
||||||
(BLEProtocol::AddressBytes_t&)address,
|
(BLEProtocol::AddressBytes_t&)address,
|
||||||
|
@ -2260,7 +2260,7 @@ void GenericGap::on_periodic_advertising_sync_established(
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventHandler->onPeriodicAdvertisingSyncEstablished(
|
_eventHandler->onPeriodicAdvertisingSyncEstablished(
|
||||||
::Gap::EventHandler::PeriodicAdvertisingSyncEstablishedEvent(
|
PeriodicAdvertisingSyncEstablishedEvent(
|
||||||
(error == pal::hci_error_code_t::SUCCESS) ? BLE_ERROR_NONE : BLE_ERROR_INTERNAL_STACK_FAILURE,
|
(error == pal::hci_error_code_t::SUCCESS) ? BLE_ERROR_NONE : BLE_ERROR_INTERNAL_STACK_FAILURE,
|
||||||
sync_handle,
|
sync_handle,
|
||||||
advertising_sid,
|
advertising_sid,
|
||||||
|
@ -2288,7 +2288,7 @@ void GenericGap::on_periodic_advertising_report(
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventHandler->onPeriodicAdvertisingReportEvent(
|
_eventHandler->onPeriodicAdvertisingReportEvent(
|
||||||
::Gap::EventHandler::PeriodicAdvertisingReportEvent(
|
PeriodicAdvertisingReportEvent(
|
||||||
sync_handle,
|
sync_handle,
|
||||||
tx_power,
|
tx_power,
|
||||||
rssi,
|
rssi,
|
||||||
|
@ -2305,7 +2305,7 @@ void GenericGap::on_periodic_advertising_sync_loss(pal::sync_handle_t sync_handl
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventHandler->onPeriodicAdvertisingSyncLoss(
|
_eventHandler->onPeriodicAdvertisingSyncLoss(
|
||||||
::Gap::EventHandler::PeriodicAdvertisingSyncLoss(sync_handle)
|
PeriodicAdvertisingSyncLoss(sync_handle)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2323,7 +2323,7 @@ void GenericGap::on_advertising_set_terminated(
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventHandler->onAdvertisingEnd(
|
_eventHandler->onAdvertisingEnd(
|
||||||
::Gap::EventHandler::AdvertisingEndEvent_t(
|
AdvertisingEndEvent_t(
|
||||||
advertising_handle,
|
advertising_handle,
|
||||||
connection_handle,
|
connection_handle,
|
||||||
number_of_completed_extended_advertising_events,
|
number_of_completed_extended_advertising_events,
|
||||||
|
@ -2343,7 +2343,7 @@ void GenericGap::on_scan_request_received(
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventHandler->onScanRequest(
|
_eventHandler->onScanRequest(
|
||||||
::Gap::EventHandler::ScanRequestEvent_t(
|
ScanRequestEvent_t(
|
||||||
advertising_handle,
|
advertising_handle,
|
||||||
(ble::peer_address_type_t::type) scanner_address_type.value(),
|
(ble::peer_address_type_t::type) scanner_address_type.value(),
|
||||||
address
|
address
|
||||||
|
|
Loading…
Reference in New Issue