From d88eee8fcf23e20ae76b3dd346b36af693849ccd Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 22 Nov 2018 19:30:14 +0100 Subject: o Working enabling of notifications. --- include/ble/att.h | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'include/ble/att.h') 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 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; -o attPduType(const AttVariant& v); +o 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 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 -- cgit v1.2.3