Class AbstractBluetoothObject
java.lang.Object
com.github.hypfvieh.bluetooth.wrapper.AbstractBluetoothObject
- Direct Known Subclasses:
AgentHandler,AgentManager,BluetoothAdapter,BluetoothBattery,BluetoothDevice,BluetoothGattCharacteristic,BluetoothGattDescriptor,BluetoothGattService,ProfileManager
Base class of all bluetooth wrapper object classes.
- Author:
- hypfvieh
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractBluetoothObject(BluetoothDeviceType _bluetoothType, org.freedesktop.dbus.connections.impl.DBusConnection _dbusConnection, String _dbusPath) -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]byteListToByteArray(List<?> _list) org.freedesktop.dbus.connections.impl.DBusConnectionprotected abstract Class<? extends org.freedesktop.dbus.interfaces.DBusInterface> DBus-Interface class used in this wrapper object.getRemoteObjects(Set<String> _objectNames, String _parentPath, Class<T> _type) Helper to get remote objects from DBus.protected <T> THelper to get a value of a DBus property.optionsToVariantMap(Map<String, Object> _options) Convert options for read/write commands to the correct Map-type.
DBus library uses a custom object class names 'variant' which is some sort of wrapper
for any object.protected voidHelper to set a value on a DBus property.protected byte[]toPrimitives(Byte[] oBytes) Convert Byte[] to byte[] array.
-
Constructor Details
-
AbstractBluetoothObject
public AbstractBluetoothObject(BluetoothDeviceType _bluetoothType, org.freedesktop.dbus.connections.impl.DBusConnection _dbusConnection, String _dbusPath)
-
-
Method Details
-
getInterfaceClass
protected abstract Class<? extends org.freedesktop.dbus.interfaces.DBusInterface> getInterfaceClass()DBus-Interface class used in this wrapper object.- Returns:
- class which implements the interface
-
getBluetoothType
-
getDbusPath
-
getDbusConnection
public org.freedesktop.dbus.connections.impl.DBusConnection getDbusConnection() -
getRemoteObjects
protected <T extends org.freedesktop.dbus.interfaces.DBusInterface> Map<String,T> getRemoteObjects(Set<String> _objectNames, String _parentPath, Class<T> _type) Helper to get remote objects from DBus.- Type Parameters:
T- class/interface extendingDBusInterface- Parameters:
_objectNames- Set of object names to retrieve [e.g service0000, service0001]_parentPath- DBus parent path (objectName will be appended) [e.g. /org/bluez/hci0]_type- Expected DBusInterface type [e.g. Device1]- Returns:
- Map of string key and the given interface
-
getTyped
Helper to get a value of a DBus property.- Type Parameters:
T- class of the expected result- Parameters:
_field- DBus property key_type- expected return type of DBus property- Returns:
- value of _field as _type class or null
-
setTyped
Helper to set a value on a DBus property.- Parameters:
_field- DBus property key_value- value to set
-
optionsToVariantMap
protected Map<String,org.freedesktop.dbus.types.Variant<?>> optionsToVariantMap(Map<String, Object> _options) Convert options for read/write commands to the correct Map-type.
DBus library uses a custom object class names 'variant' which is some sort of wrapper
for any object. As the variant class 'allows' specifying the underlying object type, it produces
lots of compiler warnings (rawtype).
To get around that ugly behavior, this library uses Maps with object value.
This method will convert the object values to variant values.- Parameters:
_options- options map- Returns:
- map of variant, maybe empty but never null
-
byteListToByteArray
-
toPrimitives
Convert Byte[] to byte[] array.- Parameters:
oBytes- the array to convert- Returns:
- primitive byte array
-