Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
jau.direct_bt.DBTManager Class Reference
Inheritance diagram for jau.direct_bt.DBTManager:
Collaboration diagram for jau.direct_bt.DBTManager:

Public Member Functions

final Settings getSettings ()
 Returns this implmentation's Settings. More...
 
BTType getBluetoothType ()
 
DBTObject find (final BTType type, final String name, final String identifier, final BTObject parent, final long timeoutMS)
 Find a BluetoothObject of a type matching type. More...
 
DBTObject find (final BTType type, final String name, final String identifier, final BTObject parent)
 Find a BluetoothObject of a type matching type. More...
 
List< BTAdaptergetAdapters ()
 Returns a list of BluetoothAdapters available in the system. More...
 
BTAdapter getAdapter (final int dev_id)
 Returns the BluetoothAdapter matching the given dev_id or null if not found. More...
 
List< BTDevicegetDevices ()
 Returns a list of discovered BluetoothDevices. More...
 
List< BTGattServicegetServices ()
 Returns a list of available BluetoothGattServices.
Returns
A list of available BluetoothGattServices
More...
 
boolean setDefaultAdapter (final BTAdapter adapter)
 Sets a default adapter to use for discovery. More...
 
BTAdapter getDefaultAdapter ()
 Gets the default adapter to use for discovery. More...
 
HCIStatusCode startDiscovery (final boolean keepAlive, final boolean le_scan_active) throws BTException
 Turns on device discovery on the default adapter if it is disabled. More...
 
HCIStatusCode stopDiscovery () throws BTException
 Turns off device discovery on the default adapter if it is enabled. More...
 
final ScanType getCurrentScanType ()
 Returns the current meta discovering ScanType of the getDefaultAdapter() via BTAdapter#getCurrentScanType(). More...
 
final void addChangedAdapterSetListener (final ChangedAdapterSetListener l)
 Add the given ChangedAdapterSetListener to this manager. More...
 
final int removeChangedAdapterSetListener (final ChangedAdapterSetListener l)
 Remove the given ChangedAdapterSetListener from this manager. More...
 
void shutdown ()
 Release the native memory associated with this object and all related Bluetooth resources. More...
 

Static Public Member Functions

static final boolean isJVMShuttingDown ()
 Returns true if the JVM is shutting down, otherwise false. More...
 
static void addShutdownHook (final boolean head, final Runnable runnable)
 Add a shutdown hook to be performed at JVM shutdown before shutting down DBTManager instance. More...
 
static boolean getUnifyUUID128Bit ()
 Returns whether uuid128_t consolidation is enabled for native uuid16_t and uuid32_t values before string conversion. More...
 
static void setUnifyUUID128Bit (final boolean v)
 Enables or disables uuid128_t consolidation for native uuid16_t and uuid32_t values before string conversion. More...
 
static BTManager getManager () throws RuntimeException, BTException
 Returns an instance of BluetoothManager, to be used instead of constructor. More...
 

Protected Member Functions

void finalize ()
 

Static Protected Attributes

static final boolean DEBUG = BTFactory.DEBUG
 
static final boolean VERBOSE = BTFactory.VERBOSE
 

Detailed Description

Definition at line 50 of file DBTManager.java.

Member Function Documentation

◆ addChangedAdapterSetListener()

final void jau.direct_bt.DBTManager.addChangedAdapterSetListener ( final ChangedAdapterSetListener  l)

Add the given ChangedAdapterSetListener to this manager.

When a new callback is added, all available adapter's will be reported as added, this allows a fully event driven workflow.

The callback is performed on a dedicated thread, allowing the user to perform complex operations.

Since
2.0.0

Implements org.direct_bt.BTManager.

Definition at line 254 of file DBTManager.java.

Here is the call graph for this function:

◆ addShutdownHook()

static void jau.direct_bt.DBTManager.addShutdownHook ( final boolean  head,
final Runnable  runnable 
)
static

Add a shutdown hook to be performed at JVM shutdown before shutting down DBTManager instance.

Parameters
headif true add runnable at the start, otherwise at the end
runnablerunnable to be added.

Definition at line 123 of file DBTManager.java.

◆ finalize()

void jau.direct_bt.DBTManager.finalize ( )
protected

Definition at line 407 of file DBTManager.java.

