Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Public Member Functions | Protected Member Functions | List of all members
jau.direct_bt.DBTGattChar Class Reference
Inheritance diagram for jau.direct_bt.DBTGattChar:
Collaboration diagram for jau.direct_bt.DBTGattChar:

Public Member Functions

final boolean addCharListener (final BTGattCharListener listener)
 Add the given BTGattCharListener to the listener list if not already present. More...
 
final boolean addCharListener (final BTGattCharListener listener, final boolean enabledState[])
 Add the given BTGattCharListener to the listener list if not already present and if enabling the notification or indication for this characteristic at BLE level was successful. More...
 
synchronized void close ()
 Release the native memory associated with this object The object should not be used following a call to close. More...
 
final synchronized boolean configNotificationIndication (final boolean enableNotification, final boolean enableIndication, final boolean enabledState[]) throws IllegalStateException
 BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration. More...
 
boolean disableIndicationNotification () throws IllegalStateException
 BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration. More...
 
boolean enableNotificationOrIndication (final boolean enabledState[]) throws IllegalStateException
 BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration. More...
 
boolean equals (final Object obj)
 
BTGattDesc findGattDesc (final String desc_uuid)
 Find a BTGattDesc by its desc_uuid. More...
 
final BTGattDesc getClientCharConfig ()
 Return the Client Characteristic Configuration BTGattDesc if available or null. More...
 
final List< BTGattDescgetDescriptors ()
 Returns a list of BluetoothGattDescriptors this characteristic exposes. More...
 
final short getHandle ()
 Characteristic Handle of this instance. More...
 
final boolean getNotifying (final boolean enabledState[])
 Returns true if notification for changes of this characteristic are activated. More...
 
final GattCharPropertySet getProperties ()
 Returns the properties of this characteristic. More...
 
final BTGattService getService ()
 Returns the service to which this characteristic belongs to. More...
 
final BTGattDesc getUserDescription ()
 Return the User Description BTGattDesc if available or null. More...
 
String getUUID ()
 Get the UUID of this characteristic. More...
 
final short getValueHandle ()
 Returns Characteristics Value Handle. More...
 
final byte[] readValue () throws BTException
 Reads the value of this characteristic. More...
 
final int removeAllAssociatedCharListener (final boolean shallDisableIndicationNotification)
 Disables the notification and/or indication for this characteristic BLE level if disableIndicationNotification == true and removes all associated BTGattChar.Listener or BTGattCharListener from the listener list, which are associated with this characteristic instance. More...
 
final boolean removeCharListener (final BTGattCharListener listener)
 Remove the given associated BTGattCharListener from the listener list if present. More...
 
final String toString ()
 
final boolean writeValue (final byte[] value, final boolean withResponse) throws BTException
 Writes the value of this characteristic, using one of the following methods depending on withResponse @endiliteral.
More...
 
- Public Member Functions inherited from jau.direct_bt.DBTObject
synchronized void close ()
 Release the native memory associated with this object The object should not be used following a call to close. More...
 
abstract boolean equals (final Object obj)
 
final int hashCode ()
 
void close ()
 Release the native memory associated with this object The object should not be used following a call to close. More...
 
boolean equals (Object obj)
 
int hashCode ()
 
boolean addCharListener (final BTGattCharListener listener) throws IllegalStateException
 Add the given BTGattCharListener to the listener list if not already present. More...
 
boolean addCharListener (final BTGattCharListener listener, final boolean enabledState[]) throws IllegalStateException
 Add the given BTGattCharListener to the listener list if not already present and if enabling the notification or indication for this characteristic at BLE level was successful. More...
 
boolean configNotificationIndication (final boolean enableNotification, final boolean enableIndication, final boolean enabledState[]) throws IllegalStateException
 BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration. More...
 
boolean disableIndicationNotification () throws IllegalStateException
 BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration. More...
 
boolean enableNotificationOrIndication (final boolean enabledState[]) throws IllegalStateException
 BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration. More...
 
