aboutsummaryrefslogtreecommitdiff
path: root/Bluetooth.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Bluetooth.cpp')
-rw-r--r--Bluetooth.cpp17
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()));