Here is the call graph for this function:

◆ find() [1/2]

DBTObject jau.direct_bt.DBTManager.find ( final BTType  type,
final String  name,
final String  identifier,
final BTObject  parent 
)

Find a BluetoothObject of a type matching type.

If parameters name, identifier and parent 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 type specify the type of the object you are waiting for, NONE means anything. @parameter name optionally specify the name of the object you are waiting for (for Adapter or Device) @parameter identifier optionally specify the identifier of the object you are waiting for (UUID for GattService, GattCharacteristic or GattDescriptor, address for Adapter or Device) @parameter parent optionally specify the parent of the object you are waiting for

Returns
An object matching the name, identifier and parent.

Implements org.direct_bt.BTManager.

Definition at line 172 of file DBTManager.java.

Here is the call graph for this function:

◆ find() [2/2]

DBTObject jau.direct_bt.DBTManager.find ( final BTType  type,
final String  name,
final String  identifier,
final BTObject  parent,
final long  timeoutMS 
)

Find a BluetoothObject of a type matching type.

If parameters name, identifier and parent 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 type specify the type of the object you are waiting for, NONE means anything. @parameter name optionally specify the name of the object you are waiting for (for Adapter or Device) @parameter identifier optionally specify the identifier of the object you are waiting for (UUID for GattService, GattCharacteristic or GattDescriptor, address for Adapter or Device) @parameter parent optionally specify the parent of the object 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.

Returns
An object matching the name, identifier, parent or null if not found before timeout expires or event is canceled.

Implements org.direct_bt.BTManager.

Definition at line 167 of file DBTManager.java.

Here is the caller graph for this function:

◆ getAdapter()

BTAdapter jau.direct_bt.DBTManager.getAdapter ( final int  dev_id)

Returns the BluetoothAdapter matching the given dev_id or null if not found.

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

Parameters
dev_idthe internal temporary adapter device id
Since
2.0.0

Implements org.direct_bt.BTManager.

Definition at line 180 of file DBTManager.java.

Here is the call graph for this function:

◆ getAdapters()

List<BTAdapter> jau.direct_bt.DBTManager.getAdapters ( )

Returns a list of BluetoothAdapters available in the system.

Returns
A list of BluetoothAdapters available in the system

Implements org.direct_bt.BTManager.

Definition at line 177 of file DBTManager.java.

◆ getBluetoothType()

BTType jau.direct_bt.DBTManager.getBluetoothType ( )

Definition at line 164 of file DBTManager.java.

◆ getCurrentScanType()

final ScanType jau.direct_bt.DBTManager.getCurrentScanType ( )

Returns the current meta discovering ScanType of the getDefaultAdapter() via BTAdapter#getCurrentScanType().

See also
BTAdapter::getCurrentScanType()
getDefaultAdapter()
Since
2.3

Implements org.direct_bt.BTManager.

Definition at line 249 of file DBTManager.java.

Here is the call graph for this function:

◆ getDefaultAdapter()

BTAdapter jau.direct_bt.DBTManager.getDefaultAdapter ( )

Gets the default adapter to use for discovery.

The default adapter is either the first powered BTAdapter, or function returns nullptr if none is enabled.

Returns
the used default adapter

Implements org.direct_bt.BTManager.

Definition at line 230 of file DBTManager.java.

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

◆ getDevices()

List<BTDevice> jau.direct_bt.DBTManager.getDevices ( )

Returns a list of discovered BluetoothDevices.

Returns
A list of discovered BluetoothDevices

Implements org.direct_bt.BTManager.

Definition at line 191 of file DBTManager.java.

Here is the call graph for this function:

◆ getManager()

static BTManager jau.direct_bt.DBTManager.getManager ( ) throws RuntimeException, BTException
static

Returns an instance of BluetoothManager, to be used instead of constructor.

Returns
An initialized BluetoothManager instance.

Definition at line 398 of file DBTManager.java.

Here is the caller graph for this function:

◆ getServices()

List<BTGattService> jau.direct_bt.DBTManager.getServices ( )

Returns a list of available BluetoothGattServices.

Returns
A list of available BluetoothGattServices

This call could be a quite expensive service query, see below.

This implementation returns all BTGattService from all BTDevices from the getDefaultAdapter() using BTDevice#getServices().

