aboutsummaryrefslogtreecommitdiff
path: root/ble/LinuxBluetooth.cpp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-11-17 22:38:32 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2018-11-17 22:38:32 +0100
commit52450ed3034b0ba058ea2c9f9baa2d5f78df6a94 (patch)
tree97fe35d5d7fe6fe354b2effe8c0ef4836787eb83 /ble/LinuxBluetooth.cpp
parenta167d6e68e634a70af442cd86e43fd9223b1431c (diff)
downloadble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.tar.gz
ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.tar.bz2
ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.tar.xz
ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.zip
apps/ble-bts:
o Adding start of health termometer service tool. apps/ble-read-characteristic: o Sart of new tool. apps/ble-inspect-device o Make adapter configurable. other: o UUID fixes and tests.
Diffstat (limited to 'ble/LinuxBluetooth.cpp')
-rw-r--r--ble/LinuxBluetooth.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/ble/LinuxBluetooth.cpp b/ble/LinuxBluetooth.cpp
index 541093b..e567d62 100644
--- a/ble/LinuxBluetooth.cpp
+++ b/ble/LinuxBluetooth.cpp
@@ -251,15 +251,18 @@ Uuid readUuid(BluetoothDevice *device, ByteBuffer &bytes) {
if (bytesLeft == 2) {
uint8_t bs[16] = BLUETOOTH_UUID_INITIALIZER;
- bs[2] = bytes.read8();
bs[3] = bytes.read8();
+ bs[2] = bytes.read8();
return Uuid(bs);
} else if (bytesLeft == 16) {
- return {bytes.read8(), bytes.read8(), bytes.read8(), bytes.read8(),
- bytes.read8(), bytes.read8(), bytes.read8(), bytes.read8(),
- bytes.read8(), bytes.read8(), bytes.read8(), bytes.read8(),
- bytes.read8(), bytes.read8(), bytes.read8(), bytes.read8()};
+ uint8_t bs[16] = {
+ bytes.get8(15), bytes.get8(14), bytes.get8(13), bytes.get8(12), bytes.get8(11), bytes.get8(10), bytes.get8(9), bytes.get8(8),
+ bytes.get8(7), bytes.get8(6), bytes.get8(5), bytes.get8(4), bytes.get8(3), bytes.get8(2), bytes.get8(1), bytes.get8(0),
+ };
+ bytes.skip(16);
+
+ return Uuid{bs};
} else {
throw BluetoothException(device, "Unexpected bytes left: " + to_string(bytesLeft));
}
@@ -368,10 +371,10 @@ void LinuxBluetoothGatt::discoverServices() {
uint16_t valueHandle = c.value.read16le();
auto uuid = readUuid(&device, c.value);
-// D << "characteristic: handle: " << setw(2) << setfill('0') << hex << (int) c.handle <<
-// ", properties: " << setw(2) << setfill('0') << hex << (int) properties <<
-// ", valueHandle: 0x" << setw(4) << setfill('0') << hex << (int) valueHandle <<
-// ", uuid: " << uuid;
+ LOG_DEBUG("characteristic: handle: " << setw(2) << setfill('0') << hex << (int) c.handle <<
+ ", properties: " << setw(2) << setfill('0') << hex << (int) properties <<
+ ", valueHandle: 0x" << setw(4) << setfill('0') << hex << (int) valueHandle <<
+ ", uuid: " << uuid);
s->addCharacteristic(std::move(make_shared<DefaultBluetoothGattCharacteristic>(s, c.handle, uuid, properties, valueHandle)));
}