Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Classes | Public Member Functions | List of all members
org.direct_bt.BTGattCmd Class Reference

Class maps a GATT command and optionally its asynchronous response to a synchronous atomic operation. More...

Inheritance diagram for org.direct_bt.BTGattCmd:
Collaboration diagram for org.direct_bt.BTGattCmd:

Classes

interface  DataCallback
 

Public Member Functions

 BTGattCmd (final BTDevice dev_, final String name_, final String service_uuid_, final String cmd_uuid_)
 Constructor for commands without response. More...
 
 BTGattCmd (final BTDevice dev_, final String name_, final String service_uuid_, final String cmd_uuid_, final String rsp_uuid_)
 Constructor for commands with notification or indication response. More...
 
void close ()
 Close this command instance, usually called at destruction. More...
 
synchronized HCIStatusCode close0 ()
 Close this command instance, usually called at destruction. More...
 
void finalize ()
 
String getCommandUUID ()
 Return command's BTGattChar value jau::uuid_t to write command, never null. More...
 
String getName ()
 Return name, representing the command. More...
 
byte[] getResponse ()
 Returns the read-only response data object for configured commands with response notification or indication. More...
 
String getResponseUUID ()
 Return command's optional BTGattChar value jau::uuid_t for the notification or indication response, may be null. More...
 
String getServiceUUID ()
 Return command's BTGattService jau::uuid_t, may be null. More...
 
boolean hasResponseSet ()
 Return true if a notification or indication response has been set via constructor, otherwise false. More...
 
synchronized boolean isResolved ()
 Query whether all UUIDs of this commands have been resolved. More...
 
synchronized HCIStatusCode send (final boolean prefNoAck, final byte[] cmd_data, final int timeoutMS)
 Send the command to the remote BTDevice. More...
 
synchronized HCIStatusCode sendOnly (final boolean prefNoAck, final byte[] cmd_data)
 Send the command to the remote BTDevice, only. More...
 
void setDataCallback (final DataCallback dcb)
 
void setResponseMinSize (final int v)
 
void setVerbose (final boolean v)
 Set verbosity for UUID resolution. More...
 
String toString ()
 

Detailed Description

Class maps a GATT command and optionally its asynchronous response to a synchronous atomic operation.

The GATT command is issued by writing the associated GATT characteristic value via BTGattChar.writeValueNoResp() or BTGattChar.writeValue().

Its optional asynchronous characteristic value notification or indication response is awaited and collected after command issuance.

If a response jau.uuid_t is given, notification or indication will be enabled at first send() command and disabled at close() or destruction.

See also
BTGattChar.writeValueNoResp()
BTGattChar.writeValue()
Since
2.4.0

Definition at line 48 of file BTGattCmd.java.

Constructor & Destructor Documentation

◆ BTGattCmd() [1/2]

org.direct_bt.BTGattCmd.BTGattCmd ( final BTDevice  dev_,
final String  name_,
final String  service_uuid_,
final String  cmd_uuid_,
final String  rsp_uuid_ 
)

Constructor for commands with notification or indication response.

Parameters
dev_the remote BTDevice
name_user given name, representing the command
service_uuid_command's BTGattService jau.uuid_t, may be null for using a less efficient BTGattChar lookup
cmd_uuid_command's BTGattChar value jau.uuid_t to write the command
rsp_uuid_command's BTGattChar value jau.uuid_t for the notification or indication response.

Definition at line 253 of file BTGattCmd.java.

◆ BTGattCmd() [2/2]

org.direct_bt.BTGattCmd.BTGattCmd ( final BTDevice  dev_,
final String  name_,
final String  service_uuid_,
final String  cmd_uuid_ 
)

Constructor for commands without response.

Parameters
dev_the remote BTDevice
name_user given name, representing the command
service_uuid_command's BTGattService jau.uuid_t, may be null for using a less efficient BTGattChar lookup
cmd_uuid_command's BTGattChar value jau.uuid_t to write the command

Definition at line 279 of file BTGattCmd.java.

Member Function Documentation

◆ close()

void org.direct_bt.BTGattCmd.close ( )

Close this command instance, usually called at destruction.

If a response jau.uuid_t has been given, notification or indication will be disabled.

