From ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 19 Jul 2015 21:39:28 +0200 Subject: o Going back to a bunch of cpp files instead of launcher+bunch of header files. This ends up with an easier build file and faster builds with CMake's "OBJECT" library type. --- apps/ble-scan.h | 79 --------------------------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 apps/ble-scan.h (limited to 'apps/ble-scan.h') diff --git a/apps/ble-scan.h b/apps/ble-scan.h deleted file mode 100644 index 2c183e3..0000000 --- a/apps/ble-scan.h +++ /dev/null @@ -1,79 +0,0 @@ -#include "ble/Bluetooth.h" -#include "apps.h" - -#include - -namespace trygvis { -namespace apps { - -using namespace std; -using namespace trygvis::bluetooth; -using namespace trygvis::apps; - -namespace ble_scan_utils { - -static std::function onSignal; - -static void signal_handler(int signal) { - onSignal(signal); -} -} - -class ble_scan : public app { -public: - ble_scan() : app("ble-scan") { - } - - ~ble_scan() = default; - - void add_options(po::options_description_easy_init &options) override { - options("adapter", po::value()->default_value(0), "Which adapter to use."); - } - - int main(app_execution &execution) override { - BluetoothSystem bluetoothSystem; - shared_ptr adapter; - - struct sigaction sigIntHandler; - - ble_scan_utils::onSignal = [&](int signal) { adapter->stopScan(); }; - - sigIntHandler.sa_handler = &ble_scan_utils::signal_handler; - sigemptyset(&sigIntHandler.sa_mask); - sigIntHandler.sa_flags = 0; - - sigaction(SIGINT, &sigIntHandler, NULL); - - try { - auto adapter_index = execution.vm["adapter"].as(); - - adapter = getAdapter(adapter_index); - - set seen_devices; - - cout << "Scanning with adapter #" << adapter_index << ", mac=" << adapter->getMac().str() << endl; - - adapter->runScan([&](BluetoothDevice &device) { - auto mac = device.getMac(); - - cout << "Found: " << mac.str() << endl; - - seen_devices.insert(mac); - }); - - cout << "Stopped. Found " << seen_devices.size() << " devices." << endl; - - for_each(begin(seen_devices), end(seen_devices), [&](auto mac) { cout << mac.str() << endl; }); - - return EXIT_SUCCESS; - } catch (std::runtime_error ex) { - cout << "std::runtime_error: " << ex.what() << endl; - return EXIT_FAILURE; - } catch (std::exception ex) { - cout << "std::exception: " << ex.what() << endl; - return EXIT_FAILURE; - } - } -}; -} -} -- cgit v1.2.3