Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
direct_bt::BTAdapter Class Reference

BTAdapter represents one Bluetooth Controller. More...

#include <BTAdapter.hpp>

Inheritance diagram for direct_bt::BTAdapter:
Collaboration diagram for direct_bt::BTAdapter:

Public Member Functions

 BTAdapter (const BTAdapter::ctor_cookie &cc, BTManager &mgmt_, const AdapterInfo &adapterInfo_) noexcept
 Private ctor for private BTAdapter::make_shared() intended for friends. More...
 
 BTAdapter (const BTAdapter &)=delete
 
void operator= (const BTAdapter &)=delete
 
 ~BTAdapter () noexcept
 Releases this instance. More...
 
void close () noexcept
 Closes this instance, usually being called by destructor or when this adapter is being removed as recognized and handled by BTManager. More...
 
std::string get_java_class () const noexcept override
 
bool isPowered () const noexcept
 Returns whether the adapter is valid, plugged in and powered. More...
 
bool isSuspended () const noexcept
 Returns whether the adapter is suspended, i.e. More...
 
bool hasSecureConnections () const noexcept
 
bool hasSecureSimplePairing () const noexcept
 
constexpr LE_Features getLEFeatures () const noexcept
 Return LE_Features for this controller. More...
 
constexpr bool hasHCIExtScan () const noexcept
 Returns true if HCI_LE_Set_Extended_Scan_Parameters and HCI_LE_Set_Extended_Scan_Enable is supported (Bluetooth 5.0). More...
 
constexpr bool hasHCIExtConn () const noexcept
 Returns true if HCI_LE_Extended_Create_Connection is supported (Bluetooth 5.0). More...
 
bool isValid () const noexcept
 Returns whether the adapter is valid, i.e. More...
 
BTMode getBTMode () const noexcept
 Returns the current BTMode of this adapter. More...
 
BDAddressAndType const & getAddressAndType () const noexcept
 Returns the adapter's public BDAddressAndType. More...
 
BDAddressAndType const & getVisibleAddressAndType () const noexcept
 Returns the adapter's currently visible BDAddressAndType. More...
 
std::string getName () const noexcept
 Returns the system name. More...
 
std::string getShortName () const noexcept
 Returns the short system name. More...
 
const NameAndShortNamegetLocalName () const noexcept
 Returns the local friendly name and short_name. More...
 
std::shared_ptr< NameAndShortNamesetLocalName (const std::string &name, const std::string &short_name) noexcept
 Sets the local friendly name. More...
 
bool setDiscoverable (bool value) noexcept
 Set the discoverable state of the adapter. More...
 
bool setBondable (bool value) noexcept
 Set the bondable (aka pairable) state of the adapter. More...
 
bool setPowered (bool value) noexcept
 Set the power state of the adapter. More...
 
HCIStatusCode reset () noexcept
 Reset the adapter. More...
 
BTManagergetManager () const noexcept
 Returns a reference to the used singleton BTManager instance, used to create this adapter. More...
 
HCIHandlergetHCI () noexcept
 Returns a reference to the aggregated HCIHandler instance. More...
 
bool isDeviceWhitelisted (const BDAddressAndType &addressAndType) noexcept
 Returns true, if the adapter's device is already whitelisted. More...
 
bool addDeviceToWhitelist (const BDAddressAndType &addressAndType, const HCIWhitelistConnectType ctype, const uint16_t conn_interval_min=12, const uint16_t conn_interval_max=12, const uint16_t conn_latency=0, const uint16_t supervision_timeout=getHCIConnSupervisorTimeout(0, 15))
 Add the given device to the adapter's autoconnect whitelist. More...
 
bool removeDeviceFromWhitelist (const BDAddressAndType &addressAndType)
 Remove the given device from the adapter's autoconnect whitelist. More...
 
bool addStatusListener (std::shared_ptr< AdapterStatusListener > l)
 Add the given listener to the list if not already present. More...
 
bool addStatusListener (const BTDevice &d, std::shared_ptr< AdapterStatusListener > l)
 Please use BTDevice::addStatusListener() for clarity, merely existing here to allow JNI access. More...
 
