/*
* Author: Sven Gothel
* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.1 Characteristic Declaration Attribute Value
*
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.6.1 Discover All Characteristics of a Service
*
* Here the handle is a service's characteristics-declaration
* and the value the Characteristics Property, Characteristics Value Handle _and_ Characteristics UUID.
*
* Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle).
*
* Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle).
*
* Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle).
*
* Convenience delegation call to GATTHandler via DBTDevice
*
* If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
*
* Implementation masks this Characteristic properties PropertyBitVal::Notify and PropertyBitVal::Indicate
* with the respective user request parameters, hence removes unsupported requests.
* Returns false if there is no GATTDescriptor of type ClientCharacteristicConfiguration,
* or if the operation has failed.
*
* Returns true if the given listener is not element of the list and has been newly added,
* otherwise false.
*
* Convenience delegation call to GATTHandler via DBTDevice
*
* If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
*
* To restrict the listener to listen only to this GATTCharacteristic instance,
* user has to implement GATTCharacteristicListener::match(GATTCharacteristicRef) accordingly.
*
* Returns true if the given listener is an element of the list and has been removed,
* otherwise false.
*
* Convenience delegation call to GATTHandler via DBTDevice
*
* If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
*
* Returns true if the given listener is an element of the list and has been removed,
* otherwise false.
*
* Convenience delegation call to GATTHandler via DBTDevice
*
* If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
*
* Returns the number of removed event listener.
*
* Convenience delegation call to GATTHandler via DBTDevice
*
* If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
*
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.8.3 Read Long Characteristic Value
*
* If expectedLength = 0, then only one ATT_READ_REQ/RSP will be used.
*
* If expectedLength < 0, then long values using multiple ATT_READ_BLOB_REQ/RSP will be used until
* the response returns zero. This is the default parameter.
*
* If expectedLength > 0, then long values using multiple ATT_READ_BLOB_REQ/RSP will be used
* if required until the response returns zero.
*
* Convenience delegation call to GATTHandler via DBTDevice
*
*
* org.bluez.GattCharacteristic1 :: array{string} Flags [read-only]
*
*/
static std::string getPropertyString(const PropertyBitVal prop);
static std::string getPropertiesString(const PropertyBitVal properties);
static std::vector
* If the resulting combination for both requests is false, method returns false.
*
* For this purpose, use may derive from SpecificGATTCharacteristicListener,
* which provides these simple matching filter facilities.
*
* Convenience delegation call to GATTHandler via DBTDevice *
*
* If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown. * */ bool writeValue(const TROOctets & value); /** * BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.1 Write Characteristic Value Without Response ** Convenience delegation call to GATTHandler via DBTDevice *
*
* If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown. * */ bool writeValueNoResp(const TROOctets & value); }; typedef std::shared_ptr
* A listener instance may be attached to a {@link BluetoothGattCharacteristic} via
* {@link GATTCharacteristic::addCharacteristicListener(std::shared_ptr
* A listener instance may be attached to a {@link GATTHandler} via
* {@link GATTHandler::addCharacteristicListener(std::shared_ptr
* The listener receiver maintains a unique set of listener instances without duplicates. *
*/ class GATTCharacteristicListener { public: /** * Custom filter for all event methods, * which will not be called if this method returns false. ** User may override this method to test whether the methods shall be called * for the given GATTCharacteristic. *
** Defaults to true; *
*/ virtual bool match(const GATTCharacteristic & characteristic) { (void)characteristic; return true; } virtual void notificationReceived(GATTCharacteristicRef charDecl, std::shared_ptr* Specializations may override. *
*/ virtual bool operator==(const GATTCharacteristicListener& rhs) const { return this == &rhs; } bool operator!=(const GATTCharacteristicListener& rhs) const { return !(*this == rhs); } }; class SpecificGATTCharacteristicListener : public GATTCharacteristicListener{ private: const GATTCharacteristic * characteristicMatch; public: /** * Passing the specific GATTCharacteristic to filter out non matching events. */ SpecificGATTCharacteristicListener(const GATTCharacteristic * characteristicMatch) : characteristicMatch(characteristicMatch) { } bool match(const GATTCharacteristic & characteristic) override { if( nullptr == characteristicMatch ) { return true; } return *characteristicMatch == characteristic; } }; } // namespace direct_bt #endif /* GATT_CHARACTERISTIC_HPP_ */