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. --- apps/ble-bts.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'apps/ble-bts.cpp') diff --git a/apps/ble-bts.cpp b/apps/ble-bts.cpp index 82d6d43..3f79f2c 100644 --- a/apps/ble-bts.cpp +++ b/apps/ble-bts.cpp @@ -59,9 +59,11 @@ public: auto gatt = device->connectGatt(); cout << "Connected" << endl; + gatt->discoverServices(); + auto bts = gatt->findService(uuids::HealthTermometerService); if (!bts) { - cout << "Device does not implement Health thermometer service" << endl; + cout << "Device does not implement Health thermometer service (" << uuids::HealthTermometerService.str() << ")" << endl; return EXIT_FAILURE; } @@ -72,7 +74,7 @@ public: return EXIT_FAILURE; } - with_connection(gatt, tmc.value()); + with_characteristic(gatt, tmc.value()); return EXIT_SUCCESS; } catch (std::runtime_error &ex) { @@ -84,7 +86,7 @@ public: } } - void with_connection(BluetoothGattPtr gatt, BluetoothGattCharacteristicPtr tmc) { + void with_characteristic(const BluetoothGattPtr &gatt, const BluetoothGattCharacteristicPtr &tmc) { auto svc = tmc->getService(); cout << "Reading temp value" << endl; @@ -93,13 +95,13 @@ public: cout << "bytes " << buf.getSize() << endl; - for (int i = 0; i < buf.getSize(); i++) { + for (size_t i = 0; i < buf.getSize(); i++) { cout << "byte " << i << " = " << hex << buf.peek8(i) << endl; } } }; -} -} +} // namespace apps +} // namespace trygvis int main(int argc, const char *argv[]) { using namespace trygvis::apps; -- cgit v1.2.3