bool removeStatusListener (std::shared_ptr< AdapterStatusListener > l)
 Remove the given listener from the list. More...
 
bool removeStatusListener (const AdapterStatusListener *l)
 Remove the given listener from the list. More...
 
int removeAllStatusListener ()
 Remove all status listener from the list. More...
 
HCIStatusCode startDiscovery (const bool keepAlive=true, const bool le_scan_active=false, const uint16_t le_scan_interval=24, const uint16_t le_scan_window=24, const uint8_t filter_policy=0x00)
 Starts a new discovery session. More...
 
HCIStatusCode stopDiscovery () noexcept
 Closes the discovery session. More...
 
ScanType getCurrentScanType () const noexcept
 Returns the current meta discovering ScanType. More...
 
ScanType getCurrentNativeScanType () const noexcept
 Returns the adapter's current native discovering ScanType. More...
 
bool getDiscovering () const noexcept
 Returns the meta discovering state. More...
 
jau::darray< std::shared_ptr< BTDevice > > getDiscoveredDevices () const noexcept
 Returns discovered devices from the last discovery. More...
 
int removeDiscoveredDevices () noexcept
 Discards all discovered devices. More...
 
bool removeDiscoveredDevice (const BDAddressAndType &addressAndType) noexcept
 Discards matching discovered devices. More...
 
std::shared_ptr< BTDevicefindDiscoveredDevice (const EUI48 &address, const BDAddressType addressType) noexcept
 Returns shared BTDevice if found, otherwise nullptr. More...
 
std::shared_ptr< BTDevicefindSharedDevice (const EUI48 &address, const BDAddressType addressType) noexcept
 Returns shared BTDevice if found, otherwise nullptr. More...
 
std::string toString () const noexcept override
 
std::string toString (bool includeDiscoveredDevices) const noexcept
 
void printDeviceLists () noexcept
 Print the internally maintained BTDevice lists to stderr: More...
 
void printStatusListenerList () noexcept
 
- Public Member Functions inherited from direct_bt::BTObject
virtual ~BTObject () noexcept
 
bool isValid () const noexcept
 Returns whether the object's reference is valid and in a general operational state. More...
 

Static Public Member Functions

static std::string java_class () noexcept
 

Public Attributes

const uint16_t dev_id
 Adapter's internal temporary device id. More...
 

Friends

std::shared_ptr< BTDeviceBTDevice::getSharedInstance () const noexcept
 
void BTDevice::remove () noexcept
 
std::shared_ptr< ConnectionInfoBTDevice::getConnectionInfo () noexcept
 
void BTDevice::sendMgmtEvDeviceDisconnected (std::unique_ptr< MgmtEvent > evt) noexcept
 
HCIStatusCode BTDevice::disconnect (const HCIStatusCode reason) noexcept
 
HCIStatusCode BTDevice::connectLE (uint16_t interval, uint16_t window, uint16_t min_interval, uint16_t max_interval, uint16_t latency, uint16_t supervision_timeout) noexcept
 
HCIStatusCode BTDevice::connectBREDR (const uint16_t pkt_type, const uint16_t clock_offset, const uint8_t role_switch) noexcept
 
void BTDevice::processL2CAPSetup (std::shared_ptr< BTDevice > sthis)
 
