diff options
Diffstat (limited to 'Bluetooth.cpp')
-rw-r--r-- | Bluetooth.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Bluetooth.cpp b/Bluetooth.cpp index 5dca8fa..dd9e48e 100644 --- a/Bluetooth.cpp +++ b/Bluetooth.cpp @@ -1,7 +1,6 @@ #include <sstream> #include <iomanip> #include <string.h> -#include <hwloc.h> #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<AttributeData*>* AttPdu::parseReadByGroupType(ByteBuffer &bytes) { + vector<AttributeData> 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<AttributeData*> *values = new vector<AttributeData*>; + vector<AttributeData> 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() { |