From 52450ed3034b0ba058ea2c9f9baa2d5f78df6a94 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 17 Nov 2018 22:38:32 +0100 Subject: 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. --- ble/LinuxBluetooth.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'ble/LinuxBluetooth.cpp') 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(s, c.handle, uuid, properties, valueHandle))); } -- cgit v1.2.3