Direct-BT v3.2.3-1-g688f983
Direct-BT - Direct Bluetooth Programming.
Public Member Functions | Static Public Member Functions | List of all members
direct_bt::AdapterStatusListener Class Reference

BTAdapter status listener for remote BTDevice discovery events: Added, updated and removed; as well as for certain BTAdapter events. More...

#include <BTAdapter.hpp>

Inheritance diagram for direct_bt::AdapterStatusListener:
Collaboration diagram for direct_bt::AdapterStatusListener:

Public Member Functions

 ~AdapterStatusListener () noexcept override=default
 
virtual void adapterSettingsChanged (BTAdapter &adapter, const AdapterSetting oldmask, const AdapterSetting newmask, const AdapterSetting changedmask, const uint64_t timestamp)
 BTAdapter setting(s) changed. More...
 
virtual void deviceConnected (const BTDeviceRef &device, const bool discovered, const uint64_t timestamp)
 Remote BTDevice got connected. More...
 
virtual void deviceDisconnected (const BTDeviceRef &device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp)
 Remote BTDevice got disconnected. More...
 
virtual bool deviceFound (const BTDeviceRef &device, const uint64_t timestamp)
 A remote BTDevice has been newly discovered. More...
 
virtual void devicePairingState (const BTDeviceRef &device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp)
 An already connected remote BTDevice's SMPPairingState has changed. More...
 
virtual void deviceReady (const BTDeviceRef &device, const uint64_t timestamp)
 Remote BTDevice is ready for user (GATT) processing, i.e. More...
 
virtual void deviceUpdated (const BTDeviceRef &device, const EIRDataType updateMask, const uint64_t timestamp)
 An already discovered remote BTDevice has been updated. More...
 
virtual void discoveringChanged (BTAdapter &adapter, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const DiscoveryPolicy policy, const uint64_t timestamp)
 BTAdapter's discovery state has changed, i.e. More...
 
std::string get_java_class () const noexcept override
 
bool operator!= (const AdapterStatusListener &rhs) const
 
virtual bool operator== (const AdapterStatusListener &rhs) const
 Default comparison operator, merely testing for same memory reference. More...
 
std::string toString () const noexcept override
 

Static Public Member Functions

static std::string java_class () noexcept
 

Detailed Description

BTAdapter status listener for remote BTDevice discovery events: Added, updated and removed; as well as for certain BTAdapter events.

User implementations shall return as early as possible to avoid blocking the event-handler thread, if not specified within the methods otherwise (see AdapterStatusListener::deviceReady()).
Especially complex mutable operations on BTDevice or BTAdapter should be issued off-thread!

A listener instance may be attached to a BTAdapter via BTAdapter::addStatusListener(const AdapterStatusListenerRef&).

The listener receiver maintains a unique set of listener instances without duplicates.

Examples
dbt_peripheral00.cpp, dbt_repeater00.cpp, and dbt_scanner10.cpp.

Definition at line 127 of file BTAdapter.hpp.

Constructor & Destructor Documentation

◆ ~AdapterStatusListener()

direct_bt::AdapterStatusListener::~AdapterStatusListener ( )
overridedefaultnoexcept

Member Function Documentation

◆ adapterSettingsChanged()

virtual void direct_bt::AdapterStatusListener::adapterSettingsChanged ( BTAdapter adapter,
const AdapterSetting  oldmask,
const AdapterSetting  newmask,
const AdapterSetting  changedmask,
const uint64_t  timestamp 
)
inlinevirtual

BTAdapter setting(s) changed.

Parameters
adapterthe adapter which settings have changed.
oldmaskthe previous settings mask. AdapterSetting::NONE indicates the initial setting notification, see BTAdapter::addStatusListener().
newmaskthe new settings mask
changedmaskthe changes settings mask. AdapterSetting::NONE indicates the initial setting notification, see BTAdapter::addStatusListener().
timestampthe time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().

Reimplemented in JNIAdapterStatusListener.

Definition at line 137 of file BTAdapter.hpp.

◆ discoveringChanged()

virtual void direct_bt::AdapterStatusListener::discoveringChanged ( BTAdapter adapter,
const ScanType  currentMeta,
const ScanType  changedType,
const bool  changedEnabled,
const DiscoveryPolicy  policy,
const uint64_t  timestamp 
)
inlinevirtual

BTAdapter's discovery state has changed, i.e.

enabled or disabled.

Parameters
adapterthe adapter which discovering state has changed.
currentMetathe current meta ScanType
changedTypedenotes the changed native ScanType
changedEnableddenotes whether the changed native ScanType has been enabled or disabled
policythe current DiscoveryPolicy of the BTAdapter, chosen via BTAdapter::startDiscovery()
timestampthe time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().

