From e44813dddbf5ba063d29ae1e40862e7a7cbb6f43 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 20 Feb 2015 22:56:22 +0100 Subject: Reorganizing the source code: o Moving main to apps/ o Moving the library sources to ble/ o Creating cmake files for each piece. --- main.cpp | 72 ---------------------------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 main.cpp (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp deleted file mode 100644 index 361311c..0000000 --- a/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include -#include "Bluetooth.h" - -using namespace std; -using namespace trygvis::bluetooth; - -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 " << targetMac->str() << endl; - return; - } - - cout << "Connecting to device: " << device.mac().str() << endl; - - device.connect(); - - device.discoverServices(); - - vector services = device.getServices(); - cout << "Device has " << services.size() << " services" << endl; - - for (auto &s: services) { - const vector characteristics = s->getCharacteristics(); - - cout << "Service: UUID: " << s->getUuid() << ", has " << characteristics.size() << " characteristics" << endl; - - for (auto &c: characteristics) { - cout << "Characteristic: UUID: " << c->getUuid() << ", properties: " << (int) c->getProperties() << endl; - } - } - - device.disconnect(); -} - -int main(int argc, char *argv[]) { - if (argc != 2) { - cerr << "usage: " << argv[0] << " [mac]" << endl; - return EXIT_FAILURE; - } - - int e; -// try { - Mac mac = Mac::parseMac(argv[1]); - targetMac = &mac; - - BluetoothAdapter &adapter = getAdapter(0); - - BluetoothDevice &device = adapter.getDevice(mac); - - scan_callback(device); - -// adapter->runScan(scan_callback); - - e = EXIT_SUCCESS; -// } catch (std::runtime_error ex) { -// W << "std::runtime_error: " << ex.what(); -// e = EXIT_FAILURE; -// } catch (std::exception ex) { -// W << "std::exception: " << ex.what(); -// e = EXIT_FAILURE; -// } - - shutdown(); - return e; -} -- cgit v1.2.3