aboutsummaryrefslogtreecommitdiff
path: root/apps/ble-inspect-device.h
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-07-19 21:39:28 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-07-19 21:49:03 +0200
commitae2d05eee4ffcec4c0611d907779ce8ef61d3a6e (patch)
tree6b86d64d03dfda4efc4a41e5814a229507289cb9 /apps/ble-inspect-device.h
parent0374af511d7efdb856af372f126e66e5a78841d7 (diff)
downloadble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.tar.gz
ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.tar.bz2
ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.tar.xz
ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.zip
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.
Diffstat (limited to 'apps/ble-inspect-device.h')
-rw-r--r--apps/ble-inspect-device.h74
1 files changed, 0 insertions, 74 deletions
diff --git a/apps/ble-inspect-device.h b/apps/ble-inspect-device.h
deleted file mode 100644
index ff19ba1..0000000
--- a/apps/ble-inspect-device.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <exception>
-#include <iostream>
-#include <vector>
-#include <boost/uuid/uuid_io.hpp>
-#include "ble/Bluetooth.h"
-#include "apps.h"
-
-namespace trygvis {
-namespace apps {
-
-using namespace std;
-using namespace trygvis::bluetooth;
-using namespace trygvis::apps;
-
-class ble_inspect_device : public app {
-public:
- ble_inspect_device() : app("ble-inspect-device") {
- }
-
- ~ble_inspect_device() = default;
-
- void add_options(po::options_description_easy_init &options) override {
- options("device", po::value<string>()->required(), "The MAC of the device to inspect");
- }
-
- void scan_callback(BluetoothDevice &device) {
- cout << "Inspecting device: " << device.getMac().str() << endl;
-
- auto gatt = device.connectGatt();
-
- gatt->discoverServices();
-
- vector<BluetoothGattService *> services = gatt->getServices();
- cout << "Device has " << services.size() << " services" << endl;
-
- for (auto &s : services) {
- const vector<BluetoothGattCharacteristic *> 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;
- }
- }
- }
-
- int main(app_execution &execution) override {
- string mac_str = execution.vm["device"].as<string>();
-
- BluetoothSystem bluetoothSystem;
-
- try {
- Mac mac = Mac::parseMac(mac_str);
-
- shared_ptr<BluetoothAdapter> adapter = getAdapter(0);
-
- BluetoothDevice &device = adapter->getDevice(mac);
-
- scan_callback(device);
-
- 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;
- }
- }
-};
-}
-}