aboutsummaryrefslogtreecommitdiff
path: root/include/ble/Bluetooth.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/ble/Bluetooth.h')
-rw-r--r--include/ble/Bluetooth.h38
1 files changed, 32 insertions, 6 deletions
diff --git a/include/ble/Bluetooth.h b/include/ble/Bluetooth.h
index d95d843..f97f3b8 100644
--- a/include/ble/Bluetooth.h
+++ b/include/ble/Bluetooth.h
@@ -1,7 +1,7 @@
#ifndef BLUETOOTH_H
#define BLUETOOTH_H
-#include <experimental/optional>
+#include <optional>
#include <iosfwd>
#include <iostream>
#include <stdexcept>
@@ -17,23 +17,30 @@
namespace trygvis {
namespace bluetooth {
-using namespace std;
+using std::shared_ptr;
+using std::string;
+using std::vector;
+using std::map;
+using std::runtime_error;
+
template<typename T>
-using o = std::experimental::optional<T>;
+using o = std::optional<T>;
class BluetoothAdapter;
class BluetoothDevice;
class BluetoothGatt;
+typedef shared_ptr<BluetoothGatt> BluetoothGattPtr;
class BluetoothGattService;
+typedef shared_ptr<BluetoothGattService> BluetoothGattServicePtr;
class BluetoothGattCharacteristic;
-
-typedef shared_ptr<BluetoothGatt> BluetoothGattPtr;
typedef shared_ptr<BluetoothGattCharacteristic> BluetoothGattCharacteristicPtr;
-typedef shared_ptr<BluetoothGattService> BluetoothGattServicePtr;
+
+class BluetoothGattDescriptor;
+typedef shared_ptr<BluetoothGattDescriptor> BluetoothGattDescriptorPtr;
class Mac {
public:
@@ -76,6 +83,17 @@ public:
Iterator<T> end();
};
+class BluetoothGattDescriptor {
+public:
+ static const uint8_t DISABLE_NOTIFICATION_VALUE[];
+ static const uint8_t ENABLE_INDICATION_VALUE[];
+ static const uint8_t ENABLE_NOTIFICATION_VALUE[];
+
+ virtual ~BluetoothGattDescriptor() = default;
+
+ virtual BluetoothGattCharacteristicPtr getCharacteristic() const = 0;
+};
+
class BluetoothGattCharacteristic {
public:
virtual ~BluetoothGattCharacteristic() = default;
@@ -89,6 +107,12 @@ public:
virtual uint8_t getProperties() const = 0;
virtual uint16_t getValueHandle() const = 0;
+
+ virtual shared_ptr<BluetoothGattDescriptor> getDescriptor(Uuid uuid) const = 0;
+
+ virtual shared_ptr<BluetoothGattDescriptor> getDescriptor(ShortUuid uuid) const {
+ return getDescriptor(uuid.toLong());
+ };
};
class BluetoothGattService {
@@ -131,6 +155,8 @@ public:
virtual ByteBuffer readValue(const BluetoothGattCharacteristicPtr &c, ByteBuffer& response) = 0;
+ virtual void setCharacteristicNotification(const BluetoothGattDescriptorPtr &c, bool enable) = 0;
+
virtual void discoverServices() = 0;
virtual vector<shared_ptr<BluetoothGattService>> getServices() const = 0;