Class BluetoothAdapter
java.lang.Object
com.github.hypfvieh.bluetooth.wrapper.AbstractBluetoothObject
com.github.hypfvieh.bluetooth.wrapper.BluetoothAdapter
Wrapper class which represents an bluetooth adapter.
- Author:
- hypfvieh
-
Constructor Summary
ConstructorsConstructorDescriptionBluetoothAdapter(Adapter1 _adapter, String _dbusPath, org.freedesktop.dbus.connections.impl.DBusConnection _dbusConnection) -
Method Summary
Modifier and TypeMethodDescriptionReturns the bluetooth device (MAC) address.getAlias()The changeable bluetooth friendly name.From bluez Documentation:Get the deviceName used in DBus (e.g. hci0).The current timeout (in seconds) configured before disabling discoverbility.
If 0 discoverbility will never be disabled automatically.protected Class<? extends org.freedesktop.dbus.interfaces.DBusInterface> DBus-Interface class used in this wrapper object.From bluez Documentation:getName()From bluez Documentation:Current configured timeout (in seconds) before the pairable mode is disabled.
If 0, timeout is disabled and pairability will never be disabled.Get the rawAdapter1object wrapped by thisBluetoothAdapterobject.String[]getUuids()From bluez Documentation:True if device is discoverable (= visible for others), false otherwise.True if discovery procedure is active, false otherwise.True if pairing with this adapter is allowed for others.booleanReturns if the adapter is powered on (true) or powered off (false).voidremoveDevice(Device1 _device) Remove a device and it's pairing information.voidChange the current bluetooth friendly name.voidsetDiscoverable(boolean _discoverable) Set to true to enable device visibility for other bluetooth devices nearby.voidsetDiscoverableTimeout(Integer _discoverableTimeout) Timeout (in seconds) to set before the device visibility for others will be disabled.
If set to 0, device will stay visible forever.voidsetDiscoveryFilter(Map<String, org.freedesktop.dbus.types.Variant<?>> _filter) Use this to set a discovery filter.
This will cause the bluez library to only add device objects which are matching the given criterias.
Support values for the Map:voidsetPairable(boolean _pairable) Set to true to allow pairing of other devices with this adapter.
This is a global setting and effects all applications using this adapter.voidsetPairableTimeout(Integer _pairableTimeout) Set the timeout (in seconds) before the pairable mode is disabled.
Setting this to 0 disables the timeout.voidsetPowered(boolean _powered) Turn adapter on (true) or off (false).booleanStart a new discovery operation to find any devices nearby.booleanStops the current discovery operation.toString()Methods inherited from class com.github.hypfvieh.bluetooth.wrapper.AbstractBluetoothObject
byteListToByteArray, getBluetoothType, getDbusConnection, getDbusPath, getRemoteObjects, getTyped, optionsToVariantMap, setTyped, toPrimitives
-
Constructor Details
-
BluetoothAdapter
-
-
Method Details
-
getInterfaceClass
DBus-Interface class used in this wrapper object.- Specified by:
getInterfaceClassin classAbstractBluetoothObject- Returns:
- class which implements the interface
-
getRawAdapter
Get the rawAdapter1object wrapped by thisBluetoothAdapterobject.- Returns:
- adapter
-
getDeviceName
Get the deviceName used in DBus (e.g. hci0).- Returns:
- the device name
-
getAlias
The changeable bluetooth friendly name.- Returns:
- the alias name
-
setAlias
Change the current bluetooth friendly name.- Parameters:
_alias- new alias to set
-
isPowered
public boolean isPowered()Returns if the adapter is powered on (true) or powered off (false).- Returns:
- power status
-
setPowered
public void setPowered(boolean _powered) Turn adapter on (true) or off (false).- Parameters:
_powered- set power status
-
isDiscoverable
True if device is discoverable (= visible for others), false otherwise.- Returns:
- maybe null if feature is not supported
-
setDiscoverable
public void setDiscoverable(boolean _discoverable) Set to true to enable device visibility for other bluetooth devices nearby.- Parameters:
_discoverable- set device visible for others
-
getDiscoverableTimeout
The current timeout (in seconds) configured before disabling discoverbility.
If 0 discoverbility will never be disabled automatically.- Returns:
- integer maybe null
-
setDiscoverableTimeout
Timeout (in seconds) to set before the device visibility for others will be disabled.
If set to 0, device will stay visible forever.- Parameters:
_discoverableTimeout- timeout to set
-
isPairable
True if pairing with this adapter is allowed for others.- Returns:
- maybe null if feature is not supported
-
setPairable
public void setPairable(boolean _pairable) Set to true to allow pairing of other devices with this adapter.
This is a global setting and effects all applications using this adapter.- Parameters:
_pairable- set pairing
-
getPairableTimeout
Current configured timeout (in seconds) before the pairable mode is disabled.
If 0, timeout is disabled and pairability will never be disabled.- Returns:
- integer maybe null
-
setPairableTimeout
Set the timeout (in seconds) before the pairable mode is disabled.
Setting this to 0 disables the timeout.- Parameters:
_pairableTimeout- set pairable timeout
-
getAddress
Returns the bluetooth device (MAC) address.- Returns:
- mac address, maybe null
-
getName
From bluez Documentation:The Bluetooth system name (pretty hostname). This property is either a static system default or controlled by an external daemon providing access to the pretty hostname configuration.
- Returns:
- name, maybe null
-
getDeviceClass
From bluez Documentation:The Bluetooth class of device. This property represents the value that is either automatically configured by DMI/ACPI information or provided as static configuration.
- Returns:
- integer, maybe null
-
isDiscovering
True if discovery procedure is active, false otherwise.- Returns:
- discovering status
-
getUuids
From bluez Documentation:List of 128-bit UUIDs that represents the available local services.
- Returns:
- String[], maybe null
-
getModAlias
From bluez Documentation:Local Device ID information in modalias format used by the kernel and udev.
- Returns:
- String, maybe null
-
startDiscovery
public boolean startDiscovery()Start a new discovery operation to find any devices nearby.- Returns:
- true if discovery is running, false otherwise
-
stopDiscovery
public boolean stopDiscovery()Stops the current discovery operation.- Returns:
- true if discovery was stopped, false otherwise
-
removeDevice
public void removeDevice(Device1 _device) throws BluezFailedException, BluezInvalidArgumentsException Remove a device and it's pairing information.- Parameters:
_device- device to remove- Throws:
BluezFailedException- on failure when something went wrongBluezInvalidArgumentsException- when argument is invalid when device was invalid
-
setDiscoveryFilter
public void setDiscoveryFilter(Map<String, org.freedesktop.dbus.types.Variant<?>> _filter) throws BluezInvalidArgumentsException, BluezNotReadyException, BluezNotSupportedException, BluezFailedExceptionUse this to set a discovery filter.
This will cause the bluez library to only add device objects which are matching the given criterias.
Support values for the Map:
Type KeyName : Purpose ============================================ String[] UUIDs : filtered service UUIDs Short RSSI : RSSI threshold value UInt16 Pathloss : Pathloss threshold value String Transport : type of scan to run
The 'Transport' Key supports the following options:Value - Description ============================================ "auto" - interleaved scan, default value "bredr" - BR/EDR inquiry "le" - LE scan only
If a transport mode is used which is not supported by the device, aBluezNotSupportedExceptionis thrown.- Parameters:
_filter- filter to use- Throws:
BluezInvalidArgumentsException- when argument is invalid thrown if any arguments in the map are not supportedBluezNotReadyException- when bluez not ready if adapter not readyBluezNotSupportedException- when operation not supported if operation not supportedBluezFailedException- on failure any other error
-
toString
-