diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-15 11:01:46 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-15 11:01:46 +0100 |
commit | 60d5440dd3514e71b87948ff5ed30ee38445b8a5 (patch) | |
tree | 0d983caed47449c875c5188e604e81da29e1b82c /Bluetooth.cpp | |
parent | 041bbe24b39190ac0b624b2709fc38dea17ad0a7 (diff) | |
download | ble-toys-60d5440dd3514e71b87948ff5ed30ee38445b8a5.tar.gz ble-toys-60d5440dd3514e71b87948ff5ed30ee38445b8a5.tar.bz2 ble-toys-60d5440dd3514e71b87948ff5ed30ee38445b8a5.tar.xz ble-toys-60d5440dd3514e71b87948ff5ed30ee38445b8a5.zip |
o wip. Test cases!
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() { |