diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-10 19:02:57 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-10 19:02:57 +0100 |
commit | 1c97f6df59c825b26ecb18975fd9f62e14fc46ce (patch) | |
tree | 0bdd9b909e2f2476d78527d39efc301414048609 /main.cpp | |
parent | 5cb96fd96f51e949c5311db3080c58d851b7c2e1 (diff) | |
download | ble-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.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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; } |