BTGattDesc findGattDesc (final String desc_uuid)
 Find a BTGattDesc by its desc_uuid. More...
 
BTGattDesc getClientCharConfig ()
 Return the Client Characteristic Configuration BTGattDesc if available or null. More...
 
List< BTGattDescgetDescriptors ()
 Returns a list of BluetoothGattDescriptors this characteristic exposes. More...
 
boolean getNotifying (final boolean enabledState[])
 Returns true if notification for changes of this characteristic are activated. More...
 
GattCharPropertySet getProperties ()
 Returns the properties of this characteristic. More...
 
BTGattService getService ()
 Returns the service to which this characteristic belongs to. More...
 
BTGattDesc getUserDescription ()
 Return the User Description BTGattDesc if available or null. More...
 
String getUUID ()
 Get the UUID of this characteristic. More...
 
byte[] readValue () throws BTException
 Reads the value of this characteristic. More...
 
int removeAllAssociatedCharListener (final boolean shallDisableIndicationNotification)
 Disables the notification and/or indication for this characteristic BLE level if disableIndicationNotification == true and removes all associated BTGattChar.Listener or BTGattCharListener from the listener list, which are associated with this characteristic instance. More...
 
boolean removeCharListener (final BTGattCharListener listener)
 Remove the given associated BTGattCharListener from the listener list if present. More...
 
String toString ()
 
boolean writeValue (byte[] argValue, boolean withResponse) throws BTException
 Writes the value of this characteristic, using one of the following methods depending on withResponse @endiliteral.
More...
 

Protected Member Functions

native void deleteImpl (long nativeInstance)
 Deletes the native instance. More...
 
- Protected Member Functions inherited from jau.direct_bt.DBTObject
 DBTObject (final long nativeInstance, final int hashValue)
 
void finalize ()
 

Detailed Description

Definition at line 39 of file DBTGattChar.java.

Member Function Documentation

◆ deleteImpl()

native void jau.direct_bt.DBTGattChar.deleteImpl ( long  nativeInstance)
protected

Deletes the native instance.

Called via delete() and at this point

  • this java reference has been removed from the native instance, i.e. JavaUplink's javaObjectRef = nullptr
  • the nativeInstance reference has been zeroed, but passed as argument for this final native deletion task.
Parameters
nativeInstancecopy of nativeInstance reference, which has been already zeroed.

Reimplemented from jau.direct_bt.DBTNativeDownlink.

◆ close()

synchronized void jau.direct_bt.DBTGattChar.close ( )

Release the native memory associated with this object The object should not be used following a call to close.

Reimplemented from jau.direct_bt.DBTObject.

Definition at line 124 of file DBTGattChar.java.

◆ equals()

boolean jau.direct_bt.DBTGattChar.equals ( final Object  obj)

Reimplemented from jau.direct_bt.DBTObject.

Definition at line 133 of file DBTGattChar.java.

◆ getUUID()

String jau.direct_bt.DBTGattChar.getUUID ( )

Get the UUID of this characteristic.

Returns
The 128 byte UUID of this characteristic, NULL if an error occurred

Implements org.direct_bt.BTGattChar.

Definition at line 143 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ findGattDesc()

BTGattDesc jau.direct_bt.DBTGattChar.findGattDesc ( final String  desc_uuid)

Find a BTGattDesc by its desc_uuid.

@parameter desc_uuid the UUID of the desired BTGattDesc

Returns
The matching descriptor or null if not found

Implements org.direct_bt.BTGattChar.

Definition at line 146 of file DBTGattChar.java.

◆ getService()

final BTGattService jau.direct_bt.DBTGattChar.getService ( )

Returns the service to which this characteristic belongs to.

Returns
The service.

Implements org.direct_bt.BTGattChar.

Definition at line 166 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ getNotifying()

final boolean jau.direct_bt.DBTGattChar.getNotifying ( final boolean  enabledState[])

