aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-02-10 19:02:57 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-02-10 19:02:57 +0100
commit1c97f6df59c825b26ecb18975fd9f62e14fc46ce (patch)
tree0bdd9b909e2f2476d78527d39efc301414048609 /main.cpp
parent5cb96fd96f51e949c5311db3080c58d851b7c2e1 (diff)
downloadble-toys-1c97f6df59c825b26ecb18975fd9f62e14fc46ce.tar.gz
ble-toys-1c97f6df59c825b26ecb18975fd9f62e14fc46ce.tar.bz2
ble-toys-1c97f6df59c825b26ecb18975fd9f62e14fc46ce.tar.xz
ble-toys-1c97f6df59c825b26ecb18975fd9f62e14fc46ce.zip
o wip.
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;
}