Definition at line 202 of file BTGattCmd.java.

Here is the caller graph for this function:

◆ close0()

synchronized HCIStatusCode org.direct_bt.BTGattCmd.close0 ( )

Close this command instance, usually called at destruction.

If a response jau.uuid_t has been given, notification or indication will be disabled.

Definition at line 211 of file BTGattCmd.java.

Here is the caller graph for this function:

◆ finalize()

void org.direct_bt.BTGattCmd.finalize ( )

Definition at line 297 of file BTGattCmd.java.

◆ setResponseMinSize()

void org.direct_bt.BTGattCmd.setResponseMinSize ( final int  v)

Definition at line 299 of file BTGattCmd.java.

◆ setDataCallback()

void org.direct_bt.BTGattCmd.setDataCallback ( final DataCallback  dcb)

Definition at line 300 of file BTGattCmd.java.

◆ getName()

String org.direct_bt.BTGattCmd.getName ( )

Return name, representing the command.

Definition at line 303 of file BTGattCmd.java.

◆ getServiceUUID()

String org.direct_bt.BTGattCmd.getServiceUUID ( )

Return command's BTGattService jau::uuid_t, may be null.

Definition at line 306 of file BTGattCmd.java.

◆ getCommandUUID()

String org.direct_bt.BTGattCmd.getCommandUUID ( )

Return command's BTGattChar value jau::uuid_t to write command, never null.

Definition at line 309 of file BTGattCmd.java.

◆ hasResponseSet()

boolean org.direct_bt.BTGattCmd.hasResponseSet ( )

Return true if a notification or indication response has been set via constructor, otherwise false.

Definition at line 312 of file BTGattCmd.java.

◆ getResponseUUID()

String org.direct_bt.BTGattCmd.getResponseUUID ( )

Return command's optional BTGattChar value jau::uuid_t for the notification or indication response, may be null.

Definition at line 315 of file BTGattCmd.java.

◆ setVerbose()

void org.direct_bt.BTGattCmd.setVerbose ( final boolean  v)

Set verbosity for UUID resolution.

Definition at line 318 of file BTGattCmd.java.

◆ getResponse()

byte[] org.direct_bt.BTGattCmd.getResponse ( )

Returns the read-only response data object for configured commands with response notification or indication.

jau.TROOctets.size() matches the size of last received command response or zero.

See also
send(boolean, byte[], int)

Definition at line 327 of file BTGattCmd.java.

◆ isResolved()

synchronized boolean org.direct_bt.BTGattCmd.isResolved ( )

Query whether all UUIDs of this commands have been resolved.

In case no command has been issued via send() yet, the UUIDs will be resolved with this call.

Returns
true if all UUIDs have been resolved, otherwise false

Definition at line 341 of file BTGattCmd.java.

◆ send()

synchronized HCIStatusCode org.direct_bt.BTGattCmd.send ( final boolean  prefNoAck,
final byte[]  cmd_data,
final int  timeoutMS 
)

Send the command to the remote BTDevice.

If a notification or indication result jau.uuid_t has been set via constructor, it will be awaited and can be retrieved via getResponse() after command returns.

Parameters
prefNoAckpass true to prefer command write without acknowledge, otherwise use with-ack if available
cmd_dataraw command octets
timeoutMStimeout in milliseconds. Defaults to 10 seconds limited blocking for the response to become available, if any.
Returns
See also
getResponse()

Definition at line 361 of file BTGattCmd.java.

◆ sendOnly()

synchronized HCIStatusCode org.direct_bt.BTGattCmd.sendOnly ( final boolean  prefNoAck,
final byte[]  cmd_data 
)

Send the command to the remote BTDevice, only.

Regardless whether a notification or indication result jau::uuid_t has been set via constructor, this command will not wait for the response.

Parameters
prefNoAckpass true to prefer command write without acknowledge, otherwise use with-ack if available
cmd_dataraw command octets
Returns
See also
getResponse()

Definition at line 376 of file BTGattCmd.java.

◆ toString()

String org.direct_bt.BTGattCmd.toString ( )

Definition at line 464 of file BTGattCmd.java.

Here is the caller graph for this function:

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