Returns true if notification for changes of this characteristic are activated.

Parameters
enabledStatearray of size 2, storage for the current enabled state for notification and indication.
Returns
True if either notification or indication is enabled

Implements org.direct_bt.BTGattChar.

Definition at line 169 of file DBTGattChar.java.

◆ getProperties()

final GattCharPropertySet jau.direct_bt.DBTGattChar.getProperties ( )

Returns the properties of this characteristic.

BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.1.1 Characteristic Properties

Implements org.direct_bt.BTGattChar.

Definition at line 176 of file DBTGattChar.java.

◆ getDescriptors()

final List< BTGattDesc > jau.direct_bt.DBTGattChar.getDescriptors ( )

Returns a list of BluetoothGattDescriptors this characteristic exposes.

Returns
A list of BluetoothGattDescriptors exposed by this characteristic NULL if an error occurred

Implements org.direct_bt.BTGattChar.

Definition at line 179 of file DBTGattChar.java.

◆ configNotificationIndication()

final synchronized boolean jau.direct_bt.DBTGattChar.configNotificationIndication ( final boolean  enableNotification,
final boolean  enableIndication,
final boolean  enabledState[] 
) throws IllegalStateException

BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration.

Method enables notification and/or indication for this characteristic at BLE level.

Implementation masks this Characteristic properties PropertyBitVal::Notify and PropertyBitVal::Indicate with the respective user request parameters, hence removes unsupported requests.

Notification and/or indication configuration is only performed per characteristic if changed.

It is recommended to utilize notification over indication, as its link-layer handshake and higher potential bandwidth may deliver material higher performance.

Parameters
enableNotification
enableIndication
enabledStatearray of size 2, holding the resulting enabled state for notification and indication.
Returns
false if this characteristic has no PropertyBitVal::Notify or PropertyBitVal::Indication present, or there is no GATTDescriptor of type ClientCharacteristicConfiguration, or if the operation has failed. Otherwise returns true.
Exceptions
IllegalStateExceptionif notification or indication is set to be enabled and the BTDevice's GATTHandler is null, i.e. not connected
See also
disableIndicationNotification()
enableNotificationOrIndication(boolean[])
configNotificationIndication(boolean, boolean, boolean[])
addCharListener(BTGattCharListener) #see addCharListener(BTGattCharListener, boolean[])
removeCharListener(BTGattCharListener)
removeAllAssociatedCharListener(boolean)
Since
2.0.0

Implements org.direct_bt.BTGattChar.

Definition at line 182 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ enableNotificationOrIndication()

boolean jau.direct_bt.DBTGattChar.enableNotificationOrIndication ( final boolean  enabledState[]) throws IllegalStateException

BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration.

Method will attempt to enable notification on the BLE level, if available, otherwise indication if available.

Notification and/or indication configuration is only performed per characteristic if changed.

It is recommended to utilize notification over indication, as its link-layer handshake and higher potential bandwidth may deliver material higher performance.

Parameters
enabledStatearray of size 2, holding the resulting enabled state for notification and indication.
Returns
false if this characteristic has no PropertyBitVal::Notify or PropertyBitVal::Indication present, or there is no GATTDescriptor of type ClientCharacteristicConfiguration, or if the operation has failed. Otherwise returns true.
Exceptions
IllegalStateExceptionif notification or indication is set to be enabled and the BTDevice's GATTHandler is null, i.e. not connected
See also
disableIndicationNotification()
enableNotificationOrIndication(boolean[])
configNotificationIndication(boolean, boolean, boolean[])
addCharListener(BTGattCharListener) #see addCharListener(BTGattCharListener, boolean[])
removeCharListener(BTGattCharListener)
removeAllAssociatedCharListener(boolean)
Since
2.0.0

Implements org.direct_bt.BTGattChar.

Definition at line 232 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ disableIndicationNotification()

boolean jau.direct_bt.DBTGattChar.disableIndicationNotification ( ) throws IllegalStateException

BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration.

