From 60d5440dd3514e71b87948ff5ed30ee38445b8a5 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 15 Feb 2015 11:01:46 +0100 Subject: o wip. Test cases! --- Bluetooth.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'Bluetooth.cpp') diff --git a/Bluetooth.cpp b/Bluetooth.cpp index 5dca8fa..dd9e48e 100644 --- a/Bluetooth.cpp +++ b/Bluetooth.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "Bluetooth.h" namespace trygvis { @@ -15,12 +14,12 @@ namespace trygvis { std::ostringstream buf; buf - << setw(2) << hex << setfill('0') << (int) bytes[5] << ":" - << setw(2) << hex << setfill('0') << (int) bytes[4] << ":" - << setw(2) << hex << setfill('0') << (int) bytes[3] << ":" - << setw(2) << hex << setfill('0') << (int) bytes[2] << ":" + << setw(2) << hex << setfill('0') << (int) bytes[0] << ":" << setw(2) << hex << setfill('0') << (int) bytes[1] << ":" - << setw(2) << hex << setfill('0') << (int) bytes[0]; + << setw(2) << hex << setfill('0') << (int) bytes[2] << ":" + << setw(2) << hex << setfill('0') << (int) bytes[3] << ":" + << setw(2) << hex << setfill('0') << (int) bytes[4] << ":" + << setw(2) << hex << setfill('0') << (int) bytes[5]; return buf.str(); } @@ -91,7 +90,7 @@ namespace trygvis { } } - vector* AttPdu::parseReadByGroupType(ByteBuffer &bytes) { + vector AttPdu::parseReadByGroupType(ByteBuffer &bytes) { checkType(bytes, READ_BY_GROUP_TYPE_RES); if (bytes.getSize() < 4) { @@ -104,9 +103,9 @@ namespace trygvis { size_t count = (bytes.getSize() - 2) / length; DF << "count=" << count; - vector *values = new vector; + vector values; for (int i = 0; i < count; i++) { - values->push_back(AttributeData::fromByteBuffer(bytes, length)); + values.push_back(AttributeData::fromByteBuffer(bytes, length)); } return values; @@ -116,13 +115,15 @@ namespace trygvis { // AttributeData // ----------------------------------------------------------------------- - AttributeData* AttributeData::fromByteBuffer(ByteBuffer &bytes, uint8_t length) { + AttributeData AttributeData::fromByteBuffer(ByteBuffer &bytes, uint8_t length) { uint16_t handle = bytes.get16le(); + uint16_t groupEndHandle = bytes.get16le(); - return new AttributeData(handle, bytes.view(length)); + return AttributeData(handle, groupEndHandle, bytes.view(length)); } - AttributeData::AttributeData(uint16_t handle, ByteBuffer bytes) : handle(handle), value(value) { + AttributeData::AttributeData(uint16_t handle, uint16_t groupEndHandle, ByteBuffer value) : + handle(handle), groupEndHandle(groupEndHandle), value(value) { } AttributeData::~AttributeData() { -- cgit v1.2.3