diff options
Diffstat (limited to 'Bluetooth.cpp')
-rw-r--r-- | Bluetooth.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Bluetooth.cpp b/Bluetooth.cpp index a8b95a1..9c32740 100644 --- a/Bluetooth.cpp +++ b/Bluetooth.cpp @@ -72,18 +72,18 @@ AttPduType AttPdu::getType() { return (AttPduType) bytes.get8(0); } -void AttPdu::makeReadByGroupType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, uint16_t uuid) { +void AttPdu::makeReadByGroupType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, SpecUuid uuid) { bytes.write8(AttPduType::READ_BY_GROUP_TYPE_REQ); bytes.write16le(startHandle); bytes.write16le(endHandle); - bytes.write16le(uuid); + bytes.write16le(uuid.value); } -void AttPdu::makeReadByType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, uint16_t uuid) { +void AttPdu::makeReadByType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, SpecUuid uuid) { bytes.write8(AttPduType::READ_BY_TYPE_REQ); bytes.write16le(startHandle); bytes.write16le(endHandle); - bytes.write16le(uuid); + bytes.write16le(uuid.value); } void AttPdu::checkType(ByteBuffer &bytes, AttPduType type) { @@ -99,10 +99,10 @@ void AttPdu::checkType(ByteBuffer &bytes, AttPduType type) { } } -vector<AttributeData> AttPdu::parseReadByGroupType(ByteBuffer &bytes) { +vector<AttributeData> AttPdu::parse(ByteBuffer &bytes, AttPduType type) { DF << "bytes: " << bytes.toString(); - checkType(bytes, READ_BY_GROUP_TYPE_RES); + 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())); @@ -125,6 +125,14 @@ vector<AttributeData> AttPdu::parseReadByGroupType(ByteBuffer &bytes) { return values; } +vector<AttributeData> AttPdu::parseReadByGroupType(ByteBuffer &bytes) { + return parse(bytes, READ_BY_GROUP_TYPE_RES); +} + +vector<AttributeData> AttPdu::parseReadByType(ByteBuffer &bytes) { + return parse(bytes, READ_BY_TYPE_RES); +} + // ----------------------------------------------------------------------- // AttributeData // ----------------------------------------------------------------------- @@ -137,7 +145,7 @@ AttributeData AttributeData::fromByteBuffer(ByteBuffer &bytes) { } AttributeData::AttributeData(uint16_t handle, uint16_t groupEndHandle, ByteBuffer value) : - handle(handle), groupEndHandle(groupEndHandle), value(value) { + handle(handle), endGroupHandle(groupEndHandle), value(value) { } AttributeData::~AttributeData() { |