Class BluetoothGattCharacteristic
java.lang.Object
com.github.hypfvieh.bluetooth.wrapper.AbstractBluetoothObject
com.github.hypfvieh.bluetooth.wrapper.BluetoothGattCharacteristic
Wrapper class which represents a GATT characteristic on a remote device.
- Author:
- hypfvieh
-
Constructor Summary
ConstructorsConstructorDescriptionBluetoothGattCharacteristic(GattCharacteristic1 _gattCharacteristic, BluetoothGattService _service, String _dbusPath, org.freedesktop.dbus.connections.impl.DBusConnection _dbusConnection) -
Method Summary
Modifier and TypeMethodDescriptiongetFlags()From bluez Documentation:getGattDescriptorByUuid(String _uuid) Return theBluetoothGattDescriptorobject for the given UUID.Get the currently available GATT descriptors.
Will issue a query ifrefreshGattDescriptors()wasn't called before.protected Class<? extends org.freedesktop.dbus.interfaces.DBusInterface> DBus-Interface class used in this wrapper object.Get the rawGattCharacteristic1object behind this wrapper.Returns theBluetoothGattServiceobject which provides thisBluetoothGattCharacteristic.getUuid()From bluez Documentation:byte[]getValue()From bluez Documentation:From bluez Documentation:
True, if notifications or indications on this characteristic are currently enabled.byte[]Read a value from the GATT characteristics register.
Supported options:voidRe-queries the GattCharacteristics from the device.voidFrom bluez Documentation:voidFrom bluez Documentation:toString()voidwriteValue(byte[] _value, Map<String, Object> _options) Write value to the GATT characteristic register.
Supported options:Methods inherited from class com.github.hypfvieh.bluetooth.wrapper.AbstractBluetoothObject
byteListToByteArray, getBluetoothType, getDbusConnection, getDbusPath, getRemoteObjects, getTyped, optionsToVariantMap, setTyped, toPrimitives
-
Constructor Details
-
BluetoothGattCharacteristic
public BluetoothGattCharacteristic(GattCharacteristic1 _gattCharacteristic, BluetoothGattService _service, 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
-
refreshGattDescriptors
public void refreshGattDescriptors()Re-queries the GattCharacteristics from the device. -
getGattDescriptors
Get the currently available GATT descriptors.
Will issue a query ifrefreshGattDescriptors()wasn't called before.- Returns:
- List, maybe empty but never null
-
getGattDescriptorByUuid
Return theBluetoothGattDescriptorobject for the given UUID.- Parameters:
_uuid- uuid- Returns:
- maybe null if not found
-
writeValue
public void writeValue(byte[] _value, Map<String, Object> _options) throws BluezFailedException, BluezInProgressException, BluezNotPermittedException, BluezNotAuthorizedException, BluezNotSupportedException, BluezInvalidValueLengthExceptionWrite value to the GATT characteristic register.
Supported options:
"offset": uint16 offset "device": Object Device (Server only)
- Parameters:
_value- value to write_options- options to use- Throws:
BluezFailedException- on failure if operation failedBluezInProgressException- when operation already in progress if operation is already in progressBluezNotPermittedException- if operation is not permittedBluezNotAuthorizedException- when not authorized if not authorizedBluezNotSupportedException- when operation not supported if not supportedBluezInvalidValueLengthException- if invalid length
-
readValue
public byte[] readValue(Map<String, Object> _options) throws BluezFailedException, BluezInProgressException, BluezNotPermittedException, BluezNotAuthorizedException, BluezNotSupportedException, BluezInvalidOffsetExceptionRead a value from the GATT characteristics register.
Supported options:
"offset": uint16 offset "device": Object Device (Server only)
- Parameters:
_options- options to use- Returns:
- byte array, maybe null
- Throws:
BluezFailedException- on failure if anything failedBluezInProgressException- when operation already in progress if already in progressBluezNotPermittedException- if not permittedBluezNotAuthorizedException- when not authorized if not authorizedBluezNotSupportedException- when operation not supported if not supportedBluezInvalidOffsetException- if offset is invalid
-
getUuid
From bluez Documentation:128-bit characteristic UUID.
- Returns:
- uuid, maybe null
-
getService
Returns theBluetoothGattServiceobject which provides thisBluetoothGattCharacteristic.- Returns:
- GattService, maybe null
-
getRawGattCharacteristic
Get the rawGattCharacteristic1object behind this wrapper.- Returns:
GattCharacteristic1, maybe null
-
getValue
public byte[] getValue()From bluez Documentation:The cached value of the characteristic. This property
gets updated only after a successful read request and
when a notification or indication is received, upon
which a PropertiesChanged signal will be emitted.- Returns:
- cached characteristics value, maybe null
-
isNotifying
From bluez Documentation:
True, if notifications or indications on this characteristic are currently enabled.- Returns:
- maybe null if feature is not supported
-
getFlags
From bluez Documentation:Defines how the characteristic value can be used. See
Core spec "Table 3.5: Characteristic Properties bit
field", and "Table 3.8: Characteristic Extended
Properties bit field".
Allowed values: "broadcast" "read" "write-without-response" "write" "notify" "indicate" "authenticated-signed-writes" "reliable-write" "writable-auxiliaries" "encrypt-read" "encrypt-write" "encrypt-authenticated-read" "encrypt-authenticated-write" "secure-read" (Server only) "secure-write" (Server only)- Returns:
- List of String, maybe null
-
startNotify
public void startNotify() throws BluezFailedException, BluezInProgressException, BluezNotSupportedException, BluezNotPermittedException, BluezNotConnectedExceptionFrom bluez Documentation:Starts a notification session from this characteristic if it supports value notifications or indications.
- Throws:
BluezFailedException- on failure if operation failedBluezInProgressException- when operation already in progress if operation already in progressBluezNotSupportedException- when operation not supported if operation is not supportedBluezNotPermittedException- if access is not permittedBluezNotConnectedException- when bluez is not connected
-
stopNotify
From bluez Documentation:This method will cancel any previous StartNotify transaction. Note that notifications from a characteristic are shared between sessions thus calling StopNotify will release a single session.
- Throws:
BluezFailedException- on failure on any error
-
toString
-