diff options
Diffstat (limited to 'include/ble/Bluetooth.h')
-rw-r--r-- | include/ble/Bluetooth.h | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/include/ble/Bluetooth.h b/include/ble/Bluetooth.h index f97f3b8..b0228e5 100644 --- a/include/ble/Bluetooth.h +++ b/include/ble/Bluetooth.h @@ -27,19 +27,15 @@ template<typename 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<BluetoothGattCharacteristic> BluetoothGattCharacteristicPtr; - class BluetoothGattDescriptor; + +typedef shared_ptr<BluetoothGatt> BluetoothGattPtr; +typedef shared_ptr<BluetoothGattService> BluetoothGattServicePtr; +typedef shared_ptr<BluetoothGattCharacteristic> BluetoothGattCharacteristicPtr; typedef shared_ptr<BluetoothGattDescriptor> BluetoothGattDescriptorPtr; class Mac { @@ -69,29 +65,29 @@ private: uint8_t bytes[6]; }; -template<typename T> -class Iterator { -public: -private: -}; - -template<typename T> -class Collection { -public: - Iterator<T> begin(); - - 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[]; + static const uint8_t DISABLE_NOTIFICATION_VALUE[2]; + static const uint8_t ENABLE_INDICATION_VALUE[2]; + static const uint8_t ENABLE_NOTIFICATION_VALUE[2]; virtual ~BluetoothGattDescriptor() = default; virtual BluetoothGattCharacteristicPtr getCharacteristic() const = 0; + + virtual uint16_t getHandle() const = 0; + + virtual const Uuid getUuid() const = 0; + + template<size_t N> + void setValue(const uint8_t (&buffer)[N]) { + auto tmp = ByteBuffer::wrap(buffer, N); + setValue(&tmp); + } + + virtual void setValue(const ByteBuffer &buffer) = 0; + + virtual ByteBuffer getValue() const = 0; }; class BluetoothGattCharacteristic { @@ -104,7 +100,7 @@ public: virtual const Uuid getUuid() const = 0; - virtual uint8_t getProperties() const = 0; + virtual CharacteristicProperties getProperties() const = 0; virtual uint16_t getValueHandle() const = 0; @@ -153,7 +149,9 @@ public: virtual void writeValue(const BluetoothGattCharacteristicPtr &c, const ByteBuffer &bytes) = 0; - virtual ByteBuffer readValue(const BluetoothGattCharacteristicPtr &c, ByteBuffer& response) = 0; + virtual void write(const BluetoothGattDescriptorPtr &d) = 0; + + virtual ByteBuffer readValue(const BluetoothGattCharacteristicPtr &c, ByteBuffer &response) = 0; virtual void setCharacteristicNotification(const BluetoothGattDescriptorPtr &c, bool enable) = 0; |