bool BTDevice::updatePairingState (std::shared_ptr< BTDevice > sthis, const MgmtEvent &evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept
 
void BTDevice::hciSMPMsgCallback (std::shared_ptr< BTDevice > sthis, const SMPPDUMsg &msg, const HCIACLData::l2cap_frame &source) noexcept
 
void BTDevice::processDeviceReady (std::shared_ptr< BTDevice > sthis, const uint64_t timestamp)
 
jau::darray< std::shared_ptr< BTGattService > > BTDevice::getGattServices () noexcept
 

Additional Inherited Members

- Protected Member Functions inherited from direct_bt::BTObject
 BTObject () noexcept
 
- Protected Attributes inherited from direct_bt::BTObject
std::atomic_bool valid
 

Detailed Description

BTAdapter represents one Bluetooth Controller.

Controlling Environment variables:

  • 'direct_bt.debug.adapter.event': Debug messages about events, see debug_events
Examples
dbt_scanner00.cpp, dbt_scanner01.cpp, and dbt_scanner10.cpp.

Definition at line 249 of file BTAdapter.hpp.

Constructor & Destructor Documentation

◆ BTAdapter() [1/2]

BTAdapter::BTAdapter ( const BTAdapter::ctor_cookie &  cc,
BTManager mgmt_,
const AdapterInfo adapterInfo_ 
)
noexcept

Private ctor for private BTAdapter::make_shared() intended for friends.

Definition at line 224 of file BTAdapter.cpp.

◆ BTAdapter() [2/2]

direct_bt::BTAdapter::BTAdapter ( const BTAdapter )
delete

◆ ~BTAdapter()

BTAdapter::~BTAdapter ( )
noexcept

Releases this instance.

Definition at line 238 of file BTAdapter.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addDeviceToWhitelist()

bool BTAdapter::addDeviceToWhitelist ( const BDAddressAndType addressAndType,
const HCIWhitelistConnectType  ctype,
const uint16_t  conn_interval_min = 12,
const uint16_t  conn_interval_max = 12,
const uint16_t  conn_latency = 0,
const uint16_t  supervision_timeout = getHCIConnSupervisorTimeout(0, 15) 
)

Add the given device to the adapter's autoconnect whitelist.

The given connection parameter will be uploaded to the kernel for the given device first.

Method will reject duplicate devices, in which case it should be removed first.

Parameters
address
address_type
ctype
conn_interval_minin units of 1.25ms, default value 12 for 15ms; Value range [6 .. 3200] for [7.5ms .. 4000ms]
conn_interval_maxin units of 1.25ms, default value 12 for 15ms; Value range [6 .. 3200] for [7.5ms .. 4000ms]
conn_latencyslave latency in units of connection events, default value 0; Value range [0 .. 0x01F3].
supervision_timeoutin units of 10ms, default value >= 10 x conn_interval_max, we use HCIConstInt::LE_CONN_MIN_TIMEOUT_MS minimum; Value range [0xA-0x0C80] for [100ms - 32s].
Returns
true if the device was already added or has been newly added to the adapter's whitelist.
Examples
dbt_scanner10.cpp.

Definition at line 522 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addStatusListener() [1/2]

bool BTAdapter::addStatusListener ( const BTDevice d,
std::shared_ptr< AdapterStatusListener l 
)

Please use BTDevice::addStatusListener() for clarity, merely existing here to allow JNI access.

Definition at line 564 of file BTAdapter.cpp.

Here is the call graph for this function:

◆ addStatusListener() [2/2]

bool BTAdapter::addStatusListener ( std::shared_ptr< AdapterStatusListener l)

Add the given listener to the list if not already present.

In case the AdapterStatusListener's lifecycle and event delivery shall be constrained to this device, please use BTDevice::addStatusListener().

Returns true if the given listener is not element of the list and has been newly added, otherwise false.

The newly added AdapterStatusListener will receive an initial AdapterStatusListener::adapterSettingsChanged(..) event, passing an empty AdapterSetting::NONE oldMask and changedMask, as well as current AdapterSetting newMask.
This allows the receiver to be aware of this adapter's current settings.

See also
BTDevice::addStatusListener()
removeStatusListener()
removeAllStatusListener()
Examples
dbt_scanner00.cpp, dbt_scanner01.cpp, and dbt_scanner10.cpp.

Definition at line 548 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ close()

void BTAdapter::close ( )
noexcept

Closes this instance, usually being called by destructor or when this adapter is being removed as recognized and handled by BTManager.

Renders this adapter's BTAdapter::isValid() state to false.

Definition at line 252 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findDiscoveredDevice()

std::shared_ptr< BTDevice > BTAdapter::findDiscoveredDevice ( const EUI48 address,
const BDAddressType  addressType 
)
noexcept

Returns shared BTDevice if found, otherwise nullptr.

Definition at line 843 of file BTAdapter.cpp.

Here is the caller graph for this function:

◆ findSharedDevice()

std::shared_ptr< BTDevice > BTAdapter::findSharedDevice ( const EUI48 address,
const BDAddressType  addressType 
)
noexcept

Returns shared BTDevice if found, otherwise nullptr.

Definition at line 934 of file BTAdapter.cpp.

Here is the caller graph for this function:

◆ get_java_class()

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

Implements jau::JavaUplink.

Definition at line 424 of file BTAdapter.hpp.

Here is the call graph for this function:

◆ getAddressAndType()

BDAddressAndType const& direct_bt::BTAdapter::getAddressAndType ( ) const
inlinenoexcept

Returns the adapter's public BDAddressAndType.

The adapter's address as initially reported by the system is always its public address, i.e. BDAddressType::BDADDR_LE_PUBLIC.

Since
2.2.8
See also
getVisibleAddressAndType()

Definition at line 497 of file BTAdapter.hpp.

Here is the caller graph for this function:

◆ getBTMode()

BTMode direct_bt::BTAdapter::getBTMode ( ) const
inlinenoexcept

Returns the current BTMode of this adapter.

Definition at line 487 of file BTAdapter.hpp.

Here is the call graph for this function:

◆ getCurrentNativeScanType()

ScanType direct_bt::BTAdapter::getCurrentNativeScanType ( ) const
inlinenoexcept

Returns the adapter's current native discovering ScanType.

It can be modified through startDiscovery(..) and stopDiscovery().

See also
startDiscovery()
stopDiscovery()

Definition at line 747 of file BTAdapter.hpp.

Here is the call graph for this function:

◆ getCurrentScanType()

ScanType direct_bt::BTAdapter::getCurrentScanType ( ) const
inlinenoexcept

Returns the current meta discovering ScanType.

It can be modified through startDiscovery(..) and stopDiscovery().

Note that if startDiscovery(..) has been issued with keepAlive==true, the meta ScanType will still keep the desired ScanType enabled even if it has been temporarily disabled.

See also
startDiscovery()
stopDiscovery()

Definition at line 738 of file BTAdapter.hpp.

◆ getDiscoveredDevices()

jau::darray< std::shared_ptr< BTDevice > > BTAdapter::getDiscoveredDevices ( ) const
noexcept

Returns discovered devices from the last discovery.

Note that this list will be cleared when a new discovery is started over via startDiscovery().

Note that devices in this list might be no more available, use 'DeviceStatusListener::deviceFound(..)' callback.

Definition at line 901 of file BTAdapter.cpp.

Here is the caller graph for this function:

◆ getDiscovering()

bool direct_bt::BTAdapter::getDiscovering ( ) const
inlinenoexcept

Returns the meta discovering state.

It can be modified through startDiscovery(..) and stopDiscovery().

See also
startDiscovery()
stopDiscovery()

Definition at line 756 of file BTAdapter.hpp.

◆ getHCI()

HCIHandler& direct_bt::BTAdapter::getHCI ( )
inlinenoexcept

Returns a reference to the aggregated HCIHandler instance.

Definition at line 575 of file BTAdapter.hpp.

Here is the caller graph for this function:

◆ getLEFeatures()

constexpr LE_Features direct_bt::BTAdapter::getLEFeatures ( ) const
inlineconstexprnoexcept

Return LE_Features for this controller.

BT Core Spec v5.2: Vol 6, Part B, 4.6 (LE LL) Feature Support
Examples
dbt_scanner10.cpp.

Definition at line 465 of file BTAdapter.hpp.

Here is the caller graph for this function:

◆ getLocalName()

const NameAndShortName& direct_bt::BTAdapter::getLocalName ( ) const
inlinenoexcept

Returns the local friendly name and short_name.

Contains empty strings if not set.

The value is being updated via SET_LOCAL_NAME management event reply.

Definition at line 528 of file BTAdapter.hpp.

Here is the caller graph for this function:

◆ getManager()

BTManager& direct_bt::BTAdapter::getManager ( ) const
inlinenoexcept

Returns a reference to the used singleton BTManager instance, used to create this adapter.

Examples
dbt_scanner10.cpp.

Definition at line 570 of file BTAdapter.hpp.

Here is the caller graph for this function:

◆ getName()

std::string direct_bt::BTAdapter::getName ( ) const
inlinenoexcept

Returns the system name.

Definition at line 515 of file BTAdapter.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getShortName()

std::string direct_bt::BTAdapter::getShortName ( ) const
inlinenoexcept

Returns the short system name.

Definition at line 520 of file BTAdapter.hpp.

Here is the call graph for this function:

◆ getVisibleAddressAndType()

BDAddressAndType const& direct_bt::BTAdapter::getVisibleAddressAndType ( ) const
inlinenoexcept

Returns the adapter's currently visible BDAddressAndType.

The adapter's address as initially reported by the system is always its public address, i.e. BDAddressType::BDADDR_LE_PUBLIC.

The adapter's visible BDAddressAndType might be set to BDAddressType::BDADDR_LE_RANDOM before scanning / discovery mode (TODO).

Since
2.2.8
See also
getAddressAndType()

Definition at line 510 of file BTAdapter.hpp.

◆ hasHCIExtConn()

constexpr bool direct_bt::BTAdapter::hasHCIExtConn ( ) const
inlineconstexprnoexcept

Returns true if HCI_LE_Extended_Create_Connection is supported (Bluetooth 5.0).

Definition at line 471 of file BTAdapter.hpp.

◆ hasHCIExtScan()

constexpr bool direct_bt::BTAdapter::hasHCIExtScan ( ) const
inlineconstexprnoexcept

Returns true if HCI_LE_Set_Extended_Scan_Parameters and HCI_LE_Set_Extended_Scan_Enable is supported (Bluetooth 5.0).

Definition at line 468 of file BTAdapter.hpp.

◆ hasSecureConnections()

bool direct_bt::BTAdapter::hasSecureConnections ( ) const
inlinenoexcept

Definition at line 451 of file BTAdapter.hpp.

Here is the call graph for this function:

◆ hasSecureSimplePairing()

bool direct_bt::BTAdapter::hasSecureSimplePairing ( ) const
inlinenoexcept

Definition at line 455 of file BTAdapter.hpp.

Here is the call graph for this function:

◆ isDeviceWhitelisted()

bool BTAdapter::isDeviceWhitelisted ( const BDAddressAndType addressAndType)
noexcept

Returns true, if the adapter's device is already whitelisted.

Definition at line 518 of file BTAdapter.cpp.

Here is the caller graph for this function:

◆ isPowered()

bool direct_bt::BTAdapter::isPowered ( ) const
inlinenoexcept

Returns whether the adapter is valid, plugged in and powered.

Returns
true if BTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is set.
See also
isSuspended()
isValid()
Examples
dbt_scanner00.cpp, dbt_scanner01.cpp, and dbt_scanner10.cpp.

Definition at line 437 of file BTAdapter.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSuspended()

bool direct_bt::BTAdapter::isSuspended ( ) const
inlinenoexcept

Returns whether the adapter is suspended, i.e.

valid and plugged in, but not powered.

Returns
true if BTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is not set.
See also
isPowered()
isValid()

Definition at line 447 of file BTAdapter.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValid()

bool direct_bt::BTAdapter::isValid ( ) const
inlinenoexcept

Returns whether the adapter is valid, i.e.

reference is valid, plugged in and generally operational, but not necessarily BTAdapter::isPowered() powered.

Returns
true if this adapter references are valid and hasn't been BTAdapter::close() 'ed
See also
isPowered()
isSuspended()
Examples
dbt_scanner00.cpp, and dbt_scanner01.cpp.

Definition at line 480 of file BTAdapter.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ java_class()

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

Definition at line 427 of file BTAdapter.hpp.

Here is the caller graph for this function:

◆ operator=()

void direct_bt::BTAdapter::operator= ( const BTAdapter )
delete

◆ printDeviceLists()

void BTAdapter::printDeviceLists ( )
noexcept

Print the internally maintained BTDevice lists to stderr:

  • sharedDevices
  • connectedDevice
  • discoveredDevices
  • StatusListener

This is intended as a debug facility.

Examples
dbt_scanner10.cpp.

Definition at line 325 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printStatusListenerList()

void BTAdapter::printStatusListenerList ( )
noexcept

Definition at line 340 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeAllStatusListener()

int BTAdapter::removeAllStatusListener ( )

Remove all status listener from the list.

Returns the number of removed status listener.

Definition at line 649 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeDeviceFromWhitelist()

bool BTAdapter::removeDeviceFromWhitelist ( const BDAddressAndType addressAndType)

Remove the given device from the adapter's autoconnect whitelist.

Definition at line 541 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeDiscoveredDevice()

bool BTAdapter::removeDiscoveredDevice ( const BDAddressAndType addressAndType)
noexcept

Discards matching discovered devices.

Returns true if found and removed, otherwise false.

Definition at line 860 of file BTAdapter.cpp.

Here is the caller graph for this function:

◆ removeDiscoveredDevices()

int BTAdapter::removeDiscoveredDevices ( )
noexcept

Discards all discovered devices.

Returns number of removed discovered devices.

Examples
dbt_scanner10.cpp.

Definition at line 877 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeStatusListener() [1/2]

bool BTAdapter::removeStatusListener ( const AdapterStatusListener l)

Remove the given listener from the list.

Returns true if the given listener is an element of the list and has been removed, otherwise false.

See also
BTDevice::removeStatusListener()
addStatusListener()

Definition at line 599 of file BTAdapter.cpp.

Here is the call graph for this function:

◆ removeStatusListener() [2/2]

bool BTAdapter::removeStatusListener ( std::shared_ptr< AdapterStatusListener l)

Remove the given listener from the list.

Returns true if the given listener is an element of the list and has been removed, otherwise false.

See also
BTDevice::removeStatusListener()
addStatusListener()

Definition at line 585 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

HCIStatusCode BTAdapter::reset ( )
noexcept

Reset the adapter.

The semantics are specific to the HCI host implementation, however, it shall comply at least with the HCI Reset command and bring up the device from standby into a POWERED functional state afterwards.

BT Core Spec v5.2: Vol 4, Part E HCI: 7.3.2 Reset command
Examples
dbt_scanner10.cpp.

Definition at line 489 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBondable()

bool BTAdapter::setBondable ( bool  value)
noexcept

Set the bondable (aka pairable) state of the adapter.

Definition at line 357 of file BTAdapter.cpp.

Here is the caller graph for this function:

◆ setDiscoverable()

bool BTAdapter::setDiscoverable ( bool  value)
noexcept

Set the discoverable state of the adapter.

Definition at line 352 of file BTAdapter.cpp.

Here is the caller graph for this function:

◆ setLocalName()

std::shared_ptr< NameAndShortName > BTAdapter::setLocalName ( const std::string &  name,
const std::string &  short_name 
)
noexcept

Sets the local friendly name.

Returns the immediate SET_LOCAL_NAME reply if successful, otherwise nullptr. The corresponding management event will be received separately.

Definition at line 348 of file BTAdapter.cpp.

Here is the caller graph for this function:

◆ setPowered()

bool BTAdapter::setPowered ( bool  value)
noexcept

Set the power state of the adapter.

Definition at line 362 of file BTAdapter.cpp.

Here is the caller graph for this function:

◆ startDiscovery()

HCIStatusCode BTAdapter::startDiscovery ( const bool  keepAlive = true,
const bool  le_scan_active = false,
const uint16_t  le_scan_interval = 24,
const uint16_t  le_scan_window = 24,
const uint8_t  filter_policy = 0x00 
)

Starts a new discovery session.

Returns HCIStatusCode::SUCCESS if successful, otherwise the HCIStatusCode error state;

if keepAlive is true, discovery state will be re-enabled in case the underlying Bluetooth implementation (BlueZ, ..) disabled it. Default is true.

Using startDiscovery(keepAlive=true) and stopDiscovery() is the recommended workflow for a reliable discovery process.

+ --+-------+--------+-----------+----------------------------------------------------+
| # | meta  | native | keepAlive | Note
+---+-------+--------+-----------+----------------------------------------------------+
| 1 | true  | true   | false     | -
| 2 | false | false  | false     | -
+---+-------+--------+-----------+----------------------------------------------------+
| 3 | true  | true   | true      | -
| 4 | true  | false  | true      | temporarily disabled -> startDiscoveryBackground()
| 5 | false | false  | true      | [4] -> [5] requires manual DISCOVERING event
+---+-------+--------+-----------+----------------------------------------------------+

<p<blockquote>

Remaining default parameter values are chosen for using public address resolution and usual discovery intervals etc.

This adapter's HCIHandler instance is used to initiate scanning, see HCIHandler::le_set_scan_param() and HCIHandler::le_enable_scan().

Method will always clear previous discovered devices via removeDiscoveredDevices().

Parameters
keepAlive
le_scan_activetrue enables delivery of active scanning PDUs, otherwise no scanning PDUs shall be sent (default)
le_scan_intervalin units of 0.625ms, default value 24 for 15ms; Value range [4 .. 0x4000] for [2.5ms .. 10.24s]
le_scan_windowin units of 0.625ms, default value 24 for 15ms; Value range [4 .. 0x4000] for [2.5ms .. 10.24s]. Shall be <= le_scan_interval
filter_policy0x00 accepts all PDUs (default), 0x01 only of whitelisted, ...
Returns
HCIStatusCode::SUCCESS if successful, otherwise the HCIStatusCode error state
Examples
dbt_scanner00.cpp, dbt_scanner01.cpp, and dbt_scanner10.cpp.

Definition at line 679 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopDiscovery()

HCIStatusCode BTAdapter::stopDiscovery ( )
noexcept

Closes the discovery session.

This adapter's HCIHandler instance is used to stop scanning, see HCIHandler::le_enable_scan().

Returns
HCIStatusCode::SUCCESS if successful, otherwise the HCIStatusCode error state
Examples
dbt_scanner00.cpp, dbt_scanner01.cpp, and dbt_scanner10.cpp.

Definition at line 756 of file BTAdapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString() [1/2]

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

Reimplemented from direct_bt::BTObject.

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

Definition at line 784 of file BTAdapter.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString() [2/2]

std::string BTAdapter::toString ( bool  includeDiscoveredDevices) const
noexcept

Definition at line 956 of file BTAdapter.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ BTDevice::connectBREDR

HCIStatusCode BTDevice::connectBREDR ( const uint16_t  pkt_type,
const uint16_t  clock_offset,
const uint8_t  role_switch 
)
friend

◆ BTDevice::connectLE

HCIStatusCode BTDevice::connectLE ( uint16_t  interval,
uint16_t  window,
uint16_t  min_interval,
uint16_t  max_interval,
uint16_t  latency,
uint16_t  supervision_timeout 
)
friend

◆ BTDevice::disconnect

◆ BTDevice::getConnectionInfo

std::shared_ptr<ConnectionInfo> BTDevice::getConnectionInfo ( )
friend

◆ BTDevice::getGattServices

jau::darray<std::shared_ptr<BTGattService> > BTDevice::getGattServices ( )
friend

◆ BTDevice::getSharedInstance

std::shared_ptr<BTDevice> BTDevice::getSharedInstance ( ) const
friend

◆ BTDevice::hciSMPMsgCallback

void BTDevice::hciSMPMsgCallback ( std::shared_ptr< BTDevice sthis,
const SMPPDUMsg msg,
const HCIACLData::l2cap_frame source 
)
friend

◆ BTDevice::processDeviceReady

void BTDevice::processDeviceReady ( std::shared_ptr< BTDevice sthis,
const uint64_t  timestamp 
)
friend

◆ BTDevice::processL2CAPSetup

void BTDevice::processL2CAPSetup ( std::shared_ptr< BTDevice sthis)
friend

◆ BTDevice::remove

void BTDevice::remove ( )
friend

◆ BTDevice::sendMgmtEvDeviceDisconnected

void BTDevice::sendMgmtEvDeviceDisconnected ( std::unique_ptr< MgmtEvent evt)
friend

◆ BTDevice::updatePairingState

bool BTDevice::updatePairingState ( std::shared_ptr< BTDevice sthis,
const MgmtEvent evt,
const HCIStatusCode  evtStatus,
SMPPairingState  claimed_state 
)
friend

Member Data Documentation

◆ dev_id

const uint16_t direct_bt::BTAdapter::dev_id

Adapter's internal temporary device id.

The internal device id is constant across the adapter lifecycle, but may change after its destruction.

Definition at line 273 of file BTAdapter.hpp.


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