From e8aa2eadf309fbc0c0e1418c6bee482e505fa09b Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 19 Nov 2018 23:13:50 +0100 Subject: ble-read-characteristic: working READ mode, starting on NOTIFY. --- ble/BluetoothImpl.h | 31 ++++--------------------------- ble/LinuxBluetooth.cpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 29 deletions(-) (limited to 'ble') diff --git a/ble/BluetoothImpl.h b/ble/BluetoothImpl.h index 802c844..975a011 100644 --- a/ble/BluetoothImpl.h +++ b/ble/BluetoothImpl.h @@ -40,33 +40,6 @@ protected: // Shared classes -namespace detail { - -template -struct constify2; - -template -struct constify2 { - typedef T *type; -}; - -template -struct constify2 { - typedef T const *type; -}; - -} - -template -class CollectionImpl : public Collection { -public: - explicit CollectionImpl(B &b) : b(b) { - } - -private: - B &b; -}; - class DefaultBluetoothGattCharacteristic : protected LogSetup, public BluetoothGattCharacteristic { public: DefaultBluetoothGattCharacteristic(const BluetoothGattServicePtr &service, uint16_t handle, Uuid uuid, @@ -97,6 +70,10 @@ public: return valueHandle; } + shared_ptr getDescriptor(Uuid uuid) const override { + return {}; + } + protected: BluetoothGattServicePtr service; uint16_t handle; diff --git a/ble/LinuxBluetooth.cpp b/ble/LinuxBluetooth.cpp index d3fe80b..444e3a2 100644 --- a/ble/LinuxBluetooth.cpp +++ b/ble/LinuxBluetooth.cpp @@ -1,4 +1,5 @@ #include "BluetoothImpl.h" +#include "ble/misc.h" #include #include @@ -22,8 +23,9 @@ namespace trygvis { namespace bluetooth { namespace linux { -using namespace uuids; +//using namespace uuids; using namespace std::chrono_literals; +using namespace std; using std::to_string; class LinuxBluetoothGatt; @@ -55,7 +57,7 @@ public: void runScan(std::function &device)>) override; - shared_ptr getDevice(Mac &mac) override; + shared_ptr getDevice(Mac &mac) override; private: void startScan() override; @@ -105,6 +107,8 @@ public: ByteBuffer readValue(const BluetoothGattCharacteristicPtr &c, ByteBuffer& response) override; + void setCharacteristicNotification(const BluetoothGattDescriptorPtr &c, bool enable) override; + private: void connect(); @@ -302,6 +306,9 @@ ByteBuffer LinuxBluetoothGatt::readValue(const BluetoothGattCharacteristicPtr &c return view; } +void LinuxBluetoothGatt::setCharacteristicNotification(const BluetoothGattDescriptorPtr &c, bool enable) { +} + void LinuxBluetoothGatt::discoverServices() { uint16_t startHandle = 0x0001; -- cgit v1.2.3