aboutsummaryrefslogtreecommitdiff
path: root/ble
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-11-19 23:13:50 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2018-11-19 23:13:50 +0100
commite8aa2eadf309fbc0c0e1418c6bee482e505fa09b (patch)
treee93292292834b8d8959301cd8d02b27090e7e0ca /ble
parentd6f16958eaa966332b911eb9257b8524c2efd772 (diff)
downloadble-toys-e8aa2eadf309fbc0c0e1418c6bee482e505fa09b.tar.gz
ble-toys-e8aa2eadf309fbc0c0e1418c6bee482e505fa09b.tar.bz2
ble-toys-e8aa2eadf309fbc0c0e1418c6bee482e505fa09b.tar.xz
ble-toys-e8aa2eadf309fbc0c0e1418c6bee482e505fa09b.zip
ble-read-characteristic: working READ mode, starting on NOTIFY.
Diffstat (limited to 'ble')
-rw-r--r--ble/BluetoothImpl.h31
-rw-r--r--ble/LinuxBluetooth.cpp11
2 files changed, 13 insertions, 29 deletions
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<typename T, typename U>
-struct constify2;
-
-template<typename T, typename U>
-struct constify2<T *, U *> {
- typedef T *type;
-};
-
-template<typename T, typename U>
-struct constify2<T *, U const *> {
- typedef T const *type;
-};
-
-}
-
-template<typename A, typename B>
-class CollectionImpl : public Collection<A> {
-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<BluetoothGattDescriptor> 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 <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@@ -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<void(const shared_ptr<BluetoothDevice> &device)>) override;
- shared_ptr <BluetoothDevice> getDevice(Mac &mac) override;
+ shared_ptr<BluetoothDevice> 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;