aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/direct_bt/ATTPDUTypes.hpp214
-rw-r--r--api/direct_bt/OctetTypes.hpp13
-rw-r--r--api/direct_bt/SMPKeyBin.hpp2
-rw-r--r--api/direct_bt/SMPTypes.hpp98
4 files changed, 145 insertions, 182 deletions
diff --git a/api/direct_bt/ATTPDUTypes.hpp b/api/direct_bt/ATTPDUTypes.hpp
index af9408ed..9c487526 100644
--- a/api/direct_bt/ATTPDUTypes.hpp
+++ b/api/direct_bt/ATTPDUTypes.hpp
@@ -434,25 +434,17 @@ namespace direct_bt {
virtual ~AttPDUMsg() noexcept {}
/** ATT PDU Format Vol 3, Part F 3.3.1 */
- inline Opcode getOpcode() const noexcept {
- return static_cast<Opcode>(pdu.get_uint8_nc(0));
- }
+ constexpr Opcode getOpcode() const noexcept { return static_cast<Opcode>(pdu.get_uint8_nc(0)); }
std::string getOpcodeString() const noexcept { return getOpcodeString(getOpcode()); }
/** ATT PDU Format Vol 3, Part F 3.3.1 */
- Opcode getOpMethod() const noexcept {
- return bit_and(getOpcode(), Opcode::METHOD_MASK);
- }
+ constexpr Opcode getOpMethod() const noexcept { return bit_and(getOpcode(), Opcode::METHOD_MASK); }
/** ATT PDU Format Vol 3, Part F 3.3.1 */
- bool getOpCommandFlag() const noexcept {
- return bit_test(getOpcode(), Opcode::COMMAND_FLAG);
- }
+ constexpr bool getOpCommandFlag() const noexcept { return bit_test(getOpcode(), Opcode::COMMAND_FLAG); }
/** ATT PDU Format Vol 3, Part F 3.3.1 */
- bool getOpAuthSigFlag() const noexcept {
- return bit_test(getOpcode(), Opcode::AUTH_SIGNATURE_FLAG);
- }
+ constexpr bool getOpAuthSigFlag() const noexcept { return bit_test(getOpcode(), Opcode::AUTH_SIGNATURE_FLAG); }
/**
* ATT PDU Format Vol 3, Part F 3.3.1
@@ -463,9 +455,7 @@ namespace direct_bt {
* This auth-signature comes at the very last of the PDU.
* </p>
*/
- jau::nsize_t getAuthSigSize() const noexcept {
- return getOpAuthSigFlag() ? 12 : 0;
- }
+ constexpr jau::nsize_t getAuthSigSize() const noexcept { return getOpAuthSigFlag() ? 12 : 0; }
/**
* ATT PDU Format Vol 3, Part F 3.3.1
@@ -483,7 +473,7 @@ namespace direct_bt {
* Note that the optional auth-signature is at the end of the PDU.
* </p>
*/
- jau::nsize_t getPDUParamSize() const noexcept {
+ constexpr jau::nsize_t getPDUParamSize() const noexcept {
return pdu.getSize() - getAuthSigSize() - 1 /* opcode */;
}
@@ -505,7 +495,7 @@ namespace direct_bt {
* conveniently.
* </p>
*/
- virtual jau::nsize_t getPDUValueOffset() const noexcept { return 1; /* default: opcode */ }
+ constexpr_cxx20 virtual jau::nsize_t getPDUValueOffset() const noexcept { return 1; /* default: opcode */ }
/**
* Returns this PDU's minimum size, i.e.
@@ -514,7 +504,7 @@ namespace direct_bt {
* </pre>
* Value is excluded as it might be flexible.
*/
- jau::nsize_t getPDUMinSize() const noexcept {
+ constexpr_cxx20 jau::nsize_t getPDUMinSize() const noexcept {
return getPDUValueOffset() + getAuthSigSize();
}
@@ -533,7 +523,7 @@ namespace direct_bt {
* value-size := pdu.size - getAuthSigSize() - value-offset
* </pre>
*/
- jau::nsize_t getPDUValueSize() const noexcept { return getPDUParamSize() - getPDUValueOffset() + 1; }
+ constexpr_cxx20 jau::nsize_t getPDUValueSize() const noexcept { return getPDUParamSize() - getPDUValueOffset() + 1; }
/**
* Returns the theoretical maximum value size of a PDU.
@@ -541,11 +531,11 @@ namespace direct_bt {
* ATT_MTU - getAuthSigSize() - value-offset
* </pre>
*/
- jau::nsize_t getMaxPDUValueSize(const jau::nsize_t mtu) const noexcept {
+ constexpr_cxx20 jau::nsize_t getMaxPDUValueSize(const jau::nsize_t mtu) const noexcept {
return mtu - getAuthSigSize() - getPDUValueOffset();
}
- virtual std::string getName() const noexcept {
+ constexpr_cxx20 virtual std::string getName() const noexcept {
return "AttPDUMsg";
}
@@ -568,9 +558,9 @@ namespace direct_bt {
}
/** opcode */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1; }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttPDUUndefined";
}
};
@@ -615,26 +605,20 @@ namespace direct_bt {
}
/** opcode + reqOpcodeCause + handleCause + errorCode */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 1 + 2 + 1; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 1 + 2 + 1; }
- uint8_t getRequestedOpcodeCause() const noexcept {
- return pdu.get_uint8_nc(1);
- }
+ constexpr uint8_t getRequestedOpcodeCause() const noexcept { return pdu.get_uint8_nc(1); }
- uint16_t getHandleCause() const noexcept {
- return pdu.get_uint16_nc(2);
- }
+ constexpr uint16_t getHandleCause() const noexcept { return pdu.get_uint16_nc(2); }
- ErrorCode getErrorCode() const noexcept {
- return static_cast<ErrorCode>(pdu.get_uint8_nc(4));
- }
+ constexpr ErrorCode getErrorCode() const noexcept { return static_cast<ErrorCode>(pdu.get_uint8_nc(4)); }
std::string getErrorString() const noexcept {
const ErrorCode ec = getErrorCode();
return jau::uint8HexString(number(ec)) + ": " + getPlainErrorString(ec);
}
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttErrorRsp";
}
@@ -668,13 +652,11 @@ namespace direct_bt {
}
/** opcode + mtu-size */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1+2; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1+2; }
- uint16_t getMTUSize() const noexcept {
- return pdu.get_uint16_nc(1);
- }
+ constexpr uint16_t getMTUSize() const noexcept { return pdu.get_uint16_nc(1); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttExchangeMTU";
}
@@ -704,13 +686,11 @@ namespace direct_bt {
}
/** opcode + handle */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1+2; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1+2; }
- uint16_t getHandle() const noexcept {
- return pdu.get_uint16_nc( 1 );
- }
+ constexpr uint16_t getHandle() const noexcept { return pdu.get_uint16_nc( 1 ); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttReadReq";
}
@@ -739,6 +719,8 @@ namespace direct_bt {
private:
const TOctetSlice view;
+ constexpr static jau::nsize_t pdu_value_offset = 1;
+
public:
static bool instanceOf();
@@ -748,13 +730,13 @@ namespace direct_bt {
}
/** opcode */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return pdu_value_offset; }
- uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc(getPDUValueOffset()); }
+ constexpr uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc( pdu_value_offset ); }
- TOctetSlice const & getValue() const noexcept { return view; }
+ constexpr TOctetSlice const & getValue() const noexcept { return view; }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttReadRsp";
}
@@ -785,17 +767,13 @@ namespace direct_bt {
}
/** opcode + handle + value_offset */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 2 + 2; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 2 + 2; }
- uint16_t getHandle() const noexcept {
- return pdu.get_uint16_nc( 1 );
- }
+ constexpr uint16_t getHandle() const noexcept { return pdu.get_uint16_nc( 1 ); }
- uint16_t getValueOffset() const noexcept {
- return pdu.get_uint16_nc( 1 + 2 );
- }
+ constexpr uint16_t getValueOffset() const noexcept { return pdu.get_uint16_nc( 1 + 2 ); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttReadBlobReq";
}
@@ -824,6 +802,8 @@ namespace direct_bt {
private:
const TOctetSlice view;
+ constexpr static jau::nsize_t pdu_value_offset = 1;
+
public:
static bool instanceOf();
@@ -833,13 +813,13 @@ namespace direct_bt {
}
/** opcode */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return pdu_value_offset; }
- uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc(getPDUValueOffset()); }
+ constexpr uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc( pdu_value_offset ); }
- TOctetSlice const & getValue() const noexcept { return view; }
+ constexpr TOctetSlice const & getValue() const noexcept { return view; }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttReadBlobRsp";
}
@@ -867,6 +847,8 @@ namespace direct_bt {
private:
const TOctetSlice view;
+ constexpr static jau::nsize_t pdu_value_offset = 1 + 2;
+
public:
AttWriteReq(const uint16_t handle, const TROOctets & value)
: AttPDUMsg(Opcode::WRITE_REQ, 1+2+value.getSize()), view(pdu, getPDUValueOffset(), getPDUValueSize())
@@ -878,17 +860,15 @@ namespace direct_bt {
}
/** opcode + handle */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 2; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return pdu_value_offset; }
- uint16_t getHandle() const noexcept {
- return pdu.get_uint16_nc( 1 );
- }
+ constexpr uint16_t getHandle() const noexcept { return pdu.get_uint16_nc( 1 ); }
- uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc(getPDUValueOffset()); }
+ constexpr uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc( pdu_value_offset ); }
- TOctetSlice const & getValue() const noexcept { return view; }
+ constexpr TOctetSlice const & getValue() const noexcept { return view; }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttWriteReq";
}
@@ -917,9 +897,9 @@ namespace direct_bt {
}
/** opcode */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1; }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttWriteRsp";
}
};
@@ -939,6 +919,8 @@ namespace direct_bt {
private:
const TOctetSlice view;
+ constexpr static jau::nsize_t pdu_value_offset = 1 + 2;
+
public:
AttWriteCmd(const uint16_t handle, const TROOctets & value)
: AttPDUMsg(Opcode::WRITE_CMD, 1+2+value.getSize()), view(pdu, getPDUValueOffset(), getPDUValueSize())
@@ -950,17 +932,15 @@ namespace direct_bt {
}
/** opcode + handle */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 2; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return pdu_value_offset; }
- uint16_t getHandle() const noexcept {
- return pdu.get_uint16_nc( 1 );
- }
+ constexpr uint16_t getHandle() const noexcept { return pdu.get_uint16_nc( 1 ); }
- uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc(getPDUValueOffset()); }
+ constexpr uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc( pdu_value_offset ); }
- TOctetSlice const & getValue() const noexcept { return view; }
+ constexpr TOctetSlice const & getValue() const noexcept { return view; }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttWriteCmd";
}
@@ -991,6 +971,8 @@ namespace direct_bt {
private:
const TOctetSlice view;
+ constexpr static jau::nsize_t pdu_value_offset = 1 + 2;
+
public:
AttHandleValueRcv(const uint8_t* source, const jau::nsize_t length)
: AttPDUMsg(source, length), view(pdu, getPDUValueOffset(), getPDUValueSize()) {
@@ -998,13 +980,11 @@ namespace direct_bt {
}
/** opcode + handle */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1+2; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return pdu_value_offset; }
- uint16_t getHandle() const noexcept {
- return pdu.get_uint16_nc(1);
- }
+ constexpr uint16_t getHandle() const noexcept { return pdu.get_uint16_nc(1); }
- uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc(getPDUValueOffset()); }
+ constexpr uint8_t const * getValuePtr() const noexcept { return pdu.get_ptr_nc( pdu_value_offset ); }
TOctetSlice const & getValue() const noexcept { return view; }
@@ -1120,7 +1100,7 @@ namespace direct_bt {
class AttReadByNTypeReq : public AttPDUMsg
{
private:
- uuid_t::TypeSize getUUIFormat() const {
+ constexpr_cxx20 uuid_t::TypeSize getUUIFormat() const {
return uuid_t::toTypeSize(this->getPDUValueSize());
}
@@ -1137,17 +1117,13 @@ namespace direct_bt {
}
/** opcode + handle-start + handle-end */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 2 + 2; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 2 + 2; }
- uint16_t getStartHandle() const noexcept {
- return pdu.get_uint16_nc( 1 );
- }
+ constexpr uint16_t getStartHandle() const noexcept { return pdu.get_uint16_nc( 1 ); }
- uint16_t getEndHandle() const noexcept {
- return pdu.get_uint16_nc( 1 + 2 /* 1 handle size */ );
- }
+ constexpr uint16_t getEndHandle() const noexcept { return pdu.get_uint16_nc( 1 + 2 /* 1 handle size */ ); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttReadByNTypeReq";
}
@@ -1196,15 +1172,11 @@ namespace direct_bt {
Element(const AttReadByTypeRsp & p, const jau::nsize_t idx)
: view(p.pdu, p.getElementPDUOffset(idx), p.getElementTotalSize()) {}
- uint16_t getHandle() const noexcept {
- return view.get_uint16_nc(0);
- }
+ constexpr uint16_t getHandle() const noexcept { return view.get_uint16_nc(0); }
- uint8_t const * getValuePtr() const noexcept {
- return view.get_ptr_nc(2 /* handle size */);
- }
+ constexpr uint8_t const * getValuePtr() const noexcept { return view.get_ptr_nc(2 /* handle size */); }
- jau::nsize_t getValueSize() const noexcept { return view.getSize() - 2 /* handle size */; }
+ constexpr jau::nsize_t getValueSize() const noexcept { return view.getSize() - 2 /* handle size */; }
std::string toString() const {
return "handle "+jau::uint16HexString(getHandle())+
@@ -1224,10 +1196,10 @@ namespace direct_bt {
}
/** opcode + element-size */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 1; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 1; }
/** Returns size of each element, i.e. handle-value pair. */
- jau::nsize_t getElementTotalSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getElementTotalSize() const noexcept override {
return pdu.get_uint8_nc(1);
}
@@ -1237,11 +1209,11 @@ namespace direct_bt {
* element := { uint16_t handle, uint8_t value[value-size] }
* </p>
*/
- jau::nsize_t getElementValueSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getElementValueSize() const noexcept override {
return getElementTotalSize() - 2;
}
- jau::nsize_t getElementCount() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getElementCount() const noexcept override {
return getPDUValueSize() / getElementTotalSize();
}
@@ -1257,7 +1229,7 @@ namespace direct_bt {
return pdu.get_wptr() + getElementPDUOffset(elementIdx) + 2 /* handle size */;
}
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttReadByTypeRsp";
}
@@ -1299,19 +1271,13 @@ namespace direct_bt {
Element(const AttReadByGroupTypeRsp & p, const jau::nsize_t idx)
: view(p.pdu, p.getElementPDUOffset(idx), p.getElementTotalSize()) {}
- uint16_t getStartHandle() const noexcept {
- return view.get_uint16_nc(0);
- }
+ constexpr uint16_t getStartHandle() const noexcept { return view.get_uint16_nc(0); }
- uint16_t getEndHandle() const noexcept {
- return view.get_uint16_nc(2);
- }
+ constexpr uint16_t getEndHandle() const noexcept { return view.get_uint16_nc(2); }
- uint8_t const * getValuePtr() const noexcept {
- return view.get_ptr_nc(4 /* handle size */);
- }
+ constexpr uint8_t const * getValuePtr() const noexcept { return view.get_ptr_nc(4 /* handle size */); }
- jau::nsize_t getValueSize() const noexcept { return view.getSize() - 4 /* handle size */; }
+ constexpr jau::nsize_t getValueSize() const noexcept { return view.getSize() - 4 /* handle size */; }
};
AttReadByGroupTypeRsp(const uint8_t* source, const jau::nsize_t length)
@@ -1326,10 +1292,10 @@ namespace direct_bt {
}
/** opcode + element-size */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 1; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 1; }
/** Returns size of each element, i.e. handle-value triple. */
- jau::nsize_t getElementTotalSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getElementTotalSize() const noexcept override {
return pdu.get_uint8_nc(1);
}
@@ -1339,11 +1305,11 @@ namespace direct_bt {
* element := { uint16_t startHandle, uint16_t endHandle, uint8_t value[value-size] }
* </p>
*/
- jau::nsize_t getElementValueSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getElementValueSize() const noexcept override {
return getElementTotalSize() - 4;
}
- jau::nsize_t getElementCount() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getElementCount() const noexcept override {
return getPDUValueSize() / getElementTotalSize();
}
@@ -1363,7 +1329,7 @@ namespace direct_bt {
return pdu.get_wptr() + getElementPDUOffset(elementIdx) + 4 /* 2 handle size */;
}
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttReadByGroupTypeRsp";
}
@@ -1398,15 +1364,11 @@ namespace direct_bt {
/** opcode + handle_start + handle_end */
jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 2 + 2; }
- uint16_t getStartHandle() const noexcept {
- return pdu.get_uint16_nc( 1 );
- }
+ constexpr uint16_t getStartHandle() const noexcept { return pdu.get_uint16_nc( 1 ); }
- uint16_t getEndHandle() const noexcept {
- return pdu.get_uint16_nc( 1 + 2 );
- }
+ constexpr uint16_t getEndHandle() const noexcept { return pdu.get_uint16_nc( 1 + 2 ); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttFindInfoReq";
}
@@ -1471,7 +1433,7 @@ namespace direct_bt {
}
/** opcode + format */
- jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 1; }
+ constexpr_cxx20 jau::nsize_t getPDUValueOffset() const noexcept override { return 1 + 1; }
/** Returns size of each element, i.e. handle-value tuple. */
jau::nsize_t getElementTotalSize() const override {
@@ -1504,7 +1466,7 @@ namespace direct_bt {
return pdu.get_uuid( getElementPDUOffset(elementIdx) + 2, getUUIFormat() );
}
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "AttFindInfoRsp";
}
diff --git a/api/direct_bt/OctetTypes.hpp b/api/direct_bt/OctetTypes.hpp
index 519e3024..ebbb3487 100644
--- a/api/direct_bt/OctetTypes.hpp
+++ b/api/direct_bt/OctetTypes.hpp
@@ -195,12 +195,12 @@ namespace direct_bt {
return std::string( (const char*)(_data+i) );
}
/** Assumes a null terminated string */
- constexpr_func_cxx20 std::string get_string_nc(const jau::nsize_t i) const noexcept {
+ constexpr_cxx20 std::string get_string_nc(const jau::nsize_t i) const noexcept {
return std::string( (const char*)(_data+i) );
}
/** Assumes a string with defined length, not necessarily null terminated */
- std::string get_string(const jau::nsize_t i, const jau::nsize_t length) const {
+ inline std::string get_string(const jau::nsize_t i, const jau::nsize_t length) const {
check_range(i, length);
return std::string( (const char*)(_data+i), length );
}
@@ -380,12 +380,13 @@ namespace direct_bt {
direct_bt::put_uuid(data(), i, v, true /* littleEndian */);
}
- constexpr uint8_t * get_wptr() noexcept { return data(); }
+ inline uint8_t * get_wptr() noexcept { return data(); }
+
uint8_t * get_wptr(const jau::nsize_t i) {
check_range(i, 1);
return data() + i;
}
- constexpr uint8_t * get_wptr_nc(const jau::nsize_t i) noexcept {
+ inline uint8_t * get_wptr_nc(const jau::nsize_t i) noexcept {
return data() + i;
}
@@ -410,8 +411,8 @@ namespace direct_bt {
}
}
- jau::nsize_t getSize() const noexcept { return size; }
- jau::nsize_t getOffset() const noexcept { return offset; }
+ constexpr jau::nsize_t getSize() const noexcept { return size; }
+ constexpr jau::nsize_t getOffset() const noexcept { return offset; }
const TOctets& getParent() const noexcept { return parent; }
uint8_t get_uint8(const jau::nsize_t i) const {
diff --git a/api/direct_bt/SMPKeyBin.hpp b/api/direct_bt/SMPKeyBin.hpp
index 53eca7e5..2fce960c 100644
--- a/api/direct_bt/SMPKeyBin.hpp
+++ b/api/direct_bt/SMPKeyBin.hpp
@@ -170,7 +170,7 @@ class SMPKeyBin {
std::string toString() const noexcept;
- constexpr_func_cxx20 std::string getFileBasename() const noexcept {
+ std::string getFileBasename() const noexcept {
return "bd_"+addrAndType.address.toString()+":"+std::to_string(number(addrAndType.type))+".smpkey.bin";
}
static std::string getFileBasename(const BDAddressAndType& addrAndType_) {
diff --git a/api/direct_bt/SMPTypes.hpp b/api/direct_bt/SMPTypes.hpp
index d4774119..d995bef1 100644
--- a/api/direct_bt/SMPTypes.hpp
+++ b/api/direct_bt/SMPTypes.hpp
@@ -514,7 +514,7 @@ namespace direct_bt {
bzero(reinterpret_cast<void *>(this), sizeof(SMPLongTermKeyInfo));
}
- constexpr_func_cxx20 std::string toString() const noexcept { // hex-fmt aligned with btmon
+ std::string toString() const noexcept { // hex-fmt aligned with btmon
return "LTK[props "+getPropertyMaskString(properties)+", enc_size "+std::to_string(enc_size)+
", ediv "+jau::bytesHexString(reinterpret_cast<const uint8_t *>(&ediv), 0, sizeof(ediv), false /* lsbFirst */)+
", rand "+jau::bytesHexString(reinterpret_cast<const uint8_t *>(&rand), 0, sizeof(rand), false /* lsbFirst */)+
@@ -748,10 +748,10 @@ namespace direct_bt {
template<class T>
static T* clone(const T& source) noexcept { return new T(source); }
- uint64_t getTimestamp() const noexcept { return ts_creation; }
+ constexpr uint64_t getTimestamp() const noexcept { return ts_creation; }
/** SMP Command Codes Vol 3, Part H (SM): 3.3 */
- inline Opcode getOpcode() const noexcept {
+ constexpr Opcode getOpcode() const noexcept {
return static_cast<Opcode>(pdu.get_uint8_nc(0));
}
std::string getOpcodeString() const noexcept { return getOpcodeString(getOpcode()); }
@@ -769,7 +769,7 @@ namespace direct_bt {
*
* @see SMPPDUMsg::getDataSize()
*/
- jau::nsize_t getPDUParamSize() const noexcept {
+ constexpr jau::nsize_t getPDUParamSize() const noexcept {
return pdu.getSize() - 1 /* opcode */;
}
@@ -779,7 +779,7 @@ namespace direct_bt {
*
* @see SMPPDUMsg::getPDUParamSize()
*/
- virtual jau::nsize_t getDataSize() const noexcept {
+ constexpr_cxx20 virtual jau::nsize_t getDataSize() const noexcept {
return getPDUParamSize();
}
@@ -791,7 +791,7 @@ namespace direct_bt {
*/
constexpr jau::nsize_t getDataOffset() const noexcept { return 1; /* default: opcode */ }
- virtual std::string getName() const noexcept {
+ constexpr_cxx20 virtual std::string getName() const noexcept {
return "SMPPDUMsg";
}
@@ -910,7 +910,7 @@ namespace direct_bt {
pdu.put_uint8_nc(6, direct_bt::number(responder_key_dist));
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 6;
}
@@ -921,7 +921,7 @@ namespace direct_bt {
* </pre>
* @see IOCapability
*/
- SMPIOCapability getIOCapability() const noexcept {
+ constexpr SMPIOCapability getIOCapability() const noexcept {
return static_cast<SMPIOCapability>(pdu.get_uint8_nc(1));
}
@@ -932,7 +932,7 @@ namespace direct_bt {
* </pre>
* @see OOBDataFlag
*/
- SMPOOBDataFlag getOOBDataFlag() const noexcept {
+ constexpr SMPOOBDataFlag getOOBDataFlag() const noexcept {
return static_cast<SMPOOBDataFlag>(pdu.get_uint8_nc(2));
}
@@ -955,7 +955,7 @@ namespace direct_bt {
* This value defines the maximum encryption key size in octets that the device
* can support. The maximum key size shall be in the range 7 to 16 octets.
*/
- uint8_t getMaxEncryptionKeySize() const noexcept {
+ constexpr uint8_t getMaxEncryptionKeySize() const noexcept {
return pdu.get_uint8_nc(4);
}
/**
@@ -985,7 +985,7 @@ namespace direct_bt {
return responder_key_dist;
}
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPPairingMsg";
}
@@ -1049,7 +1049,7 @@ namespace direct_bt {
jau::put_uint128(pdu.get_wptr(), 1, confirm_value);
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 16;
}
@@ -1066,9 +1066,9 @@ namespace direct_bt {
* See Vol 3, Part H, 2.3.5.6 SM - Pairing algo - LE Secure Connections pairing phase 2.
* </p>
*/
- jau::uint128_t getConfirmValue() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
+ constexpr jau::uint128_t getConfirmValue() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPPairConfirm";
}
@@ -1144,7 +1144,7 @@ namespace direct_bt {
jau::put_uint128(pdu.get_wptr(), 1, random_value);
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 16;
}
@@ -1160,9 +1160,9 @@ namespace direct_bt {
* the initiating device sends Na and the responding device sends Nb.
* </p>
*/
- jau::uint128_t getRand() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
+ constexpr jau::uint128_t getRand() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPPairRand";
}
@@ -1221,15 +1221,15 @@ namespace direct_bt {
pdu.put_uint8_nc(1, number(rc));
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 1;
}
- ReasonCode getReasonCode() const noexcept {
+ constexpr ReasonCode getReasonCode() const noexcept {
return static_cast<ReasonCode>(pdu.get_uint8_nc(1));
}
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPPairFailed";
}
@@ -1279,21 +1279,21 @@ namespace direct_bt {
jau::put_uint256(pdu.get_wptr(), 1+32, pub_key_y);
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 32+32;
}
/**
* Returns the 256-bit Public Key X value (32 octets)
*/
- jau::uint256_t getPubKeyX() const noexcept { return jau::get_uint256(pdu.get_ptr(), 1); }
+ constexpr jau::uint256_t getPubKeyX() const noexcept { return jau::get_uint256(pdu.get_ptr(), 1); }
/**
* Returns the 256-bit Public Key Y value (32 octets)
*/
- jau::uint256_t getPubKeyY() const noexcept { return jau::get_uint256(pdu.get_ptr(), 1+32); }
+ constexpr jau::uint256_t getPubKeyY() const noexcept { return jau::get_uint256(pdu.get_ptr(), 1+32); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPPairPubKey";
}
@@ -1342,16 +1342,16 @@ namespace direct_bt {
jau::put_uint128(pdu.get_wptr(), 1, dhkey_check_values);
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 16;
}
/**
* Returns the 128-bit DHKey Check value (16 octets)
*/
- jau::uint128_t getDHKeyCheck() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
+ constexpr jau::uint128_t getDHKeyCheck() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPPairDHKeyCheck";
}
@@ -1403,15 +1403,15 @@ namespace direct_bt {
pdu.put_uint8_nc(1, number(tc));
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 1;
}
- TypeCode getTypeCode() const noexcept {
+ constexpr TypeCode getTypeCode() const noexcept {
return static_cast<TypeCode>(pdu.get_uint8_nc(1));
}
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPPasskeyNotify";
}
@@ -1465,7 +1465,7 @@ namespace direct_bt {
jau::put_uint128(pdu.get_wptr(), 1, long_term_key);
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 16;
}
@@ -1476,9 +1476,9 @@ namespace direct_bt {
* see Vol 3, Part H, 2.4.2.3 SM - LE legacy pairing - generation of LTK, EDIV and Rand.
* </p>
*/
- jau::uint128_t getLTK() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
+ constexpr jau::uint128_t getLTK() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPEncInfo";
}
@@ -1535,7 +1535,7 @@ namespace direct_bt {
jau::put_uint64(pdu.get_wptr(), 1+2, rand);
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 10;
}
@@ -1545,7 +1545,7 @@ namespace direct_bt {
* See Vol 3, Part H, 2.4.2.3 SM - Generation of CSRK - LE legacy pairing - generation of LTK, EDIV and Rand.
* </p>
*/
- uint16_t getEDIV() const noexcept { return jau::get_uint16(pdu.get_ptr(), 1); }
+ constexpr uint16_t getEDIV() const noexcept { return jau::get_uint16(pdu.get_ptr(), 1); }
/**
* Returns the 64-bit Rand value (8 octets) being distributed
@@ -1553,9 +1553,9 @@ namespace direct_bt {
* See Vol 3, Part H, 2.4.2.3 SM - Generation of CSRK - LE legacy pairing - generation of LTK, EDIV and Rand.
* </p>
*/
- uint64_t getRand() const noexcept { return jau::get_uint64(pdu.get_ptr(), 1+2); }
+ constexpr uint64_t getRand() const noexcept { return jau::get_uint64(pdu.get_ptr(), 1+2); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPMasterIdent";
}
@@ -1612,7 +1612,7 @@ namespace direct_bt {
jau::put_uint128(pdu.get_wptr(), 1, identity_resolving_key);
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 16;
}
@@ -1623,9 +1623,9 @@ namespace direct_bt {
* see Vol 3, Part H, 2.4.2.1 SM - Definition of keys and values - Generation of IRK.
* </p>
*/
- jau::uint128_t getIRK() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
+ constexpr jau::uint128_t getIRK() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPIdentInfo";
}
@@ -1678,21 +1678,21 @@ namespace direct_bt {
pdu.put_eui48_nc(1+1, addr);
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 1+6;
}
/**
* Returns whether the device address is static random (true) or public (false).
*/
- bool isStaticRandomAddress() const noexcept { return pdu.get_uint16_nc(1) == 0x01; }
+ constexpr bool isStaticRandomAddress() const noexcept { return pdu.get_uint16_nc(1) == 0x01; }
/**
* Returns the device address
*/
- EUI48 getAddress() const noexcept { return pdu.get_eui48_nc(1+1); }
+ inline EUI48 getAddress() const noexcept { return pdu.get_eui48_nc(1+1); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPIdentAddrInfo";
}
@@ -1748,7 +1748,7 @@ namespace direct_bt {
jau::put_uint128(pdu.get_wptr(), 1, signature_key);
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 16;
}
@@ -1759,9 +1759,9 @@ namespace direct_bt {
* see Vol 3, Part H, 2.4.2.2 SM - Definition of keys and values - Generation of CSRK.
* </p>
*/
- jau::uint128_t getCSRK() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
+ constexpr jau::uint128_t getCSRK() const noexcept { return jau::get_uint128(pdu.get_ptr(), 1); }
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPSignInfo";
}
@@ -1806,7 +1806,7 @@ namespace direct_bt {
pdu.put_uint8_nc(1, direct_bt::number(authReqMask));
}
- jau::nsize_t getDataSize() const noexcept override {
+ constexpr_cxx20 jau::nsize_t getDataSize() const noexcept override {
return 1;
}
@@ -1826,7 +1826,7 @@ namespace direct_bt {
return isSMPAuthReqBitSet(authReqMask, bit);
}
- std::string getName() const noexcept override {
+ constexpr_cxx20 std::string getName() const noexcept override {
return "SMPSecurityReq";
}