diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-19 09:09:56 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-19 09:09:56 +0100 |
commit | ed2ec4bb64052d3ed8d2357abdc080aea4341811 (patch) | |
tree | 5a0484d4b4bde449e16b9370d830a92b16b11c7f /Bluetooth.cpp | |
parent | 5460c461809294bb302be8aa6e80533ec30e28e4 (diff) | |
download | ble-toys-ed2ec4bb64052d3ed8d2357abdc080aea4341811.tar.gz ble-toys-ed2ec4bb64052d3ed8d2357abdc080aea4341811.tar.bz2 ble-toys-ed2ec4bb64052d3ed8d2357abdc080aea4341811.tar.xz ble-toys-ed2ec4bb64052d3ed8d2357abdc080aea4341811.zip |
o Successfully reading all characteristics.
Diffstat (limited to 'Bluetooth.cpp')
-rw-r--r-- | Bluetooth.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Bluetooth.cpp b/Bluetooth.cpp index 9c32740..e634233 100644 --- a/Bluetooth.cpp +++ b/Bluetooth.cpp @@ -86,23 +86,18 @@ void AttPdu::makeReadByType(ByteBuffer &bytes, uint16_t startHandle, uint16_t en bytes.write16le(uuid.value); } -void AttPdu::checkType(ByteBuffer &bytes, AttPduType type) { - if (bytes.getSize() == 0) { - throw BluetoothException("PDU is too small"); - } +vector<AttributeData> AttPdu::parse(ByteBuffer &bytes, AttPduType type) { + DF << "bytes: " << bytes.toString(); - bytes.setCursor(0); AttPduType t = (AttPduType) bytes.read8(); + if (t == INVALID_HANDLE) { + return vector<AttributeData>(); + } + if (t != type) { throw BluetoothException("Unexpected type: " + to_string(t)); } -} - -vector<AttributeData> AttPdu::parse(ByteBuffer &bytes, AttPduType type) { - DF << "bytes: " << bytes.toString(); - - checkType(bytes, type); if (bytes.getSize() < 4) { throw BluetoothException("Bad READ_BY_GROUP_TYPE_RES packet, expected at least 4 octets, got " + to_string(bytes.getSize())); |