Class BluetoothDevice
- Author:
- hypfvieh
-
Constructor Summary
ConstructorsConstructorDescriptionBluetoothDevice(Device1 _device, BluetoothAdapter _adapter, String _dbusPath, org.freedesktop.dbus.connections.impl.DBusConnection _dbusConnection) -
Method Summary
Modifier and TypeMethodDescriptionbooleanFrom bluez Documentation:booleanconnect()From bluez Documentation:booleanconnectProfile(String _uuid) From bluez Documentation:booleanFrom bluez Documentation:booleandisconnectProfile(String _uuid) From bluez Documentation:GetBluetoothAdapterobject where thisBluetoothDeviceobject belongs to.Returns the remote devices bluetooth (MAC) address.byte[]The Advertising Data Flags of the remote device.
EXPERIMENTALgetAlias()The current name alias for the remote device.From bluez Documentation:From bluez Documentation:getGattServiceByUuid(String _uuid) Get the givenBluetoothGattServiceinstance by UUID.Return the list of availableBluetoothGattServices.
Will start a query if no list was gathered before.
To re-scan for services userefreshGattServices().getIcon()From bluez Documentation:protected Class<? extends org.freedesktop.dbus.interfaces.DBusInterface> DBus-Interface class used in this wrapper object.Map<org.freedesktop.dbus.types.UInt16, byte[]> From bluez Documentation:From bluez Documentation:getName()Get the bluetooth device name.
This may fail if you not connected to the device, or if the device does not support this operation.
If no name could be retrieved, the alias will be used.
From bluez Documentation:Get the rawDevice1object wrapped by thisBluetoothDeviceobject.getRssi()From bluez Documentation:From bluez Documentation:From bluez Documentation:String[]getUuids()From bluez Documentation:True if incoming connections are rejected, false otherwise.True if device is connected, false otherwise.From bluez Documentation:isPaired()True if the device is currently paired with another device.From bluez Documentation:True if the remote device is trusted, false otherwise.booleanpair()From bluez Documentation:voidRe-queries the list of availableBluetoothGattService's on this device.voidFrom bluez Documentation:voidsetBlocked(Boolean _blocked) From bluez Documentation:voidsetTrusted(boolean _trusted) Set to true to trust the connected device, or to false if you don't.
Default is false.toString()Methods inherited from class com.github.hypfvieh.bluetooth.wrapper.AbstractBluetoothObject
byteListToByteArray, getBluetoothType, getDbusConnection, getDbusPath, getRemoteObjects, getTyped, optionsToVariantMap, setTyped, toPrimitives
-
Constructor Details
-
BluetoothDevice
public BluetoothDevice(Device1 _device, BluetoothAdapter _adapter, String _dbusPath, org.freedesktop.dbus.connections.impl.DBusConnection _dbusConnection)
-
-
Method Details
-
getInterfaceClass
DBus-Interface class used in this wrapper object.- Specified by:
getInterfaceClassin classAbstractBluetoothObject- Returns:
- class which implements the interface
-
getGattServices
Return the list of availableBluetoothGattServices.
Will start a query if no list was gathered before.
To re-scan for services userefreshGattServices().- Returns:
- List, maybe empty but never null
-
refreshGattServices
public void refreshGattServices()Re-queries the list of availableBluetoothGattService's on this device. -
getGattServiceByUuid
Get the givenBluetoothGattServiceinstance by UUID.- Parameters:
_uuid- uuid- Returns:
BluetoothGattService, maybe null if not found
-
getAdapter
GetBluetoothAdapterobject where thisBluetoothDeviceobject belongs to.- Returns:
- adapter
-
getRawDevice
Get the rawDevice1object wrapped by thisBluetoothDeviceobject.- Returns:
- device
-
isBlocked
True if incoming connections are rejected, false otherwise.- Returns:
- maybe null if feature is not supported
-
setBlocked
From bluez Documentation:If set to true any incoming connections from the
device will be immediately rejected. Any device
drivers will also be removed and no new ones will
be probed as long as the device is blocked- Parameters:
_blocked- set blocked status
-
isTrusted
True if the remote device is trusted, false otherwise.- Returns:
- maybe null if feature is not supported
-
setTrusted
public void setTrusted(boolean _trusted) Set to true to trust the connected device, or to false if you don't.
Default is false.- Parameters:
_trusted- set trusted
-
getAlias
The current name alias for the remote device.- Returns:
- alias name
-
setAlias
From bluez Documentation:The name alias for the remote device. The alias can
be used to have a different friendly name for the
remote device.
In case no alias is set, it will return the remote
device name. Setting an empty string as alias will
convert it back to the remote device name.- Parameters:
_alias- alias name to set
-
getAdvertisingFlags
public byte[] getAdvertisingFlags()The Advertising Data Flags of the remote device.
EXPERIMENTAL- Returns:
- byte array maybe null
-
getUuids
From bluez Documentation:List of 128-bit UUIDs that represents the available remote services.
- Returns:
- string array of UUIDs, maybe null
-
isConnected
True if device is connected, false otherwise.- Returns:
- maybe null if feature is not supported
-
isLegacyPairing
From bluez Documentation:Set to true if the device only supports the pre-2.1
pairing mechanism. This property is useful during
device discovery to anticipate whether legacy or
simple pairing will occur if pairing is initiated.
Note that this property can exhibit false-positives
in the case of Bluetooth 2.1 (or newer) devices that
have disabled Extended Inquiry Response support.- Returns:
- maybe null if feature is not supported
-
isPaired
True if the device is currently paired with another device. False otherwise.- Returns:
- boolean, maybe null
-
isServicesResolved
From bluez Documentation:Indicate whether or not service discovery has been resolved.
- Returns:
- maybe null if feature is not supported
-
getServiceData
From bluez Documentation:Service advertisement data. Keys are the UUIDs in string format followed by its byte array value.
- Returns:
- map of string/bytearray, maybe null
-
getManufacturerData
From bluez Documentation:Manufacturer specific advertisement data. Keys are 16 bits Manufacturer ID followed by its byte array value.
- Returns:
- map of uint16/bytearray, maybe null
-
getRssi
From bluez Documentation:Received Signal Strength Indicator of the remote device (inquiry or advertising).
- Returns:
- short, maybe null
-
getTxPower
From bluez Documentation:Advertised transmitted power level (inquiry or advertising).
- Returns:
- short, maybe null
-
getAddress
Returns the remote devices bluetooth (MAC) address.- Returns:
- mac address, maybe null
-
getIcon
From bluez Documentation:Proposed icon name according to the freedesktop.org icon naming specification.
- Returns:
- icon name, maybe null
-
getModAlias
From bluez Documentation:Remote Device ID information in modalias format used by the kernel and udev.
- Returns:
- modalias string, maybe null
-
getName
Get the bluetooth device name.
This may fail if you not connected to the device, or if the device does not support this operation.
If no name could be retrieved, the alias will be used.
From bluez Documentation:The Bluetooth remote name. This value can not be
changed. Use the Alias property instead.
This value is only present for completeness. It is
better to always use the Alias property when
displaying the devices name.
If the Alias property is unset, it will reflect
this value which makes it more convenient.- Returns:
- name, maybe null
-
getAppearance
From bluez Documentation:External appearance of device, as found on GAP service.
- Returns:
- integer, maybe null
-
getBluetoothClass
From bluez Documentation:The Bluetooth class of device of the remote device.
- Returns:
- integer, maybe null
-
connect
public boolean connect()From bluez Documentation:This is a generic method to connect any profiles
the remote device supports that can be connected
to and have been flagged as auto-connectable on
our side. If only subset of profiles is already
connected it will try to connect currently disconnected ones.- Returns:
- true if connected, false otherwise
-
disconnect
public boolean disconnect()From bluez Documentation:This method gracefully disconnects all connected
profiles and then terminates low-level ACL connection.
ACL connection will be terminated even if some profiles
were not disconnected properly e.g. due to misbehaving
device.
This method can be also used to cancel a preceding
Connect call before a reply to it has been received.- Returns:
- true if disconnected false otherwise
-
connectProfile
From bluez Documentation:This method connects a specific profile of this
device. The UUID provided is the remote service
UUID for the profile.- Parameters:
_uuid- profile uuid- Returns:
- true if connected to given profile, false otherwise
-
disconnectProfile
From bluez Documentation:This method disconnects a specific profile of
this device. The profile needs to be registered
client profile.
There is no connection tracking for a profile, so
as long as the profile is registered this will always
succeed.- Parameters:
_uuid- profile uuid- Returns:
- true if profile disconnected, false otherwise
-
pair
public boolean pair()From bluez Documentation:This method will connect to the remote device,
initiate pairing and then retrieve all SDP records
(or GATT primary services).
If the application has registered its own agent,
then that specific agent will be used. Otherwise
it will use the default agent.
Only for applications like a pairing wizard it
would make sense to have its own agent. In almost
all other cases the default agent will handle
this just fine.
In case there is no application agent and also
no default agent present, this method will fail.- Returns:
- true on successful pair, false otherwise
-
cancelPairing
public boolean cancelPairing()From bluez Documentation:This method can be used to cancel a pairing
operation initiated by the Pair method.- Returns:
- true if cancel succeeds, false otherwise
-
toString
-