aboutsummaryrefslogtreecommitdiff
path: root/Bluetooth.cpp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-02-19 00:04:06 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-02-19 00:04:06 +0100
commit5460c461809294bb302be8aa6e80533ec30e28e4 (patch)
treea171ce52d4f8908aeb9d13770965b9890608f738 /Bluetooth.cpp
parent4d2339c65548cf553891b049200e6a845de293e9 (diff)
downloadble-toys-5460c461809294bb302be8aa6e80533ec30e28e4.tar.gz
ble-toys-5460c461809294bb302be8aa6e80533ec30e28e4.tar.bz2
ble-toys-5460c461809294bb302be8aa6e80533ec30e28e4.tar.xz
ble-toys-5460c461809294bb302be8aa6e80533ec30e28e4.zip
o Reading characteristics, unable to parse just yet.
Diffstat (limited to 'Bluetooth.cpp')
-rw-r--r--Bluetooth.cpp22
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() {