From 5460c461809294bb302be8aa6e80533ec30e28e4 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 19 Feb 2015 00:04:06 +0100 Subject: o Reading characteristics, unable to parse just yet. --- Bluetooth.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'Bluetooth.cpp') 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 AttPdu::parseReadByGroupType(ByteBuffer &bytes) { +vector 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 AttPdu::parseReadByGroupType(ByteBuffer &bytes) { return values; } +vector AttPdu::parseReadByGroupType(ByteBuffer &bytes) { + return parse(bytes, READ_BY_GROUP_TYPE_RES); +} + +vector 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() { -- cgit v1.2.3