Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Provides access to Bluetooth GATT characteristic. More...
Classes | |
interface | Listener |
BTGattChar event listener for notification and indication events. More... | |
Public Member Functions | |
BTGattDesc | find (final String UUID, final long timeoutMS) |
Find a BluetoothGattDescriptor. More... | |
BTGattDesc | find (final String UUID) |
Find a BluetoothGattDescriptor. More... | |
byte[] | readValue () throws BTException |
Reads the value of this characteristic. 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 | 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 | addCharListener (final Listener listener) throws IllegalStateException |
Add the given BTGattChar.Listener to the listener list if not already present. More... | |
boolean | addCharListener (final Listener listener, final boolean enabledState[]) throws IllegalStateException |
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... | |
int | removeAllAssociatedCharListener (final boolean disableIndicationNotification) |
Disables the notification and/or indication for this characteristic BLE level if. More... | |
void | disableValueNotifications () |
Disables notifications of the value and unregisters the callback object passed through the corresponding enable method. More... | |
boolean | writeValue (byte[] argValue, boolean withResponse) throws BTException |
Writes the value of this characteristic, using one of the following methods depending on. More... | |
String | getUUID () |
Get the UUID of this characteristic. More... | |
BTGattService | getService () |
Returns the service to which this characteristic belongs to. 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... | |
List< BTGattDesc > | getDescriptors () |
Returns a list of BluetoothGattDescriptors this characteristic exposes. More... | |
Public Member Functions inherited from org.direct_bt.BTObject | |
BTType | getBluetoothType () |
Returns the BluetoothType of this object. More... | |
boolean | equals (Object obj) |
int | hashCode () |
void | close () |
Release the native memory associated with this object The object should not be used following a call to close. More... | |
Provides access to Bluetooth GATT characteristic.
Definition at line 39 of file BTGattChar.java.
boolean org.direct_bt.BTGattChar.addCharListener | ( | final Listener | listener | ) | throws IllegalStateException |
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.
listener | A BTGattChar.Listener instance, listening to this BTGattChar's events |
IllegalStateException | if the DBTDevice's GATTHandler is null, i.e. not connected |
IllegalStateException | if the given BTGattChar.Listener is already in use, i.e. added. |
Implemented in jau.direct_bt.DBTGattChar.
boolean org.direct_bt.BTGattChar.addCharListener | ( | final Listener | listener, |
final boolean | enabledState[] | ||
) | throws IllegalStateException |
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.
listener | A BTGattChar.Listener instance, listening to this BTGattChar's events |
enabledState | array of size 2, holding the resulting enabled state for notification and indication using enableNotificationOrIndication(boolean[]) |
IllegalStateException | if the BTDevice's GATTHandler is null, i.e. not connected |
IllegalStateException | if the given BTGattChar.Listener is already in use, i.e. added. |
Implemented in jau.direct_bt.DBTGattChar.
boolean org.direct_bt.BTGattChar.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.
enableNotification | |
enableIndication | |
enabledState | array of size 2, holding the resulting enabled state for notification and indication. |
IllegalStateException | if notification or indication is set to be enabled and the BTDevice's GATTHandler is null, i.e. not connected |
Implemented in jau.direct_bt.DBTGattChar.
void org.direct_bt.BTGattChar.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.
Implemented in jau.direct_bt.DBTGattChar.
boolean org.direct_bt.BTGattChar.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.
enabledState | array of size 2, holding the resulting enabled state for notification and indication. |
IllegalStateException | if notification or indication is set to be enabled and the BTDevice's GATTHandler is null, i.e. not connected |
Implemented in jau.direct_bt.DBTGattChar.
BTGattDesc org.direct_bt.BTGattChar.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
Implemented in jau.direct_bt.DBTGattChar.
BTGattDesc org.direct_bt.BTGattChar.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.
Implemented in jau.direct_bt.DBTGattChar.
List<BTGattDesc> org.direct_bt.BTGattChar.getDescriptors | ( | ) |
Returns a list of BluetoothGattDescriptors this characteristic exposes.
Implemented in jau.direct_bt.DBTGattChar.
boolean org.direct_bt.BTGattChar.getNotifying | ( | final boolean | enabledState[] | ) |
Returns true if notification for changes of this characteristic are activated.
enabledState | array of size 2, storage for the current enabled state for notification and indication. |
Implemented in jau.direct_bt.DBTGattChar.
GattCharPropertySet org.direct_bt.BTGattChar.getProperties | ( | ) |
Returns the properties of this characteristic.
BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.1.1 Characteristic Properties
Implemented in jau.direct_bt.DBTGattChar.
BTGattService org.direct_bt.BTGattChar.getService | ( | ) |
Returns the service to which this characteristic belongs to.
Implemented in jau.direct_bt.DBTGattChar.
String org.direct_bt.BTGattChar.getUUID | ( | ) |
Get the UUID of this characteristic.
Implemented in jau.direct_bt.DBTGattChar.
byte [] org.direct_bt.BTGattChar.readValue | ( | ) | throws BTException |
Reads the value of this characteristic.
Implemented in jau.direct_bt.DBTGattChar.
int org.direct_bt.BTGattChar.removeAllAssociatedCharListener | ( | final boolean | disableIndicationNotification | ) |
Disables the notification and/or indication for this characteristic BLE level if.
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,
is being returned.
disableIndicationNotification | if true, disables the notification and/or indication for this characteristic using configNotificationIndication(boolean, boolean, boolean[]) |
Implemented in jau.direct_bt.DBTGattChar.
boolean org.direct_bt.BTGattChar.writeValue | ( | byte[] | argValue, |
boolean | withResponse | ||
) | throws BTException |
Writes the value of this characteristic, using one of the following methods depending on.
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
[in] | arg_value | The data as vector<uchar> to be written packed in a GBytes struct |
withResponse | if true
|
Implemented in jau.direct_bt.DBTGattChar.