Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
|
BTAdapter represents one local Bluetooth Controller. More...
Public Member Functions | |
boolean | addDeviceToWhitelist (final BDAddressAndType addressAndType, final HCIWhitelistConnectType ctype) |
Add the given device to the adapter's autoconnect whitelist. More... | |
boolean | addDeviceToWhitelist (final BDAddressAndType addressAndType, final HCIWhitelistConnectType ctype, final short conn_interval_min, final short conn_interval_max, final short conn_latency, final short timeout) |
Add the given device to the adapter's autoconnect whitelist. More... | |
boolean | addStatusListener (final AdapterStatusListener listener) |
Add the given AdapterStatusListener to the list if not already present. More... | |
BTDevice | connectDevice (BDAddressAndType addressAndType) |
This method connects to device without need of performing General Discovery. More... | |
boolean | equals (final Object obj) |
If both types are of BTAdapter , it compares their BDAddressAndType , see getAddressAndType() . More... | |
BTDevice | find (String name, BDAddressAndType addressAndType) |
Find a BluetoothDevice. More... | |
BTDevice | find (String name, BDAddressAndType addressAndType, long timeoutMS) |
Find a BluetoothDevice. More... | |
BDAddressAndType | getAddressAndType () |
Returns the adapter's public BDAddressAndType. More... | |
int | getBTMajorVersion () |
Returns the Bluetooth major version of this adapter. More... | |
BTMode | getBTMode () |
Returns the current BTMode of this adapter. More... | |
DiscoveryPolicy | getCurrentDiscoveryPolicy () |
Return the current DiscoveryPolicy , set via startDiscovery(DiscoveryPolicy, boolean, short, short, byte, boolean) . More... | |
ScanType | getCurrentScanType () |
Returns the current meta discovering ScanType . More... | |
int | getDevID () |
Returns the BluetoothAdapter's internal temporary device id. More... | |
List< BTDevice > | getDiscoveredDevices () |
Returns a list of discovered BluetoothDevices from this adapter. More... | |
DBGattServer | getGATTServerData () |
Return the user's DBGattServer shared reference if in BTRole#Slave mode as set via and valid until subsequent disconnect. More... | |
LE_Features | getLEFeatures () |
Return LE_Features for this controller. More... | |
BTManager | getManager () |
Returns the used singleton BTManager instance, used to create this adapter. More... | |
String | getName () |
Returns the name. More... | |
boolean | getPoweredState () |
Returns the power state the adapter. More... | |
BTRole | getRole () |
Return the current BTRole of this adapter. More... | |
boolean | getSecureConnectionsEnabled () |
Returns whether Secure Connections (SC) is enabled. More... | |
String | getShortName () |
Returns the short name. More... | |
BDAddressAndType | getVisibleAddressAndType () |
Returns the adapter's currently visible BDAddressAndType. More... | |
HCIStatusCode | initialize (final BTMode btMode, boolean powerOn) |
Initialize the adapter with default values, including power-on. More... | |
boolean | isAdvertising () |
Returns the adapter's current advertising state. More... | |
boolean | isDeviceWhitelisted (final BDAddressAndType addressAndType) |
Returns true, if the adapter's device is already whitelisted. More... | |
boolean | isDiscovering () |
Returns true if the meta discovering state is not ScanType#NONE . More... | |
boolean | isInitialized () |
Returns true, if initialize(BTMode) has already been called for this adapter, otherwise false. More... | |
boolean | isPowered () |
Returns whether the adapter is valid, plugged in and powered. More... | |
boolean | isSuspended () |
Returns whether the adapter is suspended, i.e. More... | |
boolean | isValid () |
Returns whether the adapter is valid, i.e. More... | |
void | printDeviceLists () |
Print the internally maintained BTDevice lists to stderr: More... | |
int | removeAllStatusListener () |
Remove all AdapterStatusListener from the list. More... | |
boolean | removeDeviceFromWhitelist (final BDAddressAndType addressAndType) |
Remove the given device from the adapter's autoconnect whitelist. More... | |
boolean | removeDevicePausingDiscovery (final BTDevice device) |
Manual DiscoveryPolicy intervention point, allowing user to remove the ready device from the queue of pausing-discovery devices. More... | |
boolean | removeDiscoveredDevice (final BDAddressAndType addressAndType) |
Discards matching discovered devices. More... | |
int | removeDiscoveredDevices () throws BTException |
Remove all the discovered devices found on this adapter. More... | |
boolean | removeStatusListener (final AdapterStatusListener l) |
Remove the given AdapterStatusListener from the list. More... | |
HCIStatusCode | reset () |
Reset the adapter. More... | |
HCIStatusCode | setDefaultConnParam (final short conn_interval_min, final short conn_interval_max, final short conn_latency, final short supervision_timeout) |
Set default connection parameter of incoming connections for this adapter when in server mode, i.e. More... | |
HCIStatusCode | setDefaultLE_PHY (final LE_PHYs Tx, final LE_PHYs Rx) |
Sets default preference of LE_PHYs. More... | |
HCIStatusCode | setName (String name, String short_name) |
Sets the name and short-name. More... | |
boolean | setPowered (final boolean power_on) |
Sets the power state the adapter. More... | |
HCIStatusCode | setPrivacy (boolean enable) |
Toggle adapter privacy address mode, i.e. More... | |
HCIStatusCode | setSecureConnections (final boolean enable) |
Enable or disable Secure Connections (SC) of the adapter. More... | |
void | setServerConnSecurity (final BTSecurityLevel sec_level, final SMPIOCapability io_cap) |
Sets the given ::BTSecurityLevel and ::SMPIOCapability for connecting device when in server (peripheral) mode, see adapter's role. More... | |
void | setSMPKeyPath (final String path) |
Set the adapter's persistent storage directory for SMPKeyBin files. More... | |
HCIStatusCode | startAdvertising (final DBGattServer gattServerData) |
Starts advertising using all default arguments, see startAdvertising(short, short, byte, byte, byte) for details. More... | |
HCIStatusCode | startAdvertising (final DBGattServer gattServerData, final EInfoReport eir, final EIRDataTypeSet adv_mask, final EIRDataTypeSet scanrsp_mask, final short adv_interval_min, final short adv_interval_max, final byte adv_type, final byte adv_chan_map, final byte filter_policy) |
Starts advertising. More... | |
HCIStatusCode | startAdvertising (final DBGattServer gattServerData, final short adv_interval_min, final short adv_interval_max, final byte adv_type, final byte adv_chan_map, final byte filter_policy) |
Starts advertising. More... | |
HCIStatusCode | startDiscovery () throws BTException |
Starts discovery using all default arguments, see startDiscovery(DiscoveryPolicy, boolean, short, short, byte, boolean) for details. More... | |
HCIStatusCode | startDiscovery (final DBGattServer gattServerData, final DiscoveryPolicy policy, final boolean le_scan_active, final short le_scan_interval, final short le_scan_window, final byte filter_policy, final boolean filter_dup) throws BTException |
Starts discovery. More... | |
HCIStatusCode | startDiscovery (final DiscoveryPolicy policy, final boolean le_scan_active) throws BTException |
Starts discovery using default arguments, see startDiscovery(DiscoveryPolicy, boolean, short, short, byte, boolean) for details. More... | |
HCIStatusCode | stopAdvertising () |
Ends advertising. More... | |
HCIStatusCode | stopDiscovery () throws BTException |
Turns off device discovery if it is enabled. More... | |
String | toString () |
Public Member Functions inherited from org.direct_bt.BTObject | |
void | close () |
Release the native memory associated with this object The object should not be used following a call to close. More... | |
boolean | equals (Object obj) |
int | hashCode () |
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.
Definition at line 47 of file BTAdapter.java.
BTManager org.direct_bt.BTAdapter.getManager | ( | ) |
Returns the used singleton BTManager
instance, used to create this adapter.
Implemented in jau.direct_bt.DBTAdapter.
BTRole org.direct_bt.BTAdapter.getRole | ( | ) |
Return the current BTRole
of this adapter.
Implemented in jau.direct_bt.DBTAdapter.
BTMode org.direct_bt.BTAdapter.getBTMode | ( | ) |
BTDevice org.direct_bt.BTAdapter.find | ( | String | name, |
BDAddressAndType | addressAndType, | ||
long | timeoutMS | ||
) |
Find a BluetoothDevice.
If parameters name and address are not null, the returned object will have to match them. It will first check for existing objects. It will not turn on discovery or connect to devices. @parameter name optionally specify the name of the object you are waiting for @parameter address optionally specify the MAC address of the device you are waiting for @parameter timeoutMS the function will return after timeout time in milliseconds, a value of zero means wait forever. If object is not found during this time null will be returned.
Implemented in jau.direct_bt.DBTAdapter.
BTDevice org.direct_bt.BTAdapter.find | ( | String | name, |
BDAddressAndType | addressAndType | ||
) |
Find a BluetoothDevice.
If parameters name and address are not null, the returned object will have to match them. It will first check for existing objects. It will not turn on discovery or connect to devices. @parameter name optionally specify the name of the object you are waiting for @parameter address optionally specify the MAC address of the device you are waiting for
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.isDeviceWhitelisted | ( | final BDAddressAndType | addressAndType | ) |
Returns true, if the adapter's device is already whitelisted.
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.addDeviceToWhitelist | ( | final BDAddressAndType | addressAndType, |
final HCIWhitelistConnectType | ctype, | ||
final short | conn_interval_min, | ||
final short | conn_interval_max, | ||
final short | conn_latency, | ||
final short | timeout | ||
) |
Add the given device to the adapter's autoconnect whitelist.
The given LE connection parameter will be uploaded to the kernel for the given device first, if the device is of type BDAddressType#BDADDR_LE_PUBLIC
or BDAddressType#BDADDR_LE_RANDOM
.
Method will reject duplicate devices, in which case it should be removed first.
address | |
address_type | |
ctype | |
conn_interval_min | default value 0x000F |
conn_interval_max | default value 0x000F |
conn_latency | default value 0x0000 |
timeout | in units of 10ms, default value 1000 for 10000ms or 10s. |
true
if successful, otherwise false
.Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.addDeviceToWhitelist | ( | final BDAddressAndType | addressAndType, |
final HCIWhitelistConnectType | ctype | ||
) |
Add the given device to the adapter's autoconnect whitelist.
This variant of addDeviceToWhitelist(String, BDAddressType, HCIWhitelistConnectType, short, short, short, short)
uses default connection parameter, which 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 |
true
if successful, otherwise false
.Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.removeDeviceFromWhitelist | ( | final BDAddressAndType | addressAndType | ) |
Remove the given device from the adapter's autoconnect whitelist.
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.startDiscovery | ( | ) | throws BTException |
Starts discovery using all default arguments, see startDiscovery(DiscoveryPolicy, boolean, short, short, byte, boolean)
for details.
HCIStatusCode#SUCCESS
if successful, otherwise the HCIStatusCode
error state BTException |
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.startDiscovery | ( | final DiscoveryPolicy | policy, |
final boolean | le_scan_active | ||
) | throws BTException |
Starts discovery using default arguments, see startDiscovery(DiscoveryPolicy, boolean, short, short, byte, boolean)
for details.
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. |
HCIStatusCode#SUCCESS
if successful, otherwise the HCIStatusCode
error state BTException |
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.startDiscovery | ( | final DBGattServer | gattServerData, |
final DiscoveryPolicy | policy, | ||
final boolean | le_scan_active, | ||
final short | le_scan_interval, | ||
final short | le_scan_window, | ||
final byte | filter_policy, | ||
final boolean | filter_dup | ||
) | throws BTException |
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
.
gattServerData_ | the DBGattServer data to be offered via GattHandler as ::GATTRole::Client. 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. |
HCIStatusCode#SUCCESS
if successful, otherwise the HCIStatusCode
error state BTException |
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.stopDiscovery | ( | ) | throws BTException |
Turns off device discovery if it is enabled.
HCIStatusCode#SUCCESS
if successful, otherwise the HCIStatusCode
error state @apiNote return HCIStatusCode
since 2.0.0 Implemented in jau.direct_bt.DBTAdapter.
DiscoveryPolicy org.direct_bt.BTAdapter.getCurrentDiscoveryPolicy | ( | ) |
Return the current DiscoveryPolicy
, set via startDiscovery(DiscoveryPolicy, boolean, short, short, byte, boolean)
.
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.removeDevicePausingDiscovery | ( | final BTDevice | device | ) |
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(BTDevice, long)
.
Re-enabling discovery is performed on the current thread.
device | the BTDevice to remove from the pausing-discovery queue |
BTDevice
, re-enabling discovery. Otherwise false. Implemented in jau.direct_bt.DBTAdapter.
List< BTDevice > org.direct_bt.BTAdapter.getDiscoveredDevices | ( | ) |
Returns a list of discovered BluetoothDevices from this adapter.
Implemented in jau.direct_bt.DBTAdapter.
int org.direct_bt.BTAdapter.removeDiscoveredDevices | ( | ) | throws BTException |
Remove all the discovered devices found on this adapter.
BTException |
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.removeDiscoveredDevice | ( | final BDAddressAndType | addressAndType | ) |
Discards matching discovered devices.
true
if found and removed, otherwise false. Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.startAdvertising | ( | final DBGattServer | gattServerData, |
final EInfoReport | eir, | ||
final EIRDataTypeSet | adv_mask, | ||
final EIRDataTypeSet | scanrsp_mask, | ||
final short | adv_interval_min, | ||
final short | adv_interval_max, | ||
final byte | adv_type, | ||
final byte | adv_chan_map, | ||
final byte | filter_policy | ||
) |
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.
Advertising is active until either disabled via stopAdvertising()
or a connection has been made, see isAdvertising()
.
The given ADV EIR EInfoReport
will be updated with getName()
and at least GAPFlags.Bit#LE_Gen_Disc
set.
The given adv_mask and scanrsp_mask will be updated to have at least EIRDataTypeSet.DataType#FLAGS
and EIRDataTypeSet.DataType#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.Bit#LE_Gen_Disc set. |
adv_mask | EIRDataTypeSet mask for EInfoReport to select advertisement EIR PDU data, defaults to EIRDataTypeSet.DataType#FLAGS | EIRDataTypeSet.DataType#SERVICE_UUID |
scanrsp_mask | EIRDataTypeSet mask for EInfoReport to select scan-response (active scanning) EIR PDU data, defaults to EIRDataTypeSet.DataType#NAME | EIRDataTypeSet.DataType#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 0x00, i.e. ::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, ... |
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.startAdvertising | ( | final DBGattServer | gattServerData, |
final short | adv_interval_min, | ||
final short | adv_interval_max, | ||
final byte | adv_type, | ||
final byte | adv_chan_map, | ||
final byte | filter_policy | ||
) |
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.
Advertising is active until either disabled via stopAdvertising()
or a connection has been made, see isAdvertising()
.
The ADV EIR EInfoReport
will be generated on the default EIRDataTypeSet
adv_mask using EIRDataTypeSet.DataType#FLAGS
| EIRDataTypeSet.DataType#SERVICE_UUID
and EIRDataTypeSet
scanrsp_mask using scan-response (active scanning) EIRDataTypeSet.DataType#NAME
| EIRDataTypeSet.DataType#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 0x00, i.e. ::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, ... |
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.startAdvertising | ( | final DBGattServer | gattServerData | ) |
Starts advertising using all default arguments, see startAdvertising(short, short, byte, byte, byte)
for details.
Advertising is active until either disabled via stopAdvertising()
or a connection has been made, see isAdvertising()
.
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. |
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.stopAdvertising | ( | ) |
Ends advertising.
if available, otherwise using
Advertising is active until either disabled via stopAdvertising()
or a connection has been made, see isAdvertising()
.
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.isAdvertising | ( | ) |
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, see isAdvertising()
.
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.equals | ( | final Object | obj | ) |
If both types are of BTAdapter
, it compares their BDAddressAndType
, see getAddressAndType()
.
Implements org.direct_bt.BTObject.
Implemented in jau.direct_bt.DBTAdapter.
BDAddressAndType org.direct_bt.BTAdapter.getAddressAndType | ( | ) |
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
.
Implemented in jau.direct_bt.DBTAdapter.
BDAddressAndType org.direct_bt.BTAdapter.getVisibleAddressAndType | ( | ) |
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).
Implemented in jau.direct_bt.DBTAdapter.
int org.direct_bt.BTAdapter.getDevID | ( | ) |
Returns the BluetoothAdapter's internal temporary device id.
The internal device id is constant across the adapter lifecycle, but may change after its destruction.
Implemented in jau.direct_bt.DBTAdapter.
int org.direct_bt.BTAdapter.getBTMajorVersion | ( | ) |
Returns the Bluetooth major version of this adapter.
Currently either 4
or 5
.
Implemented in jau.direct_bt.DBTAdapter.
String org.direct_bt.BTAdapter.getName | ( | ) |
Returns the name.
Can be changed via setName(String, String)
while powered-off.
Implemented in jau.direct_bt.DBTAdapter.
String org.direct_bt.BTAdapter.getShortName | ( | ) |
Returns the short name.
Can be changed via setName(String, String)
while powered-off.
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.setName | ( | String | name, |
String | short_name | ||
) |
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(boolean)
. If adapter is powered, method returns HCIStatusCode#COMMAND_DISALLOWED
.
name | |
short_name |
HCIStatusCode#SUCCESS
if successful, otherwise the HCIStatusCode
error state Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.isPowered | ( | ) |
Returns whether the adapter is valid, plugged in and powered.
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.isSuspended | ( | ) |
Returns whether the adapter is suspended, i.e.
valid and plugged in, but not powered.
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.isValid | ( | ) |
Returns whether the adapter is valid, i.e.
reference is valid, plugged in and generally operational, but not necessarily isPowered()
.
close()
'ed Implemented in jau.direct_bt.DBTAdapter.
LE_Features org.direct_bt.BTAdapter.getLEFeatures | ( | ) |
Return LE_Features
for this controller.
BT Core Spec v5.2: Vol 6, Part B, 4.6 (LE LL) Feature Support
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.getPoweredState | ( | ) |
Returns the power state the adapter.
Consider using isPowered()
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.setPowered | ( | final boolean | power_on | ) |
Sets the power state 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. |
@apiNote return value boolean since 2.0.0
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.setPrivacy | ( | boolean | enable | ) |
Toggle adapter privacy address mode, i.e.
resolvable random address including IRK.
enable | toggle to enable or disable (default) |
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.getSecureConnectionsEnabled | ( | ) |
Returns whether Secure Connections (SC) is enabled.
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.setSecureConnections | ( | final boolean | enable | ) |
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(boolean)
. If adapter is powered, method returns HCIStatusCode#COMMAND_DISALLOWED
.
enable |
HCIStatusCode#SUCCESS
if successful, otherwise the HCIStatusCode
error state Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.setDefaultConnParam | ( | final short | conn_interval_min, |
final short | conn_interval_max, | ||
final short | conn_latency, | ||
final short | supervision_timeout | ||
) |
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]. |
Implemented in jau.direct_bt.DBTAdapter.
void org.direct_bt.BTAdapter.setServerConnSecurity | ( | final BTSecurityLevel | sec_level, |
final SMPIOCapability | io_cap | ||
) |
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. |
Implemented in jau.direct_bt.DBTAdapter.
void org.direct_bt.BTAdapter.setSMPKeyPath | ( | final String | path | ) |
Set the adapter's persistent storage directory for SMPKeyBin
files.
SMPKeyBin
instances will be managed and persistent.SMPKeyBin
instances will be transient only.When called, all keys within the path will be loaded, i.e. issuing 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 |
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.initialize | ( | final BTMode | btMode, |
boolean | powerOn | ||
) |
Initialize the adapter with default values, including power-on.
Method shall be issued on the desired adapter found via BTManager.ChangedAdapterSetListener
.
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 shall be BTMode#DUAL |
powerOn | true to leave adapter powered-on, otherwise leave it off * |
HCIStatusCode#SUCCESS
or an error state on failure (e.g. power-on) Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.isInitialized | ( | ) |
Returns true, if initialize(BTMode)
has already been called for this adapter, otherwise false.
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.reset | ( | ) |
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
Implemented in jau.direct_bt.DBTAdapter.
HCIStatusCode org.direct_bt.BTAdapter.setDefaultLE_PHY | ( | final LE_PHYs | Tx, |
final LE_PHYs | Rx | ||
) |
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 zero LE_PHYs#mask (ignored). |
Rx | receiver LE_PHYs bit mask of preference if not set to zero LE_PHYs#mask (ignored). |
Implemented in jau.direct_bt.DBTAdapter.
BTDevice org.direct_bt.BTAdapter.connectDevice | ( | BDAddressAndType | addressAndType | ) |
This method connects to device without need of performing General Discovery.
Connection mechanism is similar to Connect method from Device1 interface with exception that this method returns success when physical connection is established. After this method returns, services discovery will continue and any supported profile will be connected. There is no need for calling Connect on Device1 after this call. If connection was successful this method returns object path to created device object.
address | The Bluetooth device address of the remote device. This parameter is mandatory. |
addressType | The Bluetooth device Address Type. This is address type that should be used for initial connection. If this parameter is not present BR/EDR device is created. Possible values:
|
Implemented in jau.direct_bt.DBTAdapter.
ScanType org.direct_bt.BTAdapter.getCurrentScanType | ( | ) |
Returns the current meta discovering ScanType
.
It can be modified through startDiscovery(DiscoveryPolicy, boolean)
and stopDiscovery()
.
Note that if startDiscovery(DiscoveryPolicy, boolean)
has been issued with keepAlive==true, the meta ScanType
will still keep the desired ScanType
enabled even if it has been temporarily disabled.
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.isDiscovering | ( | ) |
Returns true if the meta discovering state is not ScanType#NONE
.
It can be modified through startDiscovery(DiscoveryPolicy, boolean)
and stopDiscovery()
.
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.addStatusListener | ( | final AdapterStatusListener | listener | ) |
Add the given AdapterStatusListener
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(AdapterStatusListener)
.
The newly added AdapterStatusListener
will receive an initial adapterSettingsChanged
event, passing an empty oldMask and changedMask
, as well as current newMask
.
This allows the receiver to be aware of this adapter's current settings.
listener | A AdapterStatusListener instance |
BTDevice#addStatusListener(AdapterStatusListener)
removeStatusListener(AdapterStatusListener)
removeAllStatusListener()
Implemented in jau.direct_bt.DBTAdapter.
boolean org.direct_bt.BTAdapter.removeStatusListener | ( | final AdapterStatusListener | l | ) |
Remove the given AdapterStatusListener
from the list.
listener | A AdapterStatusListener instance |
Implemented in jau.direct_bt.DBTAdapter.
int org.direct_bt.BTAdapter.removeAllStatusListener | ( | ) |
Remove all AdapterStatusListener
from the list.
Implemented in jau.direct_bt.DBTAdapter.
DBGattServer org.direct_bt.BTAdapter.getGATTServerData | ( | ) |
Return the user's DBGattServer shared reference if in BTRole#Slave
mode as set via and valid until subsequent disconnect.
Returns nullptr if in BTRole#Master
mode.
Implemented in jau.direct_bt.DBTAdapter.
void org.direct_bt.BTAdapter.printDeviceLists | ( | ) |
Print the internally maintained BTDevice lists to stderr:
This is intended as a debug facility.
Implemented in jau.direct_bt.DBTAdapter.
String org.direct_bt.BTAdapter.toString | ( | ) |