From b55df0b8e46f46fea4d69f98a729cd237d77a6ed Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 10 Feb 2015 21:29:19 +0100 Subject: o wip. --- main.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index ad713e8..7caa303 100644 --- a/main.cpp +++ b/main.cpp @@ -10,8 +10,8 @@ static Mac *targetMac; void scan_callback(BluetoothDevice &device) { device.adapter().stopScan(); - if (device.mac() == *targetMac) { - cout << "found device: " << device.mac().str() << ", but not the one we want" << endl; + if (device.mac() != *targetMac) { + cout << "found device: " << device.mac().str() << ", but not the one we want " << targetMac->str() << endl; return; } @@ -30,18 +30,25 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - targetMac = Mac::parseMac(argv[1]); - BluetoothAdapter *adapter = nullptr; int e; try { - adapter = trygvis::getDevice(0); + targetMac = Mac::parseMac(argv[1]); + + adapter = trygvis::getAdapter(0); + + BluetoothDevice &device = adapter->getDevice(*targetMac); - adapter->runScan(scan_callback); + scan_callback(device); + +// adapter->runScan(scan_callback); e = EXIT_SUCCESS; } catch (BluetoothException ex) { - W << "Excpetion: " << ex.what(); + W << "BluetoothException: " << ex.what(); + e = EXIT_FAILURE; + } catch (std::exception ex) { + W << "std::exception: " << ex.what(); e = EXIT_FAILURE; } -- cgit v1.2.3