Direct-BT v3.3.0-1-gc2d430c
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 (AttPDUMsg &&o) noexcept=default | |
AttPDUMsg (const AttPDUMsg &o)=default | |
AttPDUMsg (const Opcode opc, const jau::nsize_t size) | |
Persistent memory, w/ ownership . More... | |
AttPDUMsg (const uint8_t *source, const jau::nsize_t size) | |
Persistent memory, w/ ownership . More... | |
virtual | ~AttPDUMsg () noexcept=default |
constexpr jau::nsize_t | getAuthSigSize () const noexcept |
ATT PDU Format Vol 3, Part F 3.3.1. More... | |
constexpr_cxx20 jau::nsize_t | getMaxPDUValueSize (const jau::nsize_t mtu) const noexcept |
Returns the theoretical maximum value size of a PDU's attribute value. More... | |
virtual std::string | getName () const noexcept |
constexpr bool | getOpAuthSigFlag () const noexcept |
ATT PDU Format Vol 3, Part F 3.3.1. More... | |
constexpr Opcode | getOpcode () 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 Opcode | getOpMethod () const noexcept |
ATT PDU Format Vol 3, Part F 3.3.1. More... | |
constexpr_cxx20 jau::nsize_t | getPDUMinSize () const noexcept |
Returns this PDU's minimum size, i.e. 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 | getPDUValueSize () const noexcept |
Returns the net octet size of this PDU's attributes value, i.e. More... | |
AttPDUMsg & | operator= (AttPDUMsg &&o) noexcept=delete |
AttPDUMsg & | operator= (const AttPDUMsg &o) noexcept=delete |
virtual std::string | toString () const noexcept |
Static Public Member Functions | |
static constexpr OpcodeType | get_type (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... | |
static constexpr bool | is_request (const ReqRespType rhs) noexcept |
static constexpr uint8_t | number (const Opcode rhs) noexcept |
Public Attributes | |
jau::POctets | pdu |
actual received PDU More... | |
const uint64_t | ts_creation |
creation timestamp in milliseconds More... | |
Protected Member Functions | |
virtual std::string | baseString () const noexcept |
void | check_range () |
void | checkOpcode (const Opcode exp1, const Opcode exp2) const |
void | checkOpcode (const Opcode expected) const |
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 Specification
resulting in a ATT_MTU range of
with
and
Definition at line 347 of file ATTPDUTypes.hpp.
|
strong |
ATT Opcode Summary Vol 3, Part F 3.4.8.
Definition at line 351 of file ATTPDUTypes.hpp.
|
strong |
Enumerator | |
---|---|
REQUEST | |
RESPONSE |
Definition at line 399 of file ATTPDUTypes.hpp.
|
strong |
Enumerator | |
---|---|
UNDEFINED | |
REQUEST | |
RESPONSE | |
NOTIFICATION | |
INDICATION |
Definition at line 407 of file ATTPDUTypes.hpp.
|
inline |
Persistent memory, w/ ownership .
Definition at line 544 of file ATTPDUTypes.hpp.
|
inline |
Persistent memory, w/ ownership .
Definition at line 550 of file ATTPDUTypes.hpp.
|
default |
|
defaultnoexcept |
|
virtualdefaultnoexcept |
|
inlinestaticconstexprnoexcept |
|
staticnoexcept |
|
inlinestaticconstexprnoexcept |
Definition at line 403 of file ATTPDUTypes.hpp.
|
inlinestaticconstexprnoexcept |
Definition at line 415 of file ATTPDUTypes.hpp.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
Definition at line 509 of file ATTPDUTypes.hpp.
|
inlineprotectedvirtualnoexcept |
|
inlineprotectedvirtualnoexcept |
Reimplemented in direct_bt::AttErrorRsp, direct_bt::AttExchangeMTU, direct_bt::AttReadReq, direct_bt::AttReadBlobReq, direct_bt::AttReadNRsp, direct_bt::AttWriteReq, direct_bt::AttWriteCmd, direct_bt::AttPrepWrite, direct_bt::AttHandleValueRcv, direct_bt::AttElementList, direct_bt::AttReadByNTypeReq, direct_bt::AttFindInfoReq, direct_bt::AttFindByTypeValueReq, and direct_bt::AttFindByTypeValueRsp.
Definition at line 523 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 119 of file ATTPDUTypes.cpp.
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
Definition at line 565 of file ATTPDUTypes.hpp.
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
Definition at line 568 of file ATTPDUTypes.hpp.
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
Definition at line 571 of file ATTPDUTypes.hpp.
|
inlineconstexprnoexcept |
ATT PDU Format Vol 3, Part F 3.3.1.
Definition at line 574 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 585 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 603 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::AttPDUUndefined, direct_bt::AttErrorRsp, direct_bt::AttExchangeMTU, direct_bt::AttReadReq, direct_bt::AttReadBlobReq, direct_bt::AttReadNRsp, direct_bt::AttWriteReq, direct_bt::AttWriteRsp, direct_bt::AttWriteCmd, direct_bt::AttPrepWrite, direct_bt::AttExeWriteReq, direct_bt::AttExeWriteRsp, direct_bt::AttHandleValueRcv, direct_bt::AttHandleValueCfm, direct_bt::AttReadByNTypeReq, direct_bt::AttReadByTypeRsp, direct_bt::AttReadByGroupTypeRsp, direct_bt::AttFindInfoReq, direct_bt::AttFindInfoRsp, direct_bt::AttFindByTypeValueReq, and direct_bt::AttFindByTypeValueRsp.
Definition at line 625 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 634 of file ATTPDUTypes.hpp.
|
inlinenoexcept |
Returns the net octet size of this PDU's attributes value, i.e.
pdu.size - getAuthSigSize() - value-offset
orgetPDUParamSize() - 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 655 of file ATTPDUTypes.hpp.
|
inlinenoexcept |
Returns the theoretical maximum value size of a PDU's attribute value.
ATT_MTU - getAuthSigSize() - value-offset
Definition at line 663 of file ATTPDUTypes.hpp.
|
inlinevirtualnoexcept |
Reimplemented in direct_bt::AttPDUUndefined, direct_bt::AttErrorRsp, direct_bt::AttExchangeMTU, direct_bt::AttReadReq, direct_bt::AttReadBlobReq, direct_bt::AttReadNRsp, direct_bt::AttWriteReq, direct_bt::AttWriteRsp, direct_bt::AttWriteCmd, direct_bt::AttPrepWrite, direct_bt::AttExeWriteReq, direct_bt::AttExeWriteRsp, direct_bt::AttHandleValueRcv, direct_bt::AttHandleValueCfm, direct_bt::AttElementList, direct_bt::AttReadByNTypeReq, direct_bt::AttReadByTypeRsp, direct_bt::AttReadByGroupTypeRsp, direct_bt::AttFindInfoReq, direct_bt::AttFindInfoRsp, direct_bt::AttFindByTypeValueReq, and direct_bt::AttFindByTypeValueRsp.
Definition at line 667 of file ATTPDUTypes.hpp.
|
inlinevirtualnoexcept |
Definition at line 671 of file ATTPDUTypes.hpp.
jau::POctets direct_bt::AttPDUMsg::pdu |
actual received PDU
Definition at line 530 of file ATTPDUTypes.hpp.
const uint64_t direct_bt::AttPDUMsg::ts_creation |
creation timestamp in milliseconds
Definition at line 533 of file ATTPDUTypes.hpp.