From d720fa36ad4768ed1b948a92ba5287c30093fbec Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 26 Jul 2015 18:33:15 +0200 Subject: o Overhaul of the bluetooth code. - Adding support for reading FLOAT (specified in IEEE 11073-20601) values from a bluetooth device. - More shared pointers to help keep track of the object's lifecycle. Makes sure that the connections are released back to Linux, Linux is way to sensitive with crashing applications. o Adding support for reading the temperature sensors from the SoilMoisture device. --- apps/ble-scan.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'apps/ble-scan.cpp') diff --git a/apps/ble-scan.cpp b/apps/ble-scan.cpp index 839a9fa..158af14 100644 --- a/apps/ble-scan.cpp +++ b/apps/ble-scan.cpp @@ -26,8 +26,11 @@ public: ~ble_scan() = default; + string adapter_name; + void add_options(po::options_description_easy_init &options) override { - options("adapter", po::value()->default_value(0), "Which adapter to use."); + auto adapter_value = po::value<>(&adapter_name)->default_value("0"); + options("adapter", adapter_value, "Which adapter to use."); } int main(app_execution &execution) override { @@ -45,16 +48,14 @@ public: sigaction(SIGINT, &sigIntHandler, NULL); try { - auto adapter_index = execution.vm["adapter"].as(); - - adapter = getAdapter(adapter_index); + adapter = bluetoothSystem.getAdapter(adapter_name); set seen_devices; - cout << "Scanning with adapter #" << adapter_index << ", mac=" << adapter->getMac().str() << endl; + cout << "Scanning with adapter " << adapter_name << ", mac=" << adapter->getMac().str() << endl; - adapter->runScan([&](BluetoothDevice &device) { - auto mac = device.getMac(); + adapter->runScan([&](auto device) { + auto mac = device->getMac(); cout << "Found: " << mac.str() << endl; -- cgit v1.2.3