aboutsummaryrefslogtreecommitdiff
path: root/apps/ble-bts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'apps/ble-bts.cpp')
-rw-r--r--apps/ble-bts.cpp14
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;