diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-11-17 22:38:32 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-11-17 22:38:32 +0100 |
commit | 52450ed3034b0ba058ea2c9f9baa2d5f78df6a94 (patch) | |
tree | 97fe35d5d7fe6fe354b2effe8c0ef4836787eb83 /apps/ble-bts.cpp | |
parent | a167d6e68e634a70af442cd86e43fd9223b1431c (diff) | |
download | ble-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 'apps/ble-bts.cpp')
-rw-r--r-- | apps/ble-bts.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
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; |