Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
|
Class maps a GATT command and optionally its asynchronous response to a synchronous atomic operation. More...
#include <BTGattCmd.hpp>
Public Types | |
typedef jau::function< void(BTGattCharRef charDecl, const jau::TROOctets &char_value, const uint64_t timestamp)> | DataCallback |
Public Member Functions | |
BTGattCmd (BTDevice &dev_, std::string name_, const jau::uuid_t &cmd_uuid_) noexcept | |
Constructor for commands without response. More... | |
BTGattCmd (BTDevice &dev_, std::string name_, const jau::uuid_t &cmd_uuid_, const jau::uuid_t &rsp_uuid_, const jau::nsize_t rsp_capacity) noexcept | |
Constructor for commands with notification or indication response. More... | |
BTGattCmd (BTDevice &dev_, std::string name_, const jau::uuid_t &service_uuid_, const jau::uuid_t &cmd_uuid_) noexcept | |
Constructor for commands without response. More... | |
BTGattCmd (BTDevice &dev_, std::string name_, const jau::uuid_t &service_uuid_, const jau::uuid_t &cmd_uuid_, const jau::uuid_t &rsp_uuid_, const jau::nsize_t rsp_capacity) noexcept | |
Constructor for commands with notification or indication response. More... | |
~BTGattCmd () noexcept | |
HCIStatusCode | close () noexcept |
Close this command instance, usually called at destruction. More... | |
const jau::uuid_t * | getCommandUUID () const noexcept |
Return command's BTGattChar value jau::uuid_t to write command, never nullptr. More... | |
const std::string & | getName () const noexcept |
Return name, representing the command. More... | |
const jau::TROOctets & | getResponse () const noexcept |
Returns the read-only response data object for configured commands with response notification or indication. More... | |
const jau::uuid_t * | getResponseUUID () const noexcept |
Return command's optional BTGattChar value jau::uuid_t for the notification or indication response, may be nullptr. More... | |
const jau::uuid_t * | getServiceUUID () const noexcept |
Return command's BTGattService jau::uuid_t, may be nullptr. More... | |
bool | hasResponseSet () const noexcept |
Return true if a notification or indication response has been set via constructor, otherwise false. More... | |
bool | isResolved () noexcept |
Query whether all UUIDs of this commands have been resolved. More... | |
HCIStatusCode | send (const bool prefNoAck, const jau::TROOctets &cmd_data, const jau::fraction_i64 &timeout) noexcept |
Send the command to the remote BTDevice. More... | |
HCIStatusCode | sendOnly (const bool prefNoAck, const jau::TROOctets &cmd_data) noexcept |
Send the command to the remote BTDevice, only. More... | |
void | setDataCallback (const DataCallback &dcb) noexcept |
void | setResponseMinSize (jau::nsize_t v) noexcept |
void | setVerbose (const bool v) noexcept |
Set verbosity for UUID resolution. More... | |
std::string | toString () const noexcept |
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.
Definition at line 66 of file BTGattCmd.hpp.
typedef jau::function<void(BTGattCharRef charDecl, const jau::TROOctets& char_value, const uint64_t timestamp)> direct_bt::BTGattCmd::DataCallback |
Definition at line 69 of file BTGattCmd.hpp.
|
inlinenoexcept |
Constructor for commands with notification or indication response.
dev_ | the remote BTDevice |
name_ | user given name, representing the command |
service_uuid_ | command's BTGattService jau::uuid_t |
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. |
rsp_capacity | initial capacity of response sink, see getResponse() |
Definition at line 144 of file BTGattCmd.hpp.
|
inlinenoexcept |
Constructor for commands with notification or indication response.
Since no service UUID is given, the BTGattChar lookup is less efficient.
dev_ | the remote BTDevice |
name_ | user given name, representing the command |
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. |
rsp_capacity | initial capacity of response sink, see getResponse() |
Definition at line 175 of file BTGattCmd.hpp.
|
inlinenoexcept |
Constructor for commands without response.
dev_ | the remote BTDevice |
name_ | user given name, representing the command |
service_uuid_ | command's BTGattService jau::uuid_t |
cmd_uuid_ | command's BTGattChar value jau::uuid_t to write the command |
Definition at line 202 of file BTGattCmd.hpp.
|
inlinenoexcept |
Constructor for commands without response.
Since no service UUID is given, the BTGattChar lookup is less efficient.
dev_ | the remote BTDevice |
name_ | user given name, representing the command |
cmd_uuid_ | command's BTGattChar value jau::uuid_t to write the command |
Definition at line 229 of file BTGattCmd.hpp.
|
inlinenoexcept |
Definition at line 253 of file BTGattCmd.hpp.
|
noexcept |
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 133 of file BTGattCmd.cpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Return name, representing the command.
Definition at line 259 of file BTGattCmd.hpp.
|
inlinenoexcept |
Return command's BTGattService jau::uuid_t, may be nullptr.
Definition at line 262 of file BTGattCmd.hpp.
|
inlinenoexcept |
Return command's BTGattChar value jau::uuid_t to write command, never nullptr.
Definition at line 265 of file BTGattCmd.hpp.
|
inlinenoexcept |
Return true if a notification or indication response has been set via constructor, otherwise false.
Definition at line 268 of file BTGattCmd.hpp.
|
inlinenoexcept |
Return command's optional BTGattChar value jau::uuid_t for the notification or indication response, may be nullptr.
Definition at line 271 of file BTGattCmd.hpp.
|
inlinenoexcept |
Set verbosity for UUID resolution.
Definition at line 274 of file BTGattCmd.hpp.
|
inlinenoexcept |
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.
Definition at line 283 of file BTGattCmd.hpp.
|
noexcept |
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.
Definition at line 167 of file BTGattCmd.cpp.
|
noexcept |
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.
prefNoAck | pass true to prefer command write without acknowledge, otherwise use with-ack if available |
cmd_data | raw command octets |
timeout | maximum duration in fractions of seconds to wait for the response to become available, if any. |
Definition at line 176 of file BTGattCmd.cpp.
|
noexcept |
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.
prefNoAck | pass true to prefer command write without acknowledge, otherwise use with-ack if available |
cmd_data | raw command octets |
Definition at line 179 of file BTGattCmd.cpp.
|
noexcept |
Definition at line 262 of file BTGattCmd.cpp.