diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -1,5 +1,7 @@ #include <exception> #include <iostream> +#include <vector> +#include <boost/uuid/uuid_io.hpp> #include "Bluetooth.h" using namespace std; @@ -15,12 +17,25 @@ void scan_callback(BluetoothDevice &device) { return; } - cout << "found device: " << device.mac().str() << endl; + cout << "Connecting to device: " << device.mac().str() << endl; device.connect(); device.discoverServices(); + vector<BluetoothGattService *> services = device.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; + } + } + device.disconnect(); } @@ -32,18 +47,18 @@ int main(int argc, char *argv[]) { int e; // try { - Mac mac = Mac::parseMac(argv[1]); - targetMac = &mac; + Mac mac = Mac::parseMac(argv[1]); + targetMac = &mac; - BluetoothAdapter &adapter = getAdapter(0); + BluetoothAdapter &adapter = getAdapter(0); - BluetoothDevice &device = adapter.getDevice(mac); + BluetoothDevice &device = adapter.getDevice(mac); - scan_callback(device); + scan_callback(device); // adapter->runScan(scan_callback); - e = EXIT_SUCCESS; + e = EXIT_SUCCESS; // } catch (std::runtime_error ex) { // W << "std::runtime_error: " << ex.what(); // e = EXIT_FAILURE; |