diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-11-19 23:13:50 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-11-19 23:13:50 +0100 |
commit | e8aa2eadf309fbc0c0e1418c6bee482e505fa09b (patch) | |
tree | e93292292834b8d8959301cd8d02b27090e7e0ca /include/ble | |
parent | d6f16958eaa966332b911eb9257b8524c2efd772 (diff) | |
download | ble-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 'include/ble')
-rw-r--r-- | include/ble/Bluetooth.h | 38 | ||||
-rw-r--r-- | include/ble/misc.h | 6 |
2 files changed, 36 insertions, 8 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; diff --git a/include/ble/misc.h b/include/ble/misc.h index 4ba3309..2508d8e 100644 --- a/include/ble/misc.h +++ b/include/ble/misc.h @@ -1,6 +1,6 @@ #pragma once -#include <experimental/optional> +#include <optional> #include <cstring> #include <cctype> @@ -10,7 +10,7 @@ namespace trygvis { namespace bluetooth { template<typename T> -using o = std::experimental::optional<T>; +using o = std::optional<T>; class BluetoothAdapter; class BluetoothDevice; @@ -86,6 +86,8 @@ const ShortUuid PRIMARY_SERVICE{0x2800}; const ShortUuid SECONDARY_SERVICE{0x2801}; const ShortUuid CHARACTERISTIC{0x2803}; +const ShortUuid CLIENT_CHARACTERISTIC_CONFIG{0x2902}; + const ShortUuid TemperatureMeasurement{0x2A1C}; } |