diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-11-23 09:40:48 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-11-23 09:40:48 +0100 |
commit | 2034b1bb10720a2f0e6cc97427346f2320c115bc (patch) | |
tree | c382c6e404d48078aac71e2fd3f7f34587b99e7b /ble/att.cpp | |
parent | 0e2228fae626ec617a6a1f042ceb6dbdbd774558 (diff) | |
download | ble-toys-2034b1bb10720a2f0e6cc97427346f2320c115bc.tar.gz ble-toys-2034b1bb10720a2f0e6cc97427346f2320c115bc.tar.bz2 ble-toys-2034b1bb10720a2f0e6cc97427346f2320c115bc.tar.xz ble-toys-2034b1bb10720a2f0e6cc97427346f2320c115bc.zip |
o Starting to handle notifications and indications
Cleaning up:
o Using more of the shared_ptr typedefs.
o Adding code styles used by CLion.
Diffstat (limited to 'ble/att.cpp')
-rw-r--r-- | ble/att.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ble/att.cpp b/ble/att.cpp index 301918d..4d3529a 100644 --- a/ble/att.cpp +++ b/ble/att.cpp @@ -153,7 +153,8 @@ vector<AttributeData> AttPdu::parseAttributeData(ByteBuffer &bytes) { } AttVariant AttPdu::parse(ByteBuffer &bytes) { - switch (static_cast<AttPduType>(bytes.read8())) { + auto type = static_cast<AttPduType>(bytes.read8()); + switch (type) { case AttPduType::ERROR: return ErrorRes::parse(bytes); case AttPduType::EXCHANGE_MTU_REQ: @@ -166,6 +167,10 @@ AttVariant AttPdu::parse(ByteBuffer &bytes) { return ReadByGroupTypeRes{parseAttributeData(bytes)}; case AttPduType::READ_BY_TYPE_RES: return ReadByTypeRes{parseAttributeData(bytes)}; + case AttPduType::HANDLE_VALUE_NOTIFICATION: + return parseHandleValueNotification(bytes); + case AttPduType::HANDLE_VALUE_INDICATION: + return parseHandleValueIndication(bytes); default: return {}; } @@ -196,6 +201,14 @@ FindInformationRes AttPdu::parseFindInformationRes(ByteBuffer &bytes) { return {format, information}; } +HandleValueNotification AttPdu::parseHandleValueNotification(ByteBuffer &bytes) { + return {bytes.read16le(), bytes.viewCursorToEnd()}; +} + +HandleValueIndication AttPdu::parseHandleValueIndication(ByteBuffer &bytes) { + return {bytes.read16le(), bytes.viewCursorToEnd()}; +} + void AttPdu::parseRead(ByteBuffer &bytes) { auto t = static_cast<AttPduType>(bytes.read8()); |