Method will attempt to disable notification and indication on the BLE level.

Notification and/or indication configuration is only performed per characteristic if changed.

Returns
false if this characteristic has no PropertyBitVal::Notify or PropertyBitVal::Indication present, or there is no BTGattDesc of type ClientCharacteristicConfiguration, or if the operation has failed. Otherwise returns true.
Exceptions
IllegalStateExceptionif notification or indication is set to be enabled and the BTDevice's GATTHandler is null, i.e. not connected
See also
disableIndicationNotification()
enableNotificationOrIndication(boolean[])
configNotificationIndication(boolean, boolean, boolean[])
addCharListener(BTGattCharListener) #see addCharListener(BTGattCharListener, boolean[])
removeCharListener(BTGattCharListener)
removeAllAssociatedCharListener(boolean)
Since
2.4.0

Implements org.direct_bt.BTGattChar.

Definition at line 242 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ addCharListener() [1/2]

final boolean jau.direct_bt.DBTGattChar.addCharListener ( final BTGattCharListener  listener)

Add the given BTGattCharListener to the listener list if not already present.

Occurring notifications and indications for this characteristic, if enabled via configNotificationIndication(boolean, boolean, boolean[]) or enableNotificationOrIndication(boolean[]), will call the respective BTGattCharListener callback method.

Returns true if the given listener is not element of the list and has been newly added, otherwise false.

Parameters
listenerA BTGattCharListener} instance, listening to this BTGattChar's events
Returns
if successful, true is being returned, otherwise false.
Exceptions
IllegalStateExceptionif the DBTDevice's GATTHandler is null, i.e. not connected
See also
disableIndicationNotification()
enableNotificationOrIndication(boolean[])
configNotificationIndication(boolean, boolean, boolean[])
addCharListener(BTGattCharListener) #see addCharListener(BTGattCharListener, boolean[])
removeCharListener(BTGattCharListener)
removeAllAssociatedCharListener(boolean)
Since
2.4.0

Implements org.direct_bt.BTGattChar.

Definition at line 247 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ addCharListener() [2/2]

final boolean jau.direct_bt.DBTGattChar.addCharListener ( final BTGattCharListener  listener,
final boolean  enabledState[] 
)

Add the given BTGattCharListener to the listener list if not already present and if enabling the notification or indication for this characteristic at BLE level was successful.


Notification and/or indication configuration is only performed per characteristic if changed.

Implementation will enable notification if available, otherwise indication will be enabled if available.
Implementation uses enableNotificationOrIndication(boolean[]) to enable either.

Occurring notifications and indications for this characteristic will call the respective BTGattCharListener callback method.

Returns true if enabling the notification and/or indication was successful and if the given listener is not element of the list and has been newly added, otherwise false.

Parameters
listenerA BTGattChar.Listener instance, listening to this BTGattChar's events
enabledStatearray of size 2, holding the resulting enabled state for notification and indication using enableNotificationOrIndication(boolean[])
Returns
if successful, true is being returned, otherwise false.
Exceptions
IllegalStateExceptionif the BTDevice's GATTHandler is null, i.e. not connected
IllegalStateExceptionif the given BTGattChar.Listener is already in use, i.e. added.
See also
disableIndicationNotification()
enableNotificationOrIndication(boolean[])
configNotificationIndication(boolean, boolean, boolean[])
addCharListener(BTGattCharListener) #see addCharListener(BTGattCharListener, boolean[])
removeCharListener(BTGattCharListener)
removeAllAssociatedCharListener(boolean)
Since
2.4.0

Implements org.direct_bt.BTGattChar.

Definition at line 252 of file DBTGattChar.java.

◆ removeCharListener()

final boolean jau.direct_bt.DBTGattChar.removeCharListener ( final BTGattCharListener  listener)

Remove the given associated BTGattCharListener from the listener list if present.

To disables the notification and/or indication for this characteristic at BLE level use disableIndicationNotification() when desired.

