Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Classes | 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

synchronized void close ()
 Release the native memory associated with this object The object should not be used following a call to close. More...
 
boolean equals (final Object obj)
 
String getUUID ()
 Get the UUID of this characteristic. More...
 
BTType getBluetoothType ()
 Returns the BluetoothType of this object. More...
 
BTGattChar clone ()
 
BTGattDesc find (final String UUID, final long timeoutMS)
 Find a BluetoothGattDescriptor. More...
 
BTGattDesc find (final String UUID)
 Find a BluetoothGattDescriptor. More...
 
final BTGattService getService ()
 Returns the service to which this characteristic belongs to. 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 byte[] readValue () throws BTException
 Reads the value of this characteristic. More...
 
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. More...
 
final List< BTGattDescgetDescriptors ()
 Returns a list of BluetoothGattDescriptors this characteristic exposes. 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 enableNotificationOrIndication (final boolean enabledState[]) throws IllegalStateException
 BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration. More...
 
final boolean addCharListener (final Listener listener)
 Add the given BTGattChar.Listener to the listener list if not already present. More...
 
final boolean addCharListener (final Listener listener, final boolean enabledState[])
 Add the given BTGattChar.Listener to the listener list if not already present and if enabling the notification or indication for this characteristic at BLE level was successful. More...
 
final int removeAllAssociatedCharListener (final boolean disableIndicationNotification)
 Disables the notification and/or indication for this characteristic BLE level if. More...
 
final synchronized void disableValueNotifications ()
 Disables notifications of the value and unregisters the callback object passed through the corresponding enable method. More...
 
final short getHandle ()
 Characteristic Handle of this instance. More...
 
final short getValueHandle ()
 Returns Characteristics Value Handle. More...
 
final int getClientCharacteristicsConfigIndex ()
 Returns optional Client Characteristic Configuration index within descriptorList. More...
 
final String toString ()
 
- Public Member Functions inherited from jau.direct_bt.DBTObject
final int hashCode ()
 

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 41 of file DBTGattChar.java.

Member Function Documentation

◆ addCharListener() [1/2]

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

Add the given BTGattChar.Listener 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 BTGattChar.Listener callback method.

Implementation wraps given BTGattChar.Listener into a BTGattCharListener to restrict the listener to listen only to this BTGattChar instance.

Parameters
listenerA BTGattChar.Listener instance, listening to this BTGattChar's events
Returns
true if the given listener is not element of the list and has been newly added, otherwise false.
Exceptions
IllegalStateExceptionif the DBTDevice's GATTHandler is null, i.e. not connected
IllegalStateExceptionif the given BTGattChar.Listener is already in use, i.e. added.
See also
enableNotificationOrIndication(boolean[])
configNotificationIndication(boolean, boolean, boolean[])
addCharListener(Listener, boolean[])
#removeCharListener(Listener, boolean)
removeAllAssociatedCharListener(boolean)
Since
2.0.0

Implements org.direct_bt.BTGattChar.

Definition at line 269 of file DBTGattChar.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addCharListener() [2/2]

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

Add the given BTGattChar.Listener 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 BTGattChar.Listener callback method.

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
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.
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
enableNotificationOrIndication(boolean[])
configNotificationIndication(boolean, boolean, boolean[])
addCharListener(Listener)
#removeCharListener(Listener, boolean)
removeAllAssociatedCharListener(boolean)
Since
2.0.0

Implements org.direct_bt.BTGattChar.

Definition at line 274 of file DBTGattChar.java.

Here is the call graph for this function:

◆ clone()

BTGattChar jau.direct_bt.DBTGattChar.clone ( )

Reimplemented from jau.direct_bt.DBTObject.

Definition at line 144 of file DBTGattChar.java.

◆ 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 117 of file DBTGattChar.java.

Here is the call graph for this function:

◆ 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
enableNotificationOrIndication(boolean[])
Since
2.0.0

Implements org.direct_bt.BTGattChar.

Definition at line 187 of file DBTGattChar.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

◆ disableValueNotifications()

final synchronized void jau.direct_bt.DBTGattChar.disableValueNotifications ( )

Disables notifications of the value and unregisters the callback object passed through the corresponding enable method.

It disables notifcations at BLE level for this characteristic.

Implements org.direct_bt.BTGattChar.

Definition at line 290 of file DBTGattChar.java.

Here is the call 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
configNotificationIndication(boolean, boolean, boolean[])
Since
2.0.0

Implements org.direct_bt.BTGattChar.

Definition at line 237 of file DBTGattChar.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equals()

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

Reimplemented from jau.direct_bt.DBTObject.

Definition at line 126 of file DBTGattChar.java.

◆ find() [1/2]

BTGattDesc jau.direct_bt.DBTGattChar.find ( final String  UUID)

Find a BluetoothGattDescriptor.

If parameter UUID is not null, the returned object will have to match it. It will first check for existing objects. It will not turn on discovery or connect to devices. @parameter UUID optionally specify the UUID of the BluetoothGattDescriptor you are waiting for

Returns
An object matching the UUID or null if not found before timeout expires or event is canceled.

Implements org.direct_bt.BTGattChar.

Definition at line 156 of file DBTGattChar.java.

Here is the call graph for this function:

◆ find() [2/2]

BTGattDesc jau.direct_bt.DBTGattChar.find ( final String  UUID,
final long  timeoutMS 
)

Find a BluetoothGattDescriptor.

If parameter UUID is not null, the returned object will have to match it. It will first check for existing objects. It will not turn on discovery or connect to devices. @parameter UUID optionally specify the UUID of the BluetoothGattDescriptor you are waiting for @parameter timeoutMS the function will return after timeout time in milliseconds, a value of zero means wait forever. If object is not found during this time null will be returned.

Returns
An object matching the UUID or null if not found before timeout expires or event is canceled.

Implements org.direct_bt.BTGattChar.

Definition at line 148 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ getBluetoothType()

BTType jau.direct_bt.DBTGattChar.getBluetoothType ( )

Returns the BluetoothType of this object.

Returns
The BluetoothType of this object

Implements org.direct_bt.BTObject.

Definition at line 139 of file DBTGattChar.java.

◆ getClientCharacteristicsConfigIndex()

final int jau.direct_bt.DBTGattChar.getClientCharacteristicsConfigIndex ( )

Returns optional Client Characteristic Configuration index within descriptorList.

Definition at line 311 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 184 of file DBTGattChar.java.

◆ 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 300 of file DBTGattChar.java.

◆ 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 164 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 171 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 161 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ 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 136 of file DBTGattChar.java.

Here is the caller graph for this function:

◆ 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 308 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 174 of file DBTGattChar.java.

◆ removeAllAssociatedCharListener()

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

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
disableIndicationNotificationif true, disables the notification and/or indication for this characteristic using configNotificationIndication(boolean, boolean, boolean[])
Returns
number of removed listener.
See also
configNotificationIndication(boolean, boolean, boolean[])
BTDevice::removeAllAssociatedCharListener(BTGattChar)
addCharListener(Listener)
addCharListener(Listener, boolean[])
#removeCharListener(Listener, boolean)
Since
2.0.0

Implements org.direct_bt.BTGattChar.

Definition at line 282 of file DBTGattChar.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString()

final String jau.direct_bt.DBTGattChar.toString ( )

Definition at line 314 of file DBTGattChar.java.

Here is the call graph for this function:

◆ 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
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 179 of file DBTGattChar.java.


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