This implementation does not start an explicit discovery, but previous discovered devices are being queried.

Implements org.direct_bt.BTManager.

Definition at line 208 of file DBTManager.java.

Here is the call graph for this function:

◆ getSettings()

final Settings jau.direct_bt.DBTManager.getSettings ( )

Returns this implmentation's Settings.

Implements org.direct_bt.BTManager.

Definition at line 162 of file DBTManager.java.

◆ getUnifyUUID128Bit()

static boolean jau.direct_bt.DBTManager.getUnifyUUID128Bit ( )
static

Returns whether uuid128_t consolidation is enabled for native uuid16_t and uuid32_t values before string conversion.

See also
setUnifyUUID128Bit(boolean)

Definition at line 140 of file DBTManager.java.

◆ isJVMShuttingDown()

static final boolean jau.direct_bt.DBTManager.isJVMShuttingDown ( )
static

Returns true if the JVM is shutting down, otherwise false.

Definition at line 115 of file DBTManager.java.

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

◆ removeChangedAdapterSetListener()

final int jau.direct_bt.DBTManager.removeChangedAdapterSetListener ( final ChangedAdapterSetListener  l)

Remove the given ChangedAdapterSetListener from this manager.

Parameters
lthe to be removed element
Returns
the number of removed elements
Since
2.0.0

Implements org.direct_bt.BTManager.

Definition at line 266 of file DBTManager.java.

◆ setDefaultAdapter()

boolean jau.direct_bt.DBTManager.setDefaultAdapter ( final BTAdapter  adapter)

Sets a default adapter to use for discovery.

Returns
TRUE if the device was set @implNote not implemented for jau.direct_bt

Implements org.direct_bt.BTManager.

Definition at line 225 of file DBTManager.java.

◆ setUnifyUUID128Bit()

static void jau.direct_bt.DBTManager.setUnifyUUID128Bit ( final boolean  v)
static

Enables or disables uuid128_t consolidation for native uuid16_t and uuid32_t values before string conversion.

Default is

true

.

If desired, this value should be set once before the first call of getManager()!

See also
getUnifyUUID128Bit()

Definition at line 153 of file DBTManager.java.

◆ shutdown()

void jau.direct_bt.DBTManager.shutdown ( )

Release the native memory associated with this object and all related Bluetooth resources.

The object should not be used following a call to close

Shutdown method is intended to allow a clean Bluetooth state at program exist.

Implements org.direct_bt.BTManager.

Definition at line 412 of file DBTManager.java.

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

◆ startDiscovery()

HCIStatusCode jau.direct_bt.DBTManager.startDiscovery ( final boolean  keepAlive,
final boolean  le_scan_active 
) throws BTException

Turns on device discovery on the default adapter if it is disabled.

Parameters
keepAliveif
true
, indicates that discovery shall be restarted if stopped by the underlying Bluetooth implementation (BlueZ, ..). Using startDiscovery(
keepAlive=true
) and stopDiscovery() is the recommended workflow for a reliable discovery process.
le_scan_activetrue enables delivery of active scanning PDUs, otherwise no scanning PDUs shall be sent (default)
Returns
HCIStatusCode#SUCCESS if successful, otherwise the HCIStatusCode error state
Exceptions
BTException
Since
2.0.0
2.2.8

Implements org.direct_bt.BTManager.

Definition at line 241 of file DBTManager.java.

Here is the call graph for this function:

◆ stopDiscovery()

HCIStatusCode jau.direct_bt.DBTManager.stopDiscovery ( ) throws BTException

Turns off device discovery on the default adapter if it is enabled.

Returns
HCIStatusCode#SUCCESS if successful, otherwise the HCIStatusCode error state @apiNote return HCIStatusCode since 2.0.0
Since
2.0.0

Implements org.direct_bt.BTManager.

Definition at line 246 of file DBTManager.java.

Here is the call graph for this function:

Member Data Documentation

◆ DEBUG

final boolean jau.direct_bt.DBTManager.DEBUG = BTFactory.DEBUG
staticprotected

Definition at line 52 of file DBTManager.java.

◆ VERBOSE

final boolean jau.direct_bt.DBTManager.VERBOSE = BTFactory.VERBOSE
staticprotected

Definition at line 53 of file DBTManager.java.


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