Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Public Member Functions | List of all members
direct_bt::AdapterStatusListener Class Referenceabstract

BTAdapter status listener for 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

virtual bool matchDevice (const BTDevice &device)
 Custom filter for all 'device*' notification methods, which will not be called if this method returns false. More...
 
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 discoveringChanged (BTAdapter &adapter, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp)
 BTAdapter's discovery state has changed, i.e. More...
 
virtual bool deviceFound (std::shared_ptr< BTDevice > device, const uint64_t timestamp)
 A BTDevice has been newly discovered. More...
 
virtual void deviceUpdated (std::shared_ptr< BTDevice > device, const EIRDataType updateMask, const uint64_t timestamp)
 An already discovered BTDevice has been updated. More...
 
virtual void deviceConnected (std::shared_ptr< BTDevice > device, const uint16_t handle, const uint64_t timestamp)
 BTDevice got connected. More...
 
virtual void devicePairingState (std::shared_ptr< BTDevice > device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp)
 An already connected BTDevice's SMPPairingState has changed. More...
 
virtual void deviceReady (std::shared_ptr< BTDevice > device, const uint64_t timestamp)
 BTDevice is ready for user (GATT) processing, i.e. More...
 
virtual void deviceDisconnected (std::shared_ptr< BTDevice > device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp)
 BTDevice got disconnected. More...
 
virtual ~AdapterStatusListener ()
 
virtual std::string toString () const =0
 
virtual bool operator== (const AdapterStatusListener &rhs) const
 Default comparison operator, merely testing for same memory reference. More...
 
bool operator!= (const AdapterStatusListener &rhs) const
 

Detailed Description

BTAdapter status listener for 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(std::shared_ptr<AdapterStatusListener>).

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

Examples
dbt_scanner00.cpp, dbt_scanner01.cpp, and dbt_scanner10.cpp.

Definition at line 67 of file BTAdapter.hpp.

Constructor & Destructor Documentation

◆ ~AdapterStatusListener()

virtual direct_bt::AdapterStatusListener::~AdapterStatusListener ( )
inlinevirtual

Definition at line 210 of file BTAdapter.hpp.

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 93 of file BTAdapter.hpp.

◆ deviceConnected()

virtual void direct_bt::AdapterStatusListener::deviceConnected ( std::shared_ptr< BTDevice device,
const uint16_t  handle,
const uint64_t  timestamp 
)
inlinevirtual

BTDevice got connected.

Parameters
devicethe device which has been connected, holding the new connection handle.
handlethe new connection handle, which has been assigned to the device already
timestampthe time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().

Reimplemented in JNIAdapterStatusListener.

Definition at line 160 of file BTAdapter.hpp.

◆ deviceDisconnected()

virtual void direct_bt::AdapterStatusListener::deviceDisconnected ( std::shared_ptr< BTDevice device,
const HCIStatusCode  reason,
const uint16_t  handle,
const uint64_t  timestamp 
)
inlinevirtual

BTDevice got disconnected.

Parameters
devicethe 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().

Reimplemented in JNIAdapterStatusListener.

Definition at line 203 of file BTAdapter.hpp.

◆ deviceFound()

virtual bool direct_bt::AdapterStatusListener::deviceFound ( std::shared_ptr< BTDevice device,
const uint64_t  timestamp 
)
inlinevirtual

A 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.

Parameters
devicethe found 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.

Reimplemented in JNIAdapterStatusListener.

Definition at line 136 of file BTAdapter.hpp.

◆ devicePairingState()

virtual void direct_bt::AdapterStatusListener::devicePairingState ( std::shared_ptr< BTDevice device,
const SMPPairingState  state,
const PairingMode  mode,
const uint64_t  timestamp 
)
inlinevirtual

An already connected BTDevice's SMPPairingState has changed.

Parameters
devicethe 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 175 of file BTAdapter.hpp.

◆ deviceReady()

virtual void direct_bt::AdapterStatusListener::deviceReady ( std::shared_ptr< BTDevice device,
const uint64_t  timestamp 
)
inlinevirtual

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

already connected, optionally paired and ATT MTU size negotiated via connected GATT.

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

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

Reimplemented in JNIAdapterStatusListener.

Definition at line 191 of file BTAdapter.hpp.

◆ deviceUpdated()

virtual void direct_bt::AdapterStatusListener::deviceUpdated ( std::shared_ptr< BTDevice device,
const EIRDataType  updateMask,
const uint64_t  timestamp 
)
inlinevirtual

An already discovered BTDevice has been updated.

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

Reimplemented in JNIAdapterStatusListener.

Definition at line 148 of file BTAdapter.hpp.

◆ discoveringChanged()

virtual void direct_bt::AdapterStatusListener::discoveringChanged ( BTAdapter adapter,
const ScanType  currentMeta,
const ScanType  changedType,
const bool  changedEnabled,
const bool  keepAlive,
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 ScanType
changedEnableddenotes whether the changed ScanType has been enabled or disabled
keepAliveif true, the denoted changed ScanType will be re-enabled if disabled by the underlying Bluetooth implementation.
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 113 of file BTAdapter.hpp.

◆ matchDevice()

virtual bool direct_bt::AdapterStatusListener::matchDevice ( const BTDevice device)
inlinevirtual

Custom filter for all 'device*' notification methods, which will not be called if this method returns false.

User may override this method to test whether the 'device*' methods shall be called for the given device.

Defaults to true;

Reimplemented in JNIAdapterStatusListener.

Definition at line 80 of file BTAdapter.hpp.

◆ operator!=()

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

Definition at line 223 of file BTAdapter.hpp.

◆ 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 220 of file BTAdapter.hpp.

◆ toString()

virtual std::string direct_bt::AdapterStatusListener::toString ( ) const
pure virtual

Implemented in JNIAdapterStatusListener.

Here is the caller graph for this function:

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