Parameters
listenerreturned BTGattCharListener from addCharListener(Listener) ...
Returns
true if successful, otherwise false.
See also
disableIndicationNotification()
enableNotificationOrIndication(boolean[])
configNotificationIndication(boolean, boolean, boolean[])
addCharListener(BTGattCharListener) #see addCharListener(BTGattCharListener, boolean[])
removeCharListener(BTGattCharListener)
removeAllAssociatedCharListener(boolean)
Since
2.4.0

Implements org.direct_bt.BTGattChar.

Definition at line 260 of file DBTGattChar.java.

◆ removeAllAssociatedCharListener()

final int jau.direct_bt.DBTGattChar.removeAllAssociatedCharListener ( final boolean  shallDisableIndicationNotification)

Disables the notification and/or indication for this characteristic BLE level if disableIndicationNotification == true and removes all associated BTGattChar.Listener or BTGattCharListener from the listener list, which are associated with this characteristic instance.

If the DBTDevice's GATTHandler is null, i.e. not connected, false is being returned.

Parameters
shallDisableIndicationNotificationif true, disables the notification and/or indication for this characteristic using disableIndicationNotification()
Returns
number of removed listener.
See also
disableIndicationNotification()
enableNotificationOrIndication(boolean[])
configNotificationIndication(boolean, boolean, boolean[])
addCharListener(BTGattCharListener) #see addCharListener(BTGattCharListener, boolean[])
removeCharListener(BTGattCharListener)
removeAllAssociatedCharListener(boolean)
Since
2.0.0

Implements org.direct_bt.BTGattChar.

Definition at line 265 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ getHandle()

final short jau.direct_bt.DBTGattChar.getHandle ( )

Characteristic Handle of this instance.

Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle).

Definition at line 278 of file DBTGattChar.java.

◆ getValueHandle()

final short jau.direct_bt.DBTGattChar.getValueHandle ( )

Returns Characteristics Value Handle.

Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle).

Definition at line 286 of file DBTGattChar.java.

◆ getClientCharConfig()

final BTGattDesc jau.direct_bt.DBTGattChar.getClientCharConfig ( )

Return the Client Characteristic Configuration BTGattDesc if available or null.

The BTGattDesc#UUID128#CCC_DESC has been indexed while retrieving the GATT database from the server.

Implements org.direct_bt.BTGattChar.

Definition at line 289 of file DBTGattChar.java.

◆ getUserDescription()

final BTGattDesc jau.direct_bt.DBTGattChar.getUserDescription ( )

Return the User Description BTGattDesc if available or null.

The BTGattDesc#UUID128#USER_DESC has been indexed while retrieving the GATT database from the server.

Implements org.direct_bt.BTGattChar.

Definition at line 297 of file DBTGattChar.java.

◆ readValue()

final byte[] jau.direct_bt.DBTGattChar.readValue ( ) throws BTException

Reads the value of this characteristic.

Returns
A std::vector<unsgined char> containing the value of this characteristic.

Implements org.direct_bt.BTGattChar.

Definition at line 305 of file DBTGattChar.java.

◆ writeValue()

final boolean jau.direct_bt.DBTGattChar.writeValue ( final byte[]  argValue,
final boolean  withResponse 
) throws BTException

Writes the value of this characteristic, using one of the following methods depending on withResponse @endiliteral.

BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value
BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.1 Write Characteristic Value Without Response
Parameters
[in]arg_valueThe data as vector<uchar> to be written packed in a GBytes struct
withResponseif true a subsequent ATT_WRITE_RSP is expected, otherwise not.
Returns
TRUE if value was written successfully
Since
2.0.0 @implNote withResponse parameter has been added since 2.0.0

Implements org.direct_bt.BTGattChar.

Definition at line 311 of file DBTGattChar.java.

◆ toString()

final String jau.direct_bt.DBTGattChar.toString ( )

Implements org.direct_bt.BTGattChar.

Definition at line 317 of file DBTGattChar.java.


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