changeScanType(const ScanType current, const bool enable, const ScanType enableChanged) noexcept {

Reimplemented in JNIAdapterStatusListener.

Definition at line 157 of file BTAdapter.hpp.

◆ deviceFound()

virtual bool direct_bt::AdapterStatusListener::deviceFound ( const BTDeviceRef device,
const uint64_t  timestamp 
)
inlinevirtual

A remote BTDevice has been newly discovered.

The boolean return value informs the adapter whether the device shall be made persistent for connection true, or that it can be discarded false.
If no registered AdapterStatusListener::deviceFound() implementation returns true, the device instance will be removed from all internal lists and can no longer being used.
If any registered AdapterStatusListener::deviceFound() implementation returns true, the device will be made persistent, is ready to connect and BTDevice::remove() shall be called after usage.

BTDevice::unpair() has been called already.

Parameters
devicethe found remote device
timestampthe time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
Returns
true if the device shall be made persistent and BTDevice::remove() issued later. Otherwise false to remove device right away.
See also
BTDevice::unpair()
BTDevice::getEIR()

Reimplemented in JNIAdapterStatusListener.

Definition at line 185 of file BTAdapter.hpp.

◆ deviceUpdated()

virtual void direct_bt::AdapterStatusListener::deviceUpdated ( const BTDeviceRef device,
const EIRDataType  updateMask,
const uint64_t  timestamp 
)
inlinevirtual

An already discovered remote BTDevice has been updated.

Parameters
devicethe updated remote device
updateMaskthe update mask of changed data
timestampthe time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
See also
BTDevice::getEIR()

Reimplemented in JNIAdapterStatusListener.

Definition at line 199 of file BTAdapter.hpp.

◆ deviceConnected()

virtual void direct_bt::AdapterStatusListener::deviceConnected ( const BTDeviceRef device,
const bool  discovered,
const uint64_t  timestamp 
)
inlinevirtual

Remote BTDevice got connected.

If a BTRole::Master BTDevice gets connected, BTDevice::unpair() has been called already.

Parameters
devicethe remote device which has been connected, holding the new connection handle.
discoveredtrue if discovered before connected and deviceFound() has been sent (default), otherwise false.
timestampthe time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
See also
BTDevice::unpair()
Since
2.6.6

Reimplemented in JNIAdapterStatusListener.

Definition at line 216 of file BTAdapter.hpp.

◆ devicePairingState()

virtual void direct_bt::AdapterStatusListener::devicePairingState ( const BTDeviceRef device,
const SMPPairingState  state,
const PairingMode  mode,
const uint64_t  timestamp 
)
inlinevirtual

An already connected remote BTDevice's SMPPairingState has changed.

Parameters
devicethe remote device which PairingMode has been changed.
statethe current SMPPairingState of the connected device, see BTDevice::getCurrentPairingState()
modethe current PairingMode of the connected device, see BTDevice::getCurrentPairingMode()
timestampthe time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
See also
BTDevice::setPairingPasskey()
BTDevice::setPairingNumericComparison()

Reimplemented in JNIAdapterStatusListener.

Definition at line 231 of file BTAdapter.hpp.

◆ deviceReady()

virtual void direct_bt::AdapterStatusListener::deviceReady ( const BTDeviceRef device,
const uint64_t  timestamp 
)
inlinevirtual

Remote BTDevice is ready for user (GATT) processing, i.e.

already connected, optionally (SMP) paired.

In case of a LE connection to a remote BTDevice in BTRole::Slave, a GATT server (GATTRole::Server), user needs to call BTDevice::getGattServices() to have GATT MTU size negotiated and GATT services discovered.

Method is being called from a dedicated native thread, hence restrictions on method duration and complex mutable operations don't apply here.

Parameters
devicethe remote device ready to use
timestampthe time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
See also
SMPPairingState::COMPLETED
BTDevice::getGattServices()

Reimplemented in JNIAdapterStatusListener.

Definition at line 251 of file BTAdapter.hpp.

◆ deviceDisconnected()

virtual void direct_bt::AdapterStatusListener::deviceDisconnected ( const BTDeviceRef device,
const HCIStatusCode  reason,
const uint16_t  handle,
const uint64_t  timestamp 
)
inlinevirtual

Remote BTDevice got disconnected.

BTDevice::unpair() has been called already.

Parameters
devicethe remote device which has been disconnected with zeroed connection handle.
reasonthe HCIStatusCode reason for disconnection
handlethe disconnected connection handle, which has been unassigned from the device already
timestampthe time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
See also
BTDevice::unpair()

Reimplemented in JNIAdapterStatusListener.

Definition at line 267 of file BTAdapter.hpp.

◆ toString()

std::string direct_bt::AdapterStatusListener::toString ( ) const
inlineoverridevirtualnoexcept

Reimplemented from jau::jni::JavaUplink.

Reimplemented in JNIAdapterStatusListener.

Definition at line 276 of file BTAdapter.hpp.

◆ get_java_class()

std::string direct_bt::AdapterStatusListener::get_java_class ( ) const
inlineoverridevirtualnoexcept

Implements jau::jni::JavaUplink.

Definition at line 278 of file BTAdapter.hpp.

◆ java_class()

static std::string direct_bt::AdapterStatusListener::java_class ( )
inlinestaticnoexcept

Definition at line 281 of file BTAdapter.hpp.

Here is the caller graph for this function:

◆ operator==()

virtual bool direct_bt::AdapterStatusListener::operator== ( const AdapterStatusListener rhs) const
inlinevirtual

Default comparison operator, merely testing for same memory reference.

Specializations may override.

Definition at line 291 of file BTAdapter.hpp.

◆ operator!=()

bool direct_bt::AdapterStatusListener::operator!= ( const AdapterStatusListener rhs) const
inline

Definition at line 294 of file BTAdapter.hpp.


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