aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/main.cpp b/main.cpp
index ab1a9b0..ad713e8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -18,6 +18,9 @@ void scan_callback(BluetoothDevice &device) {
cout << "found device: " << device.mac().str() << endl;
device.connect();
+
+ device.discoverServices();
+
device.disconnect();
}
@@ -29,16 +32,21 @@ int main(int argc, char *argv[]) {
targetMac = Mac::parseMac(argv[1]);
+ BluetoothAdapter *adapter = nullptr;
+ int e;
try {
- BluetoothAdapter *adapter = trygvis::getDevice(0);
+ adapter = trygvis::getDevice(0);
adapter->runScan(scan_callback);
- delete adapter;
-
- return EXIT_SUCCESS;
+ e = EXIT_SUCCESS;
} catch (BluetoothException ex) {
W << "Excpetion: " << ex.what();
- return EXIT_FAILURE;
+ e = EXIT_FAILURE;
+ }
+
+ if (adapter != nullptr) {
+ delete adapter;
}
+ return e;
}