Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Handles the Attribute Protocol (ATT) using Protocol Data Unit (PDU) encoded messages over L2CAP channel. More...
#include <ATTPDUTypes.hpp>
Public Member Functions | |
AttPDUMsg (const uint8_t *source, const jau::nsize_t size) | |
Persistent memory, w/ ownership . More... | |
AttPDUMsg (const Opcode opc, const jau::nsize_t size) | |
Persistent memory, w/ ownership . More... | |
AttPDUMsg (const AttPDUMsg &o) noexcept=default | |
AttPDUMsg (AttPDUMsg &&o) noexcept=default | |
AttPDUMsg & | operator= (const AttPDUMsg &o) noexcept=delete |
AttPDUMsg & | operator= (AttPDUMsg &&o) noexcept=delete |
virtual | ~AttPDUMsg () noexcept |
constexpr Opcode | getOpcode () const noexcept |
ATT PDU Format Vol 3, Part F 3.3.1. More... | |
constexpr Opcode | getOpMethod () const noexcept |
ATT PDU Format Vol 3, Part F 3.3.1. More... | |
constexpr bool | getOpCommandFlag () const noexcept |
ATT PDU Format Vol 3, Part F 3.3.1. More... | |
constexpr bool | getOpAuthSigFlag () const noexcept |
ATT PDU Format Vol 3, Part F 3.3.1. More... | |
constexpr jau::nsize_t | getAuthSigSize () const noexcept |
ATT PDU Format Vol 3, Part F 3.3.1. More... | |
constexpr jau::nsize_t | getPDUParamSize () const noexcept |
ATT PDU Format Vol 3, Part F 3.3.1. More... | |
virtual constexpr_cxx20 jau::nsize_t | getPDUValueOffset () const noexcept |
Returns the octet offset to the value segment in this PDU including the mandatory opcode, i.e. More... | |
constexpr_cxx20 jau::nsize_t | getPDUMinSize () const noexcept |
Returns this PDU's minimum size, i.e. More... | |
constexpr_cxx20 jau::nsize_t | getPDUValueSize () const noexcept |
Returns the octet size of the value attributes in this PDI, i.e. More... | |
constexpr_cxx20 jau::nsize_t | getMaxPDUValueSize (const jau::nsize_t mtu) const noexcept |
Returns the theoretical maximum value size of a PDU. More... | |
virtual constexpr_cxx20 std::string | getName () const noexcept |
virtual std::string | toString () const noexcept |
Static Public Member Functions | |
static constexpr uint8_t | number (const Opcode rhs) noexcept |
static std::string | getOpcodeString (const Opcode opc) noexcept |
static std::unique_ptr< const AttPDUMsg > | getSpecialized (const uint8_t *buffer, jau::nsize_t const buffer_size) noexcept |
Return a newly created specialized instance pointer to base class. More... | |
Public Attributes | |
POctets | pdu |
actual received PDU More... | |
const uint64_t | ts_creation |
creation timestamp in milliseconds More... | |
Protected Member Functions | |
void | checkOpcode (const Opcode expected) const |
void | checkOpcode (const Opcode exp1, const Opcode exp2) const |
virtual std::string | baseString () const noexcept |
virtual std::string | valueString () const noexcept |
Handles the Attribute Protocol (ATT) using Protocol Data Unit (PDU) encoded messages over L2CAP channel.
Implementation uses persistent memory w/ ownership copying PDU data to allow intermediate pipe processing.
One attribute := { UUID type; uint16_t handle; permissions for higher layer; }, where
UUID is an official assigned number,
handle uniquely references an attribute on a server for client R/W access, see Vol 3, Part F 3.4.4 - 3.4.6, also 3.4.7 (notified/indicated), 3.4.3 (discovery) and 3.2.5 (permissions).
Client sends ATT requests to a server, which shall respond to all.
A device can take client and server roles concurrently.
One server per device, ATT handle is unique for all supported bearers. For each client, server has one set of ATTs. The server (and hence device) can support multiple clients.
Services are distinguished by range of handles for each service. Discovery is of these handle ranges is defined by a higher layer spec.
ATT Protocol has notification and indication capabilities for efficient ATT value promotion to client w/o reading them (Vol 3, Part F 3.3).
All ATT Protocol requests sent over an ATT bearer. Multiple ATT bearers can be established between two devices. Each ATT bearer uses a separate L2CAP channel an can have different configurations.
For LE a single ATT bearer using a fixed L2CAP channel is available ASAP after ACL connection is established. Additional ATT bearers can be established using L2CAP (Vol 3, Part F 3.2.11).
ATT handle is uint16_t and valid if > 0x0000, max is 0xffff. ATT handle is unique per server.
ATT value (Vol 3, Part F 3.2.4)
ATT value variable length is implicit by PDU carrying packet (PDU parent), implying:
Some PDUs include the ATT value length, for which above limitations don't apply.
Maximum length of an attribute value shall be 512 bytes (Vol 3, Part F 3.2.8), spread across multiple PDUs.
Attribute Protocol (ATT)'s Protocol Data Unit (PDU) message Vol 3, Part F 3.3 and Vol 3, Part F 3.4
Little endian, however, ATT value endianess is defined by above layer.
ATT_MTU Vol 3, Part F 3.2.8 Maximum size of any packet sent. Higher layer spec defines the default ATT_MTU value. LE L2CAP GATT ATT_MTU is 23 bytes (Vol 3, Part G 5.2.1).
Maximum length of an attribute value shall be 512 bytes (Vol 3, Part F 3.2.8), spread across multiple PDUs.
with
and
Definition at line 312 of file ATTPDUTypes.hpp.
|
strong |
ATT Opcode Summary Vol 3, Part F 3.4.8.
Definition at line 316 of file ATTPDUTypes.hpp.
|
inline |
Persistent memory, w/ ownership .
Definition at line 415 of file ATTPDUTypes.hpp.
|
inline |
Persistent memory, w/ ownership .
Definition at line 422 of file ATTPDUTypes.hpp.
|
defaultnoexcept |
|
defaultnoexcept |
|
inlinevirtualnoexcept |
Definition at line 434 of file ATTPDUTypes.hpp.
|
inlineprotectedvirtualnoexcept |
Definition at line 390 of file ATTPDUTypes.hpp.
|
inlineprotected |
Definition at line 372 of file ATTPDUTypes.hpp.
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
The ATT Authentication Signature size in octets.
This auth-signature comes at the very last of the PDU.
Definition at line 457 of file ATTPDUTypes.hpp.
|
inlinenoexcept |
Returns the theoretical maximum value size of a PDU.
ATT_MTU - getAuthSigSize() - value-offset
Definition at line 533 of file ATTPDUTypes.hpp.
|
inlinevirtualnoexcept |
Reimplemented in direct_bt::AttFindInfoRsp, direct_bt::AttFindInfoReq, direct_bt::AttReadByGroupTypeRsp, direct_bt::AttReadByTypeRsp, direct_bt::AttReadByNTypeReq, direct_bt::AttElementList, direct_bt::AttHandleValueCfm, direct_bt::AttHandleValueRcv, direct_bt::AttWriteCmd, direct_bt::AttWriteRsp, direct_bt::AttWriteReq, direct_bt::AttReadBlobRsp, direct_bt::AttReadBlobReq, direct_bt::AttReadRsp, direct_bt::AttReadReq, direct_bt::AttExchangeMTU, direct_bt::AttErrorRsp, and direct_bt::AttPDUUndefined.
Definition at line 537 of file ATTPDUTypes.hpp.
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
Definition at line 446 of file ATTPDUTypes.hpp.
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
Definition at line 437 of file ATTPDUTypes.hpp.
|
staticnoexcept |
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
Definition at line 443 of file ATTPDUTypes.hpp.
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
Definition at line 440 of file ATTPDUTypes.hpp.
|
inlinenoexcept |
Returns this PDU's minimum size, i.e.
opcode + param - value + auth_signature
Value is excluded as it might be flexible.
Definition at line 506 of file ATTPDUTypes.hpp.
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
The ATT PDU parameter size in octets less opcode (1 byte) and auth-signature (0 or 12 bytes).
param-size := pdu.size - getAuthSigSize() - 1
<p<blockquote>
Note that the PDU parameter include the PDU value below.
Note that the optional auth-signature is at the end of the PDU.
Definition at line 475 of file ATTPDUTypes.hpp.
|
inlinevirtualnoexcept |
Returns the octet offset to the value segment in this PDU including the mandatory opcode, i.e.
the number of octets until the first value octet.
Note that the ATT PDU value is part of the PDU param, where it is the last segment.
The value offset is ATT PDU specific and may point to the variable user data post handle etc within the PDU Param block.
Note that the opcode must be included in the implementation, as it may be used to reference the value in the pdu conveniently.
Reimplemented in direct_bt::AttFindInfoRsp, direct_bt::AttFindInfoReq, direct_bt::AttReadByGroupTypeRsp, direct_bt::AttReadByTypeRsp, direct_bt::AttReadByNTypeReq, direct_bt::AttHandleValueCfm, direct_bt::AttHandleValueRcv, direct_bt::AttWriteCmd, direct_bt::AttWriteRsp, direct_bt::AttWriteReq, direct_bt::AttReadBlobRsp, direct_bt::AttReadBlobReq, direct_bt::AttReadRsp, direct_bt::AttReadReq, direct_bt::AttExchangeMTU, direct_bt::AttErrorRsp, and direct_bt::AttPDUUndefined.
Definition at line 497 of file ATTPDUTypes.hpp.
|
inlinenoexcept |
Returns the octet size of the value attributes in this PDI, i.e.
getPDUParamSize() - getPDUValueOffset() + 1.
Note that the opcode size of 1 octet is re-added as included in getPDUValueOffset() for convenience but already taken-off in getPDUParamSize() for spec compliance!
value-size := param-size - value-offset + 1 param-size := pdu.size - getAuthSigSize() - 1
value-size := pdu.size - getAuthSigSize() - 1 - value-offset + 1 value-size := pdu.size - getAuthSigSize() - value-offset
Definition at line 525 of file ATTPDUTypes.hpp.
|
staticnoexcept |
Return a newly created specialized instance pointer to base class.
Returned memory reference is managed by caller (delete etc)
Definition at line 118 of file ATTPDUTypes.cpp.
|
inlinestaticconstexprnoexcept |
|
inlinevirtualnoexcept |
Definition at line 541 of file ATTPDUTypes.hpp.
|
inlineprotectedvirtualnoexcept |
Reimplemented in direct_bt::AttFindInfoReq, direct_bt::AttReadByNTypeReq, direct_bt::AttElementList, direct_bt::AttHandleValueRcv, direct_bt::AttWriteCmd, direct_bt::AttWriteReq, direct_bt::AttReadBlobRsp, direct_bt::AttReadBlobReq, direct_bt::AttReadRsp, direct_bt::AttReadReq, direct_bt::AttExchangeMTU, and direct_bt::AttErrorRsp.
Definition at line 394 of file ATTPDUTypes.hpp.
POctets direct_bt::AttPDUMsg::pdu |
actual received PDU
Definition at line 401 of file ATTPDUTypes.hpp.
const uint64_t direct_bt::AttPDUMsg::ts_creation |
creation timestamp in milliseconds
Definition at line 404 of file ATTPDUTypes.hpp.