diff options
Diffstat (limited to 'include/ble/att.h')
-rw-r--r-- | include/ble/att.h | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/include/ble/att.h b/include/ble/att.h index 1db560e..db21d2e 100644 --- a/include/ble/att.h +++ b/include/ble/att.h @@ -49,6 +49,8 @@ std::string to_string(AttPduType t); class AttributeData; +class InformationData; + /** * Application Error 0x80 – 0xFF Application error code defined by a higher layer specification. * @@ -92,7 +94,7 @@ struct ErrorRes { */ uint8_t errorCode; - static ErrorRes parse(ByteBuffer& buffer) { + static ErrorRes parse(ByteBuffer &buffer) { return {buffer.read8(), buffer.read16le(), buffer.read8()}; } }; @@ -109,6 +111,13 @@ struct ExchangeMtuRes { uint16_t serverRxMtu; }; +struct FindInformationRes { + static constexpr auto att_pdu_type = AttPduType::FIND_INFORMATION_RES; + + uint8_t format; + std::vector<InformationData> information; +}; + struct ReadByGroupTypeRes { static constexpr auto att_pdu_type = AttPduType::READ_BY_GROUP_TYPE_RES; @@ -124,9 +133,10 @@ struct ReadByTypeRes { using AttVariant = std::variant<std::monostate, ErrorRes, ExchangeMtuReq, ExchangeMtuRes, + FindInformationRes, ReadByGroupTypeRes, ReadByTypeRes>; -o<AttPduType> attPduType(const AttVariant& v); +o<AttPduType> attPduType(const AttVariant &v); class AttPdu { public: @@ -139,14 +149,19 @@ public: static AttVariant parse(ByteBuffer &bytes); static ExchangeMtuReq parseExchangeMtuReq(ByteBuffer &bytes); + static ExchangeMtuRes parseExchangeMtuRes(ByteBuffer &bytes); + static FindInformationRes parseFindInformationRes(ByteBuffer &bytes); + static void parseRead(ByteBuffer &bytes); static void parseWrite(ByteBuffer &bytes); static void makeExchangeMtuRes(ByteBuffer &bytes, uint16_t serverRxMtu); + static void makeFindInformationReq(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle); + static void makeReadByGroupType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, ShortUuid uuid); static void makeReadByType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, ShortUuid uuid); @@ -178,5 +193,23 @@ private: std::shared_ptr<uint8_t[]> raw; }; +class InformationData { +public: + static constexpr uint8_t FORMAT_SHORT_UUID = 0x01; + static constexpr uint8_t FORMAT_LONG_UUID = 0x02; + + ~InformationData() = default; + + static InformationData fromByteBufferShortUuid(ByteBuffer &value); + + static InformationData fromByteBufferLongUuid(ByteBuffer &value); + + const uint16_t handle; + const Uuid uuid; + +private: + InformationData(uint16_t handle, const Uuid &uuid); +}; + } // namespace bluetooth } // namespace trygvis |