aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp21
1 files changed, 14 insertions, 7 deletions
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;
}