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