diff options
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; } |