aboutsummaryrefslogtreecommitdiff
path: root/ble/LinuxBluetooth.cpp
diff options
context:
space:
mode:
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)));
}