Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
|
BTAdapter represents one local Bluetooth Controller. More...
#include <BTAdapter.hpp>
Public Types | |
typedef jau::nsize_t | size_type |
Public Member Functions | |
BTAdapter (const BTAdapter &)=delete | |
BTAdapter (const BTAdapter::ctor_cookie &cc, BTManagerRef mgmt_, AdapterInfo adapterInfo_) noexcept | |
Private ctor for private BTAdapter::make_shared() intended for friends. More... | |
~BTAdapter () noexcept override | |
Releases this instance. 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 | addStatusListener (const AdapterStatusListenerRef &l) noexcept |
Add the given listener to the list if not already present. More... | |
bool | addStatusListener (const BTDevice &d, const AdapterStatusListenerRef &l) noexcept |
bool | addStatusListener (const BTDeviceRef &d, const AdapterStatusListenerRef &l) noexcept |
Please use BTDevice::addStatusListener() for clarity, merely existing here to allow JNI access. 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... | |
BTDeviceRef | findDiscoveredDevice (const EUI48 &address, const BDAddressType addressType) noexcept |
Returns shared BTDevice if found, otherwise nullptr. More... | |
BTDeviceRef | findSharedDevice (const EUI48 &address, const BDAddressType addressType) noexcept |
Returns shared BTDevice if found, otherwise nullptr. More... | |
std::string | get_java_class () const noexcept override |
BDAddressAndType const & | getAddressAndType () const noexcept |
Returns the adapter's public BDAddressAndType, i.e. More... | |
constexpr uint16_t | getBTMajorVersion () const noexcept |
Returns the Bluetooth major version of this adapter. More... | |
BTMode | getBTMode () const noexcept |
Returns the current BTMode of this adapter. More... | |
DiscoveryPolicy | getCurrentDiscoveryPolicy () const noexcept |
Return the current DiscoveryPolicy, set via startDiscovery(). More... | |
ScanType | getCurrentNativeScanType () const noexcept |
Returns the adapter's current native discovering ScanType. More... | |
ScanType | getCurrentScanType () const noexcept |
Returns the current meta discovering ScanType. More... | |
jau::darray< BTDeviceRef > | getDiscoveredDevices () const noexcept |
Returns discovered devices from the last discovery. More... | |
DBGattServerRef | getGATTServerData () |
Return the user's DBGattServer shared reference if in BTRole::Slave mode as set via startAdvertising() and valid until subsequent disconnect. More... | |
HCIHandler & | getHCI () noexcept |
Returns a reference to the aggregated HCIHandler instance. More... | |
constexpr LE_Features | getLEFeatures () const noexcept |
Return LE_Features for this controller. More... | |
const BTManagerRef & | getManager () const noexcept |
Returns a reference to the used singleton BTManager instance, used to create this adapter. More... | |
std::string | getName () const noexcept |
Returns the name. More... | |
BTRole | getRole () const noexcept |
Return the current BTRole of this adapter. More... | |
bool | getSecureConnectionsEnabled () const noexcept |
Returns whether Secure Connections (SC) is enabled. More... | |
std::string | getShortName () const noexcept |
Returns the short name. More... | |
BDAddressAndType const & | getVisibleAddressAndType () const noexcept |
Returns the adapter's currently visible BDAddressAndType, i.e. More... | |
bool | hasSecureConnections () const noexcept |
bool | hasSecureSimplePairing () const noexcept |
HCIStatusCode | initialize (const BTMode btMode, const bool powerOn) noexcept |
Initialize the adapter with default values, including power-on. More... | |
bool | isAdvertising () const noexcept |
Returns the adapter's current advertising state. More... | |
bool | isDeviceWhitelisted (const BDAddressAndType &addressAndType) noexcept |
Returns true, if the adapter's device is already whitelisted. More... | |
bool | isDiscovering () const noexcept |
Returns true if the meta discovering state is not ScanType::NONE. More... | |
bool | isInitialized () const noexcept |
Returns true, if initialize() has already been called for this adapter, otherwise false. More... | |
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 | isValid () const noexcept |
Returns whether the adapter is valid, i.e. More... | |
void | operator= (const BTAdapter &)=delete |
void | printDeviceLists () noexcept |
Print the internally maintained BTDevice lists to stderr: More... | |
void | printStatusListenerList () noexcept |
size_type | removeAllStatusListener () noexcept |
Remove all status listener from the list. More... | |
bool | removeDeviceFromWhitelist (const BDAddressAndType &addressAndType) |
Remove the given device from the adapter's autoconnect whitelist. More... | |
bool | removeDevicePausingDiscovery (const BTDevice &device) noexcept |
Manual DiscoveryPolicy intervention point, allowing user to remove the ready device from the queue of pausing-discovery devices. More... | |
bool | removeDiscoveredDevice (const BDAddressAndType &addressAndType) noexcept |
Discards matching discovered devices. More... | |
size_type | removeDiscoveredDevices () noexcept |
Discards all discovered devices. More... | |
bool | removeStatusListener (const AdapterStatusListener *l) noexcept |
Remove the given listener from the list. More... | |
bool | removeStatusListener (const AdapterStatusListenerRef &l) noexcept |
Remove the given listener from the list. More... | |
HCIStatusCode | reset () noexcept |
Reset the adapter. More... | |
HCIStatusCode | setDefaultConnParam (const uint16_t conn_interval_min=8, const uint16_t conn_interval_max=40, const uint16_t conn_latency=0, const uint16_t supervision_timeout=getHCIConnSupervisorTimeout(0, 50)) noexcept |
Set default connection parameter of incoming connections for this adapter when in server mode, i.e. More... | |
HCIStatusCode | setDefaultLE_PHY (const LE_PHYs Tx, const LE_PHYs Rx) noexcept |
Sets default preference of LE_PHYs. More... | |
HCIStatusCode | setName (const std::string &name, const std::string &short_name) noexcept |
Sets the name and short-name. More... | |
bool | setPowered (const bool power_on) noexcept |
Set the power state of the adapter. More... | |
HCIStatusCode | setPrivacy (const bool enable) noexcept |
Toggle adapter privacy address mode, i.e. More... | |
HCIStatusCode | setSecureConnections (const bool enable) noexcept |
Enable or disable Secure Connections (SC) of the adapter. More... | |
void | setServerConnSecurity (const BTSecurityLevel sec_level, const SMPIOCapability io_cap) noexcept |
Sets the given BTSecurityLevel and SMPIOCapability for connecting device when in server (peripheral) mode, see adapter's role. More... | |
void | setSMPKeyPath (const std::string path) noexcept |
Set the adapter's persistent storage directory for SMPKeyBin files. More... | |
HCIStatusCode | startAdvertising (const DBGattServerRef &gattServerData_, const uint16_t adv_interval_min=160, const uint16_t adv_interval_max=480, const AD_PDU_Type adv_type=AD_PDU_Type::ADV_IND, const uint8_t adv_chan_map=0x07, const uint8_t filter_policy=0x00) noexcept |
Starts advertising. More... | |
HCIStatusCode | startAdvertising (const DBGattServerRef &gattServerData_, EInfoReport &eir, EIRDataType adv_mask=EIRDataType::FLAGS|EIRDataType::SERVICE_UUID, EIRDataType scanrsp_mask=EIRDataType::NAME|EIRDataType::CONN_IVAL, const uint16_t adv_interval_min=160, const uint16_t adv_interval_max=480, const AD_PDU_Type adv_type=AD_PDU_Type::ADV_IND, const uint8_t adv_chan_map=0x07, const uint8_t filter_policy=0x00) noexcept |
Starts advertising. More... | |
HCIStatusCode | startDiscovery (const DBGattServerRef &gattServerData_=nullptr, const DiscoveryPolicy policy=DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY, const bool le_scan_active=true, const uint16_t le_scan_interval=24, const uint16_t le_scan_window=24, const uint8_t filter_policy=0x00, const bool filter_dup=true) noexcept |
Starts discovery. More... | |
HCIStatusCode | stopAdvertising () noexcept |
Ends advertising. More... | |
HCIStatusCode | stopDiscovery () noexcept |
Ends discovery. More... | |
std::string | toString () const noexcept override |
std::string | toString (bool includeDiscoveredDevices) const noexcept |
HCIStatusCode | uploadKeys (SMPKeyBin &bin, const bool write) noexcept |
Associate the given SMPKeyBin with the contained remote address, i.e. More... | |
Public Member Functions inherited from direct_bt::BTObject | |
~BTObject () noexcept override | |
void | checkValidInstance () const override |
Throws an IllegalStateException if instance is not valid. More... | |
bool | isValidInstance () const noexcept |
Returns whether the object's reference is valid and in a general operational state. More... | |
std::string | toString () const noexcept override |
Public Member Functions inherited from jau::jni::JavaUplink | |
JavaUplink () noexcept=default | |
JavaUplink (const JavaUplink &o) noexcept=default | |
JavaUplink (JavaUplink &&o) noexcept=default | |
virtual | ~JavaUplink () noexcept |
virtual void | checkValidInstance () const |
Throws an IllegalStateException if instance is not valid. More... | |
virtual std::string | get_java_class () const noexcept=0 |
const JavaAnonRef & | getJavaObject () noexcept |
std::string | javaObjectToString () const noexcept |
JavaUplink & | operator= (const JavaUplink &o) noexcept=default |
JavaUplink & | operator= (JavaUplink &&o) noexcept=default |
void | setJavaObject () noexcept |
Resets the shared JavaAnon reference, the replaced item might be deleted via JNI from dtor. More... | |
void | setJavaObject (const JavaAnonRef &objRef) noexcept |
Assigns a new shared JavaAnon reference, replaced item might be deleted via JNI from dtor. More... | |
virtual std::string | toString () const noexcept |
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 | |
HCIStatusCode | BTDevice::connectBREDR (const uint16_t pkt_type, const uint16_t clock_offset, const uint8_t role_switch) noexcept |
bool | BTDevice::connectGATT (const std::shared_ptr< BTDevice > &sthis) 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::disconnect (const HCIStatusCode reason) noexcept |
std::shared_ptr< ConnectionInfo > | BTDevice::getConnectionInfo () noexcept |
jau::darray< BTGattServiceRef > | BTDevice::getGattServices () noexcept |
BTDeviceRef | BTDevice::getSharedInstance () const noexcept |
void | BTDevice::hciSMPMsgCallback (const BTDeviceRef &sthis, const SMPPDUMsg &msg, const HCIACLData::l2cap_frame &source) noexcept |
void | BTDevice::processDeviceReady (BTDeviceRef sthis, const uint64_t timestamp) |
void | BTDevice::processL2CAPSetup (BTDeviceRef sthis) |
void | BTDevice::remove () noexcept |
void | BTDevice::sendMgmtEvDeviceDisconnected (std::unique_ptr< MgmtEvent > evt) noexcept |
bool | BTDevice::updateIdentityAddress (BDAddressAndType const &identityAddress, bool sendEvent) noexcept |
bool | BTDevice::updatePairingState (const BTDeviceRef &sthis, const MgmtEvent &evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept |
Additional Inherited Members | |
Protected Member Functions inherited from direct_bt::BTObject | |
BTObject () noexcept | |
Protected Attributes inherited from direct_bt::BTObject | |
std::atomic_bool | instance_valid |
BTAdapter represents one local Bluetooth Controller.
Local BTAdapter roles (see getRole()):
BTRole::Master
: The local adapter is discovering remote BTRole::Slave BTDevice
s and may initiate connections. Enabled via startDiscovery(), but also per default at construction.BTRole::Slave
: The local adapter is advertising to remote BTRole::Master BTDevice
s and may accept connections. Enabled explicitly via startAdvertising() until startDiscovery().Note the remote BTDevice
's opposite role.
Controlling Environment variables:
Definition at line 323 of file BTAdapter.hpp.
Definition at line 355 of file BTAdapter.hpp.
|
noexcept |
Private ctor for private BTAdapter::make_shared() intended for friends.
Definition at line 419 of file BTAdapter.cpp.
|
delete |
|
overridenoexcept |
Releases this instance.
Definition at line 455 of file BTAdapter.cpp.
|
delete |
|
noexcept |
Closes this instance, usually being called by destructor or when this adapter is being removed as recognized and handled by BTManager.
In case initialize() has powered-on this adapter and was not powered-on before, it will be powered-off.
Renders this adapter's BTAdapter::isValid() state to false.
Definition at line 472 of file BTAdapter.cpp.
|
inlineoverridevirtualnoexcept |
Implements jau::jni::JavaUplink.
Definition at line 613 of file BTAdapter.hpp.
|
inlinestaticnoexcept |
|
inlinenoexcept |
Returns whether the adapter is valid, plugged in and powered.
Definition at line 626 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns whether the adapter is suspended, i.e.
valid and plugged in, but not powered.
Definition at line 636 of file BTAdapter.hpp.
|
inlinenoexcept |
Definition at line 640 of file BTAdapter.hpp.
|
inlinenoexcept |
Definition at line 644 of file BTAdapter.hpp.
|
inlineconstexprnoexcept |
Return LE_Features for this controller.
BT Core Spec v5.2: Vol 6, Part B, 4.6 (LE LL) Feature Support
Definition at line 654 of file BTAdapter.hpp.
|
inlineconstexprnoexcept |
Returns the Bluetooth major version of this adapter.
Currently either 4
or 5
.
Definition at line 657 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns whether the adapter is valid, i.e.
reference is valid, plugged in and generally operational, but not necessarily BTAdapter::isPowered() powered.
Definition at line 666 of file BTAdapter.hpp.
|
inlinenoexcept |
Return the current BTRole of this adapter.
Definition at line 676 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns the current BTMode of this adapter.
Definition at line 681 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns the adapter's public BDAddressAndType, i.e.
BDAddressType::BDADDR_LE_PUBLIC.
The adapter's address as initially reported by the system is always its public address, i.e. BDAddressType::BDADDR_LE_PUBLIC.
Definition at line 691 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns the adapter's currently visible BDAddressAndType, i.e.
BDAddressType::BDADDR_LE_RANDOM or BDAddressType::BDADDR_LE_PUBLIC.
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 via setPrivacy().
Definition at line 705 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns the name.
Can be changed via setName() while powered-off.
Definition at line 714 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns the short name.
Can be changed via setName() while powered-off.
Definition at line 723 of file BTAdapter.hpp.
|
noexcept |
Sets the name and short-name.
The corresponding management event will change the name and short-name.
Shall be called while adapter is powered off, see setPowered(). If adapter is powered, method returns HCIStatusCode::COMMAND_DISALLOWED.
name | |
short_name |
Definition at line 652 of file BTAdapter.cpp.
|
noexcept |
Set the power state of the adapter.
In case current power state is already as desired, method will not change the power state.
power_on | true will power on this adapter if it is powered-off and vice versa. |
Definition at line 660 of file BTAdapter.cpp.
|
noexcept |
Toggle adapter privacy address mode, i.e.
resolvable random address including IRK.
enable | toggle to enable or disable (default) |
Definition at line 674 of file BTAdapter.cpp.
|
inlinenoexcept |
Returns whether Secure Connections (SC) is enabled.
Definition at line 770 of file BTAdapter.hpp.
|
noexcept |
Enable or disable Secure Connections (SC) of the adapter.
By default, Secure Connections (SC) is enabled if supported.
Shall be called while adapter is powered off, see setPowered(). If adapter is powered, method returns HCIStatusCode::COMMAND_DISALLOWED.
enable |
Definition at line 710 of file BTAdapter.cpp.
|
noexcept |
Set default connection parameter of incoming connections for this adapter when in server mode, i.e.
In case the incoming connection's parameter don't lie within the given default values, a reconnect is being requested.
Shall be called while adapter is powered off, see setPowered(). If adapter is powered, method returns HCIStatusCode::COMMAND_DISALLOWED.
BlueZ/Linux LE connection defaults are
Supported on GNU/Linux since kernel 5.9.
dev_id | |
conn_interval_min | in units of 1.25ms, default value 8 for 10ms; Value range [6 .. 3200] for [7.5ms .. 4000ms]. |
conn_interval_max | in units of 1.25ms, default value 40 for 50ms; Value range [6 .. 3200] for [7.5ms .. 4000ms] |
conn_latency | slave latency in units of connection events, default value 0; Value range [0 .. 0x01F3]. |
supervision_timeout | in units of 10ms, default value 500ms >= 10 x conn_interval_max, we use HCIConstInt::LE_CONN_MIN_TIMEOUT_MS minimum; Value range [0xA-0x0C80] for [100ms - 32s]. |
Definition at line 727 of file BTAdapter.cpp.
|
noexcept |
Sets the given BTSecurityLevel and SMPIOCapability for connecting device when in server (peripheral) mode, see adapter's role.
Method either changes both parameter for the upcoming connection or none at all.
[in] | sec_level | BTSecurityLevel to be applied. |
[in] | io_cap | SMPIOCapability to be applied. |
Definition at line 735 of file BTAdapter.cpp.
|
noexcept |
Set the adapter's persistent storage directory for SMPKeyBin files.
When called, all keys within the path will be loaded, i.e. issuing uploadKeys() for all keys belonging to this BTAdapter.
Persistent SMPKeyBin management is only functional when BTAdapter is in BTRole::Slave peripheral mode.
For each SMPKeyBin file one shared BTDevice in BTRole::Master will be instantiated when uploadKeys() is called.
path | persistent storage path to SMPKeyBin files |
Definition at line 739 of file BTAdapter.cpp.
|
noexcept |
Associate the given SMPKeyBin with the contained remote address, i.e.
SMPKeyBin::getRemoteAddrAndType().
Further uploads the Long Term Key (LTK) and Link Key (LK) for a potential upcoming connection, if they are contained in the given SMPKeyBin file.
This method is provided to support BTRole::Slave peripheral adapter mode, allowing user to inject all required keys after initialize()
One shared BTDevice in BTRole::Master is instantiated.
bin | SMPKeyBin instance, might be persistent in filesystem |
write | if true, write file to persistent storage, otherwise not |
Definition at line 749 of file BTAdapter.cpp.
|
noexcept |
Initialize the adapter with default values, including power-on.
Method shall be issued on the desired adapter found via ChangedAdapterSetFunc.
While initialization, the adapter is first powered-off, setup and then powered-on.
Calling the method will allow close() to power-off the adapter, if not powered on before.
btMode | the desired adapter's BTMode, default is BTMode::DUAL |
powerOn | true to leave adapter powered-on (default), otherwise leave it off * |
Definition at line 794 of file BTAdapter.cpp.
|
inlinenoexcept |
Returns true, if initialize() has already been called for this adapter, otherwise false.
Definition at line 898 of file BTAdapter.hpp.
|
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
Definition at line 943 of file BTAdapter.cpp.
|
noexcept |
Sets default preference of LE_PHYs.
BT Core Spec v5.2: Vol 4, Part E, 7.8.49 LE Set PHY command
Tx | transmitter LE_PHYs bit mask of preference if not set to LE_PHYs::NONE (ignored). |
Rx | receiver LE_PHYs bit mask of preference if not set to LE_PHYs::NONE (ignored). |
Definition at line 978 of file BTAdapter.cpp.
|
inlinenoexcept |
Returns a reference to the used singleton BTManager instance, used to create this adapter.
Definition at line 932 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns a reference to the aggregated HCIHandler instance.
Definition at line 937 of file BTAdapter.hpp.
|
noexcept |
Returns true, if the adapter's device is already whitelisted.
Definition at line 986 of file BTAdapter.cpp.
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.
address | |
address_type | |
ctype | |
conn_interval_min | in units of 1.25ms, default value 12 for 15ms; Value range [6 .. 3200] for [7.5ms .. 4000ms] |
conn_interval_max | in units of 1.25ms, default value 12 for 15ms; Value range [6 .. 3200] for [7.5ms .. 4000ms] |
conn_latency | slave latency in units of connection events, default value 0; Value range [0 .. 0x01F3]. |
supervision_timeout | in 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]. |
Definition at line 990 of file BTAdapter.cpp.
bool BTAdapter::removeDeviceFromWhitelist | ( | const BDAddressAndType & | addressAndType | ) |
Remove the given device from the adapter's autoconnect whitelist.
Definition at line 1010 of file BTAdapter.cpp.
|
noexcept |
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.
Definition at line 1017 of file BTAdapter.cpp.
|
noexcept |
Please use BTDevice::addStatusListener() for clarity, merely existing here to allow JNI access.
Definition at line 1034 of file BTAdapter.cpp.
|
noexcept |
Definition at line 1055 of file BTAdapter.cpp.
|
noexcept |
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.
Definition at line 1059 of file BTAdapter.cpp.
|
noexcept |
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.
Definition at line 1074 of file BTAdapter.cpp.
|
noexcept |
Remove all status listener from the list.
Returns the number of removed status listener.
Definition at line 1120 of file BTAdapter.cpp.
|
noexcept |
Starts discovery.
Returns HCIStatusCode::SUCCESS if successful, otherwise the HCIStatusCode error state;
Depending on given DiscoveryPolicy policy
, the discovery mode may be turned-off, paused until a certain readiness stage has been reached or preserved at all times. Default is DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY.
+ --+-------+--------+-----------+----------------------------------------------------+ | # | 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 +---+-------+--------+-----------+----------------------------------------------------+
Default parameter values are chosen for using public address resolution and usual discovery intervals etc.
Method will always clear previous discovered devices via removeDiscoveredDevices().
Method fails if isAdvertising().
If successful, method also changes this adapter's role to BTRole::Master.
This adapter's HCIHandler instance is used to initiate scanning, see HCIHandler::le_start_scan().
gattServerData_ | optional DBGattServer data to be offered via GattHandler as GATTRole::Client, may be nullptr (default). Its handles will be setup via DBGattServer::setServicesHandles(). Reference is held until next startDiscovery. |
policy | defaults to DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY, see DiscoveryPolicy |
le_scan_active | true enables delivery of active scanning PDUs like EIR w/ device name (default), otherwise no scanning PDUs shall be sent. |
le_scan_interval | in units of 0.625ms, default value 24 for 15ms; Value range [4 .. 0x4000] for [2.5ms .. 10.24s] |
le_scan_window | in units of 0.625ms, default value 24 for 15ms; Value range [4 .. 0x4000] for [2.5ms .. 10.24s]. Shall be <= le_scan_interval |
filter_policy | 0x00 accepts all PDUs (default), 0x01 only of whitelisted, ... |
filter_dup | true to filter out duplicate AD PDUs (default), otherwise all will be reported. |
Definition at line 1150 of file BTAdapter.cpp.
|
noexcept |
Ends discovery.
This adapter's HCIHandler instance is used to stop scanning, see HCIHandler::le_enable_scan().
Definition at line 1285 of file BTAdapter.cpp.
|
inlinenoexcept |
Return the current DiscoveryPolicy, set via startDiscovery().
Definition at line 1110 of file BTAdapter.hpp.
|
noexcept |
Manual DiscoveryPolicy intervention point, allowing user to remove the ready device from the queue of pausing-discovery devices.
Manual intervention might be desired, if using DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED, but allowing discovery at an earlier processing step from AdapterStatusListener::deviceReady().
Re-enabling discovery is performed on the current thread.
device | the BTDevice to remove from the pausing-discovery queue |
Definition at line 183 of file BTAdapter.cpp.
|
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.
Definition at line 1137 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns the adapter's current native discovering ScanType.
It can be modified through startDiscovery(..) and stopDiscovery().
Definition at line 1147 of file BTAdapter.hpp.
|
inlinenoexcept |
Returns true if the meta discovering state is not ScanType::NONE.
It can be modified through startDiscovery(..) and stopDiscovery().
Definition at line 1158 of file BTAdapter.hpp.
|
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 1440 of file BTAdapter.cpp.
|
noexcept |
Discards all discovered devices.
Returns number of removed discovered devices.
Definition at line 1415 of file BTAdapter.cpp.
|
noexcept |
Discards matching discovered devices.
Returns true
if found and removed, otherwise false.
Definition at line 1400 of file BTAdapter.cpp.
|
noexcept |
Returns shared BTDevice if found, otherwise nullptr.
Definition at line 1385 of file BTAdapter.cpp.
|
noexcept |
Returns shared BTDevice if found, otherwise nullptr.
Definition at line 1475 of file BTAdapter.cpp.
|
noexcept |
Starts advertising.
if available, otherwise using
Method fails if isDiscovering() or has any open or pending connected remote BTDevice
s.
If successful, method also changes this adapter's role to BTRole::Slave and treat connected BTDevice as BTRole::Master while service GATTRole::Server.
Advertising is active until either disabled via stopAdvertising() or a connection has been made, see isAdvertising().
This adapter's HCIHandler instance is used to initiate scanning, see HCIHandler::le_start_adv().
The given ADV EIR EInfoReport will be updated with getName() and at least GAPFlags::LE_Gen_Disc set.
The given adv_mask and scanrsp_mask will be updated to have at least EIRDataType::FLAGS and EIRDataType::NAME set in total.
gattServerData_ | the DBGattServer data to be advertised and offered via GattHandler as GATTRole::Server. Its handles will be setup via DBGattServer::setServicesHandles(). Reference is held until next disconnect. |
eir | Full ADV EIR EInfoReport, will be updated with getName() and at least GAPFlags::LE_Gen_Disc set. |
adv_mask | EIRDataType mask for EInfoReport to select advertisement EIR PDU data, defaults to EIRDataType::FLAGS | EIRDataType::SERVICE_UUID |
scanrsp_mask | EIRDataType mask for EInfoReport to select scan-response (active scanning) EIR PDU data, defaults to EIRDataType::NAME | EIRDataType::CONN_IVAL |
adv_interval_min | in units of 0.625ms, default value 160 for 100ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] |
adv_interval_max | in units of 0.625ms, default value 480 for 300ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] |
adv_type | see AD_PDU_Type, default AD_PDU_Type::ADV_IND |
adv_chan_map | bit 0: chan 37, bit 1: chan 38, bit 2: chan 39, default is 0x07 (all 3 channels enabled) |
filter_policy | 0x00 accepts all PDUs (default), 0x01 only of whitelisted, ... |
Definition at line 1557 of file BTAdapter.cpp.
|
noexcept |
Starts advertising.
if available, otherwise using
Method fails if isDiscovering() or has any open or pending connected remote BTDevice
s.
If successful, method also changes this adapter's role to BTRole::Slave and treat connected BTDevice as BTRole::Master while service GATTRole::Server.
Advertising is active until either disabled via stopAdvertising() or a connection has been made, see isAdvertising().
This adapter's HCIHandler instance is used to initiate scanning, see HCIHandler::le_start_adv().
The ADV EIR EInfoReport will be generated on the default EIRDataType adv_mask using EIRDataType::FLAGS | EIRDataType::SERVICE_UUID and EIRDataType scanrsp_mask using scan-response (active scanning) EIRDataType::NAME | EIRDataType::CONN_IVAL.
gattServerData_ | the DBGattServer data to be advertised and offered via GattHandler as GATTRole::Server. Its handles will be setup via DBGattServer::setServicesHandles(). Reference is held until next disconnect. |
adv_interval_min | in units of 0.625ms, default value 160 for 100ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] |
adv_interval_max | in units of 0.625ms, default value 480 for 300ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] |
adv_type | see AD_PDU_Type, default AD_PDU_Type::ADV_IND |
adv_chan_map | bit 0: chan 37, bit 1: chan 38, bit 2: chan 39, default is 0x07 (all 3 channels enabled) |
filter_policy | 0x00 accepts all PDUs (default), 0x01 only of whitelisted, ... |
Definition at line 1637 of file BTAdapter.cpp.
|
noexcept |
Ends advertising.
Closes the advertising session.
if available, otherwise using
Advertising is active until either disabled via stopAdvertising() or a connection has been made, see isAdvertising().
This adapter's HCIHandler instance is used to stop scanning, see HCIHandler::le_enable_adv().
This adapter's HCIHandler instance is used to stop advertising, see HCIHandler::le_enable_adv().
Definition at line 1671 of file BTAdapter.cpp.
|
inlinenoexcept |
Returns the adapter's current advertising state.
It can be modified through startAdvertising(..) and stopAdvertising().
Advertising is active until either disabled via stopAdvertising() or a connection has been made.
Definition at line 1319 of file BTAdapter.hpp.
|
inline |
Return the user's DBGattServer shared reference if in BTRole::Slave mode as set via startAdvertising() and valid until subsequent disconnect.
Returns nullptr if in BTRole::Master mode.
Definition at line 1329 of file BTAdapter.hpp.
|
inlineoverridevirtualnoexcept |
Reimplemented from jau::jni::JavaUplink.
Definition at line 1331 of file BTAdapter.hpp.
|
noexcept |
Definition at line 1688 of file BTAdapter.cpp.
|
noexcept |
Print the internally maintained BTDevice lists to stderr:
This is intended as a debug facility.
Definition at line 618 of file BTAdapter.cpp.
|
noexcept |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
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 363 of file BTAdapter.hpp.