Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
BTGattChar.hpp
Go to the documentation of this file.
1 /*
2  * Author: Sven Gothel <sgothel@jausoft.com>
3  * Copyright (c) 2020 Gothel Software e.K.
4  * Copyright (c) 2020 ZAFENA AB
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 #ifndef BT_GATT_CHARACTERISTIC_HPP_
27 #define BT_GATT_CHARACTERISTIC_HPP_
28 
29 #include <cstring>
30 #include <string>
31 #include <memory>
32 #include <cstdint>
33 
34 #include <mutex>
35 #include <atomic>
36 
37 #include <jau/java_uplink.hpp>
38 
39 #include "UUID.hpp"
40 #include "BTTypes0.hpp"
41 #include "OctetTypes.hpp"
42 #include "ATTPDUTypes.hpp"
43 
44 #include "BTTypes1.hpp"
45 
46 #include "BTGattDesc.hpp"
47 
48 
49 /**
50  * - - - - - - - - - - - - - - -
51  *
52  * Module BTGattChar:
53  *
54  * - BT Core Spec v5.2: Vol 3, Part G Generic Attribute Protocol (GATT)
55  * - BT Core Spec v5.2: Vol 3, Part G GATT: 2.6 GATT Profile Hierarchy
56  */
57 namespace direct_bt {
58 
59  class BTGattHandler; // forward
60  class BTGattService; // forward
61  typedef std::shared_ptr<BTGattService> BTGattServiceRef;
62 
63  /**
64  * <p>
65  * BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.1 Characteristic Declaration Attribute Value
66  * </p>
67  * handle -> CDAV value
68  * <p>
69  * BT Core Spec v5.2: Vol 3, Part G GATT: 4.6.1 Discover All Characteristics of a Service
70  *
71  * Here the handle is a service's characteristics-declaration
72  * and the value the Characteristics Property, Characteristics Value Handle _and_ Characteristics UUID.
73  * </p>
74  */
75  class BTGattChar : public BTObject {
76  private:
77  /** Characteristics's service weak back-reference */
78  std::weak_ptr<BTGattService> wbr_service;
79  bool enabledNotifyState = false;
80  bool enabledIndicateState = false;
81 
82  std::string toShortString() const noexcept;
83 
84  public:
85  /** BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.1.1 Characteristic Properties */
86  enum PropertyBitVal : uint8_t {
87  NONE = 0,
88  Broadcast = (1 << 0),
89  Read = (1 << 1),
90  WriteNoAck = (1 << 2),
91  WriteWithAck = (1 << 3),
92  Notify = (1 << 4),
93  Indicate = (1 << 5),
94  AuthSignedWrite = (1 << 6),
95  ExtProps = (1 << 7)
96  };
97  /**
98  * Returns string values as defined in <https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt>
99  * <pre>
100  * org.bluez.GattCharacteristic1 :: array{string} Flags [read-only]
101  * </pre>
102  */
103  static std::string getPropertiesString(const PropertyBitVal properties) noexcept;
105 
106  /**
107  * {@link BTGattChar} event listener for notification and indication events.
108  * <p>
109  * This listener instance is attached to a BTGattChar via
110  * {@link BTGattChar::addCharListener(std::shared_ptr<BTGattChar::Listener>)} or
111  * {@link BTGattChar::addCharListener(std::shared_ptr<BTGattChar::Listener>, bool[])}
112  * to listen to events associated with the BTGattChar instance.
113  * </p>
114  * <p>
115  * The listener manager maintains a unique set of listener instances without duplicates.
116  * </p>
117  * <p>
118  * Implementation will utilize a BTGattCharListener instance for the listener manager,
119  * delegating matching BTGattChar events to this instance.
120  * </p>
121  */
122  class Listener {
123  public:
124  /**
125  * Called from native BLE stack, initiated by a received notification associated
126  * with the given {@link BTGattChar}.
127  * @param charDecl {@link BTGattChar} related to this notification
128  * @param charValue the notification value
129  * @param timestamp the indication monotonic timestamp, see getCurrentMilliseconds()
130  */
131  virtual void notificationReceived(BTGattCharRef charDecl,
132  const TROOctets& charValue, const uint64_t timestamp) = 0;
133 
134  /**
135  * Called from native BLE stack, initiated by a received indication associated
136  * with the given {@link BTGattChar}.
137  * @param charDecl {@link BTGattChar} related to this indication
138  * @param charValue the indication value
139  * @param timestamp the indication monotonic timestamp, see {@link BluetoothUtils#getCurrentMilliseconds()}
140  * @param confirmationSent if true, the native stack has sent the confirmation, otherwise user is required to do so.
141  */
142  virtual void indicationReceived(BTGattCharRef charDecl,
143  const TROOctets& charValue, const uint64_t timestamp,
144  const bool confirmationSent) = 0;
145 
146  virtual ~Listener() noexcept {}
147 
148  /**
149  * Default comparison operator, merely testing for same memory reference.
150  * <p>
151  * Specializations may override.
152  * </p>
153  */
154  virtual bool operator==(const Listener& rhs) const noexcept
155  { return this == &rhs; }
156 
157  bool operator!=(const Listener& rhs) const noexcept
158  { return !(*this == rhs); }
159  };
160 
161  /**
162  * Characteristics's Service Handle - key to service's handle range, retrieved from Characteristics data.
163  * <p>
164  * Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle).
165  * </p>
166  */
167  const uint16_t service_handle;
168 
169  /**
170  * Characteristic Handle of this instance.
171  * <p>
172  * Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle).
173  * </p>
174  */
175  const uint16_t handle;
176 
177  /* Characteristics Property */
179 
180  /**
181  * Characteristics Value Handle.
182  * <p>
183  * Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle).
184  * </p>
185  */
186  const uint16_t value_handle;
187 
188  /* Characteristics Value Type UUID */
189  std::unique_ptr<const uuid_t> value_type;
190 
191  /** List of Characteristic Descriptions as shared reference */
193 
194  /* Optional Client Characteristic Configuration index within descriptorList */
196 
197  BTGattChar(const BTGattServiceRef & service_, const uint16_t service_handle_, const uint16_t handle_,
198  const PropertyBitVal properties_, const uint16_t value_handle_, std::unique_ptr<const uuid_t> && value_type_) noexcept
199  : wbr_service(service_), service_handle(service_handle_), handle(handle_),
200  properties(properties_), value_handle(value_handle_), value_type(std::move(value_type_)) {}
201 
202  std::string get_java_class() const noexcept override {
203  return java_class();
204  }
205  static std::string java_class() noexcept {
206  return std::string(JAVA_DBT_PACKAGE "DBTGattChar");
207  }
208 
209  std::shared_ptr<BTGattService> getServiceUnchecked() const noexcept { return wbr_service.lock(); }
210  std::shared_ptr<BTGattService> getServiceChecked() const;
211  std::shared_ptr<BTGattHandler> getGattHandlerUnchecked() const noexcept;
212  std::shared_ptr<BTGattHandler> getGattHandlerChecked() const;
213  std::shared_ptr<BTDevice> getDeviceUnchecked() const noexcept;
214  std::shared_ptr<BTDevice> getDeviceChecked() const;
215 
216  bool hasProperties(const PropertyBitVal v) const noexcept { return v == ( properties & v ); }
217 
218  std::string toString() const noexcept override;
219 
220  void clearDescriptors() noexcept {
223  }
224 
226  if( 0 > clientCharConfigIndex ) {
227  return nullptr;
228  }
229  return descriptorList.at(static_cast<size_t>(clientCharConfigIndex)); // abort if out of bounds
230  }
231 
232  /**
233  * BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration
234  * <p>
235  * Method enables notification and/or indication for this characteristic at BLE level.
236  * </p>
237  * <p>
238  * Implementation masks this Characteristic properties PropertyBitVal::Notify and PropertyBitVal::Indicate
239  * with the respective user request parameters, hence removes unsupported requests.
240  * </p>
241  * <p>
242  * Notification and/or indication configuration is only performed per characteristic if changed.
243  * </p>
244  * <p>
245  * It is recommended to utilize notification over indication, as its link-layer handshake
246  * and higher potential bandwidth may deliver material higher performance.
247  * </p>
248  * @param enableNotification
249  * @param enableIndication
250  * @param enabledState array of size 2, holding the resulting enabled state for notification and indication.
251  * @return false if this characteristic has no PropertyBitVal::Notify or PropertyBitVal::Indication present,
252  * or there is no BTGattDesc of type ClientCharacteristicConfiguration, or if the operation has failed.
253  * Otherwise returns true.
254  * @throws IllegalStateException if notification or indication is set to be enabled
255  * and the {@link BTDevice's}'s {@link BTGattHandler} is null, i.e. not connected
256  */
257  bool configNotificationIndication(const bool enableNotification, const bool enableIndication, bool enabledState[2]);
258 
259  /**
260  * BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration
261  * <p>
262  * Method will attempt to enable notification on the BLE level, if available,
263  * otherwise indication if available.
264  * </p>
265  * <p>
266  * Notification and/or indication configuration is only performed per characteristic if changed.
267  * </p>
268  * <p>
269  * It is recommended to utilize notification over indication, as its link-layer handshake
270  * and higher potential bandwidth may deliver material higher performance.
271  * </p>
272  * @param enabledState array of size 2, holding the resulting enabled state for notification and indication.
273  * @return false if this characteristic has no PropertyBitVal::Notify or PropertyBitVal::Indication present,
274  * or there is no BTGattDesc of type ClientCharacteristicConfiguration, or if the operation has failed.
275  * Otherwise returns true.
276  * @throws IllegalStateException if notification or indication is set to be enabled
277  * and the {@link BTDevice's}'s {@link BTGattHandler} is null, i.e. not connected
278  */
279  bool enableNotificationOrIndication(bool enabledState[2]);
280 
281  /**
282  * Add the given BTGattChar::Listener to the listener list if not already present.
283  * <p>
284  * Occurring notifications and indications for this characteristic,
285  * if enabled via configNotificationIndication(bool, bool, bool[]) or enableNotificationOrIndication(bool[]),
286  * will call the respective BTGattChar::Listener callback method.
287  * </p>
288  * <p>
289  * Returns true if the given listener is not element of the list and has been newly added,
290  * otherwise false.
291  * </p>
292  * <p>
293  * Implementation wraps given BTGattChar::Listener into an AssociatedBTGattCharListener
294  * to restrict the listener to listen only to this BTGattChar instance.
295  * </p>
296  * <p>
297  * Convenience delegation call to BTGattHandler via BTDevice
298  * </p>
299  * @throws IllegalStateException if the {@link BTDevice's}'s {@link BTGattHandler} is null, i.e. not connected
300  * @see BTGattChar::enableNotificationOrIndication()
301  * @see BTGattChar::configNotificationIndication()
302  * @see BTGattChar::addCharListener()
303  * @see BTGattChar::removeCharListener()
304  * @see BTGattChar::removeAllAssociatedCharListener()
305  */
306  bool addCharListener(std::shared_ptr<Listener> l);
307 
308  /**
309  * Add the given BTGattChar::Listener to the listener list if not already present
310  * and if enabling the notification <i>or</i> indication for this characteristic at BLE level was successful.<br>
311  * Notification and/or indication configuration is only performed per characteristic if changed.
312  * <p>
313  * Implementation will enable notification if available,
314  * otherwise indication will be enabled if available. <br>
315  * Implementation uses enableNotificationOrIndication(bool[]) to enable either.
316  * </p>
317  * <p>
318  * Occurring notifications and indications for this characteristic
319  * will call the respective BTGattChar::Listener callback method.
320  * </p>
321  * <p>
322  * Returns true if enabling the notification and/or indication was successful
323  * and if the given listener is not element of the list and has been newly added,
324  * otherwise false.
325  * </p>
326  * <p>
327  * Implementation wraps given BTGattChar::Listener into an AssociatedBTGattCharListener
328  * to restrict the listener to listen only to this BTGattChar instance.
329  * </p>
330  * @param enabledState array of size 2, holding the resulting enabled state for notification and indication
331  * using enableNotificationOrIndication(bool[])
332  * @throws IllegalStateException if the {@link BTDevice's}'s {@link BTGattHandler} is null, i.e. not connected
333  * @see BTGattChar::enableNotificationOrIndication()
334  * @see BTGattChar::configNotificationIndication()
335  * @see BTGattChar::addCharListener()
336  * @see BTGattChar::removeCharListener()
337  * @see BTGattChar::removeAllAssociatedCharListener()
338  */
339  bool addCharListener(std::shared_ptr<Listener> l, bool enabledState[2]);
340 
341  /**
342  * Disables the notification and/or indication for this characteristic at BLE level
343  * if `disableIndicationNotification == true`
344  * and removes all associated BTGattChar::Listener and {@link BTGattCharListener} from the listener list.
345  * <p>
346  * Returns the number of removed event listener.
347  * </p>
348  * <p>
349  * If the BTDevice's BTGattHandler is null, i.e. not connected, `zero` is being returned.
350  * </p>
351  * @param disableIndicationNotification if true, disables the notification and/or indication for this characteristic
352  * using {@link #configNotificationIndication(bool, bool, bool[])
353  * @return
354  * @see BTGattChar::enableNotificationOrIndication()
355  * @see BTGattChar::configNotificationIndication()
356  * @see BTGattChar::addCharListener()
357  * @see BTGattChar::removeCharListener()
358  * @see BTGattChar::removeAllAssociatedCharListener()
359  */
360  int removeAllAssociatedCharListener(bool disableIndicationNotification);
361 
362  /**
363  * BT Core Spec v5.2: Vol 3, Part G GATT: 4.8.1 Read Characteristic Value
364  * <p>
365  * BT Core Spec v5.2: Vol 3, Part G GATT: 4.8.3 Read Long Characteristic Value
366  * </p>
367  * <p>
368  * If expectedLength = 0, then only one ATT_READ_REQ/RSP will be used.
369  * </p>
370  * <p>
371  * If expectedLength < 0, then long values using multiple ATT_READ_BLOB_REQ/RSP will be used until
372  * the response returns zero. This is the default parameter.
373  * </p>
374  * <p>
375  * If expectedLength > 0, then long values using multiple ATT_READ_BLOB_REQ/RSP will be used
376  * if required until the response returns zero.
377  * </p>
378  * <p>
379  * Convenience delegation call to BTGattHandler via BTDevice
380  * <p>
381  * </p>
382  * If the BTDevice's BTGattHandler is null, i.e. not connected, an IllegalStateException is thrown.
383  * </p>
384  */
385  bool readValue(POctets & res, int expectedLength=-1);
386 
387  /**
388  * BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value
389  * <p>
390  * Convenience delegation call to BTGattHandler via BTDevice
391  * <p>
392  * </p>
393  * If the BTDevice's BTGattHandler is null, i.e. not connected, an IllegalStateException is thrown.
394  * </p>
395  */
396  bool writeValue(const TROOctets & value);
397 
398  /**
399  * BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.1 Write Characteristic Value Without Response
400  * <p>
401  * Convenience delegation call to BTGattHandler via BTDevice
402  * <p>
403  * </p>
404  * If the BTDevice's BTGattHandler is null, i.e. not connected, an IllegalStateException is thrown.
405  * </p>
406  */
407  bool writeValueNoResp(const TROOctets & value);
408  };
409  typedef std::shared_ptr<BTGattChar> BTGattCharRef;
410 
411  inline bool operator==(const BTGattChar& lhs, const BTGattChar& rhs) noexcept
412  { return lhs.handle == rhs.handle; /** unique attribute handles */ }
413 
414  inline bool operator!=(const BTGattChar& lhs, const BTGattChar& rhs) noexcept
415  { return !(lhs == rhs); }
416 
417  /**
418  * {@link BTGattChar} event listener for notification and indication events.
419  * <p>
420  * A listener instance may be attached to a BTGattChar instance via
421  * {@link BTGattChar::addCharListener(std::shared_ptr<BTGattChar::Listener>)} to listen to its events.
422  * </p>
423  * <p>
424  * A listener instance may be attached to a BTGattHandler via
425  * {@link BTGattHandler::addCharListener(std::shared_ptr<BTGattCharListener>)}
426  * to listen to all events of the device or the matching filtered events.
427  * </p>
428  * <p>
429  * User may utilize {@link AssociatedBTGattCharListener} to listen to only one {@link BTGattChar}.
430  * </p>
431  * <p>
432  * The listener manager maintains a unique set of listener instances without duplicates.
433  * </p>
434  */
436  public:
437  /**
438  * Custom filter for all event methods,
439  * which will not be called if this method returns false.
440  * <p>
441  * User may override this method to test whether the methods shall be called
442  * for the given BTGattChar.
443  * </p>
444  * <p>
445  * Defaults to true;
446  * </p>
447  */
448  virtual bool match(const BTGattChar & characteristic) noexcept {
449  (void)characteristic;
450  return true;
451  }
452 
453  /**
454  * Called from native BLE stack, initiated by a received notification associated
455  * with the given {@link BTGattChar}.
456  * @param charDecl {@link BTGattChar} related to this notification
457  * @param charValue the notification value
458  * @param timestamp the indication monotonic timestamp, see getCurrentMilliseconds()
459  */
460  virtual void notificationReceived(BTGattCharRef charDecl,
461  const TROOctets& charValue, const uint64_t timestamp) = 0;
462 
463  /**
464  * Called from native BLE stack, initiated by a received indication associated
465  * with the given {@link BTGattChar}.
466  * @param charDecl {@link BTGattChar} related to this indication
467  * @param charValue the indication value
468  * @param timestamp the indication monotonic timestamp, see {@link BluetoothUtils#getCurrentMilliseconds()}
469  * @param confirmationSent if true, the native stack has sent the confirmation, otherwise user is required to do so.
470  */
471  virtual void indicationReceived(BTGattCharRef charDecl,
472  const TROOctets& charValue, const uint64_t timestamp,
473  const bool confirmationSent) = 0;
474 
475  virtual ~BTGattCharListener() noexcept {}
476 
477  /**
478  * Default comparison operator, merely testing for same memory reference.
479  * <p>
480  * Specializations may override.
481  * </p>
482  */
483  virtual bool operator==(const BTGattCharListener& rhs) const noexcept
484  { return this == &rhs; }
485 
486  bool operator!=(const BTGattCharListener& rhs) const noexcept
487  { return !(*this == rhs); }
488  };
489 
491  private:
492  const BTGattChar * associatedChar;
493 
494  public:
495  /**
496  * Passing the associated BTGattChar to filter out non matching events.
497  */
498  AssociatedBTGattCharListener(const BTGattChar * characteristicMatch) noexcept
499  : associatedChar(characteristicMatch) { }
500 
501  bool match(const BTGattChar & characteristic) noexcept override {
502  if( nullptr == associatedChar ) {
503  return true;
504  }
505  return *associatedChar == characteristic;
506  }
507  };
508 
509 } // namespace direct_bt
510 
511 #endif /* BT_GATT_CHARACTERISTIC_HPP_ */
direct_bt::BTGattCharListener::indicationReceived
virtual void indicationReceived(BTGattCharRef charDecl, const TROOctets &charValue, const uint64_t timestamp, const bool confirmationSent)=0
Called from native BLE stack, initiated by a received indication associated with the given BTGattChar...
direct_bt::BTGattChar::getPropertiesString
static std::string getPropertiesString(const PropertyBitVal properties) noexcept
Returns string values as defined in https://git.kernel.org/pub/scm/bluetooth/bluez....
Definition: BTGattChar.cpp:76
jau::darray::at
const_reference at(size_type i) const
Like std::vector::at(size_type), immutable reference.
Definition: darray.hpp:719
direct_bt::BTGattCharListener::operator==
virtual bool operator==(const BTGattCharListener &rhs) const noexcept
Default comparison operator, merely testing for same memory reference.
Definition: BTGattChar.hpp:483
direct_bt::AssociatedBTGattCharListener::AssociatedBTGattCharListener
AssociatedBTGattCharListener(const BTGattChar *characteristicMatch) noexcept
Passing the associated BTGattChar to filter out non matching events.
Definition: BTGattChar.hpp:498
direct_bt::BTGattChar::hasProperties
bool hasProperties(const PropertyBitVal v) const noexcept
Definition: BTGattChar.hpp:216
direct_bt::BTGattChar::Indicate
@ Indicate
Definition: BTGattChar.hpp:93
direct_bt::BTGattCharListener::notificationReceived
virtual void notificationReceived(BTGattCharRef charDecl, const TROOctets &charValue, const uint64_t timestamp)=0
Called from native BLE stack, initiated by a received notification associated with the given BTGattCh...
direct_bt::BTGattCharListener::match
virtual bool match(const BTGattChar &characteristic) noexcept
Custom filter for all event methods, which will not be called if this method returns false.
Definition: BTGattChar.hpp:448
direct_bt::BTGattChar::getServiceUnchecked
std::shared_ptr< BTGattService > getServiceUnchecked() const noexcept
Definition: BTGattChar.hpp:209
direct_bt::BTGattChar::Read
@ Read
Definition: BTGattChar.hpp:89
direct_bt::BTGattChar::readValue
bool readValue(POctets &res, int expectedLength=-1)
BT Core Spec v5.2: Vol 3, Part G GATT: 4.8.1 Read Characteristic Value.
Definition: BTGattChar.cpp:304
direct_bt::BTGattCharListener::operator!=
bool operator!=(const BTGattCharListener &rhs) const noexcept
Definition: BTGattChar.hpp:486
direct_bt::BTGattChar::handle
const uint16_t handle
Characteristic Handle of this instance.
Definition: BTGattChar.hpp:175
direct_bt::BTGattChar::NONE
@ NONE
Definition: BTGattChar.hpp:87
direct_bt
Definition: ATTPDUTypes.hpp:171
direct_bt::BTGattChar
Definition: BTGattChar.hpp:75
direct_bt::operator==
bool operator==(const EUI48Sub &lhs, const EUI48Sub &rhs) noexcept
Definition: BTAddress.hpp:265
BTTypes1.hpp
direct_bt::BTGattServiceRef
std::shared_ptr< BTGattService > BTGattServiceRef
Definition: BTGattChar.hpp:60
direct_bt::BTGattChar::java_class
static std::string java_class() noexcept
Definition: BTGattChar.hpp:205
OctetTypes.hpp
direct_bt::BTGattChar::getGattHandlerChecked
std::shared_ptr< BTGattHandler > getGattHandlerChecked() const
Definition: BTGattChar.cpp:170
direct_bt::BTGattChar::addCharListener
bool addCharListener(std::shared_ptr< Listener > l)
Add the given BTGattChar::Listener to the listener list if not already present.
Definition: BTGattChar.cpp:285
direct_bt::BTGattChar::getDeviceChecked
std::shared_ptr< BTDevice > getDeviceChecked() const
Definition: BTGattChar.cpp:182
direct_bt::BTGattChar::removeAllAssociatedCharListener
int removeAllAssociatedCharListener(bool disableIndicationNotification)
Disables the notification and/or indication for this characteristic at BLE level if disableIndication...
Definition: BTGattChar.cpp:296
direct_bt::BTGattChar::service_handle
const uint16_t service_handle
Characteristics's Service Handle - key to service's handle range, retrieved from Characteristics data...
Definition: BTGattChar.hpp:167
direct_bt::BTGattChar::Broadcast
@ Broadcast
Definition: BTGattChar.hpp:88
direct_bt::BTGattChar::getGattHandlerUnchecked
std::shared_ptr< BTGattHandler > getGattHandlerUnchecked() const noexcept
Definition: BTGattChar.cpp:162
jau::darray
Implementation of a dynamic linear array storage, aka vector.
Definition: darray.hpp:102
direct_bt::BTGattCharRef
std::shared_ptr< BTGattChar > BTGattCharRef
Definition: BTGattChar.hpp:409
direct_bt::BTGattChar::Listener::~Listener
virtual ~Listener() noexcept
Definition: BTGattChar.hpp:146
direct_bt::BTGattChar::getServiceChecked
std::shared_ptr< BTGattService > getServiceChecked() const
Definition: BTGattChar.cpp:154
direct_bt::BTGattCharListener
BTGattChar event listener for notification and indication events.
Definition: BTGattChar.hpp:435
direct_bt::BTGattChar::Listener::operator!=
bool operator!=(const Listener &rhs) const noexcept
Definition: BTGattChar.hpp:157
direct_bt::BTGattChar::clientCharConfigIndex
int clientCharConfigIndex
Definition: BTGattChar.hpp:195
JAVA_DBT_PACKAGE
#define JAVA_DBT_PACKAGE
Definition: BTTypes1.hpp:39
direct_bt::AssociatedBTGattCharListener::match
bool match(const BTGattChar &characteristic) noexcept override
Custom filter for all event methods, which will not be called if this method returns false.
Definition: BTGattChar.hpp:501
direct_bt::BTGattChar::getPropertiesStringList
static jau::darray< std::unique_ptr< std::string > > getPropertiesStringList(const PropertyBitVal properties) noexcept
Definition: BTGattChar.cpp:93
direct_bt::BTGattChar::Listener::operator==
virtual bool operator==(const Listener &rhs) const noexcept
Default comparison operator, merely testing for same memory reference.
Definition: BTGattChar.hpp:154
direct_bt::BTObject
Definition: BTTypes1.hpp:48
direct_bt::BTGattChar::clearDescriptors
void clearDescriptors() noexcept
Definition: BTGattChar.hpp:220
BTTypes0.hpp
direct_bt::BTGattChar::Listener::notificationReceived
virtual void notificationReceived(BTGattCharRef charDecl, const TROOctets &charValue, const uint64_t timestamp)=0
Called from native BLE stack, initiated by a received notification associated with the given BTGattCh...
UUID.hpp
direct_bt::BTGattCharListener::~BTGattCharListener
virtual ~BTGattCharListener() noexcept
Definition: BTGattChar.hpp:475
direct_bt::BTGattChar::BTGattChar
BTGattChar(const BTGattServiceRef &service_, const uint16_t service_handle_, const uint16_t handle_, const PropertyBitVal properties_, const uint16_t value_handle_, std::unique_ptr< const uuid_t > &&value_type_) noexcept
Definition: BTGattChar.hpp:197
direct_bt::AssociatedBTGattCharListener
Definition: BTGattChar.hpp:490
direct_bt::BTGattChar::PropertyBitVal
PropertyBitVal
BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.1.1 Characteristic Properties.
Definition: BTGattChar.hpp:86
direct_bt::BTGattChar::getClientCharConfig
BTGattDescRef getClientCharConfig() noexcept
Definition: BTGattChar.hpp:225
direct_bt::BTGattChar::Listener::indicationReceived
virtual void indicationReceived(BTGattCharRef charDecl, const TROOctets &charValue, const uint64_t timestamp, const bool confirmationSent)=0
Called from native BLE stack, initiated by a received indication associated with the given BTGattChar...
direct_bt::BTGattChar::toString
std::string toString() const noexcept override
Definition: BTGattChar.cpp:106
direct_bt::BTGattHandler
A thread safe GATT handler associated to one device via one L2CAP connection.
Definition: BTGattHandler.hpp:140
ATTPDUTypes.hpp
direct_bt::BTGattChar::Notify
@ Notify
Definition: BTGattChar.hpp:92
direct_bt::TROOctets
Transient read only octet data, i.e.
Definition: OctetTypes.hpp:59
direct_bt::BTGattChar::get_java_class
std::string get_java_class() const noexcept override
Definition: BTGattChar.hpp:202
BTGattDesc.hpp
direct_bt::BTGattChar::AuthSignedWrite
@ AuthSignedWrite
Definition: BTGattChar.hpp:94
charValue
static int charValue
Definition: dbt_scanner10.cpp:121
direct_bt::BTGattChar::ExtProps
@ ExtProps
Definition: BTGattChar.hpp:95
direct_bt::BTGattChar::WriteWithAck
@ WriteWithAck
Definition: BTGattChar.hpp:91
direct_bt::BTGattChar::writeValue
bool writeValue(const TROOctets &value)
BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value.
Definition: BTGattChar.cpp:315
direct_bt::BTGattChar::configNotificationIndication
bool configNotificationIndication(const bool enableNotification, const bool enableIndication, bool enabledState[2])
BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration.
Definition: BTGattChar.cpp:186
direct_bt::BTGattChar::value_type
std::unique_ptr< const uuid_t > value_type
Definition: BTGattChar.hpp:189
direct_bt::BTGattChar::writeValueNoResp
bool writeValueNoResp(const TROOctets &value)
BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.1 Write Characteristic Value Without Response.
Definition: BTGattChar.cpp:327
direct_bt::BTGattChar::descriptorList
jau::darray< BTGattDescRef > descriptorList
List of Characteristic Descriptions as shared reference.
Definition: BTGattChar.hpp:192
direct_bt::BTGattChar::WriteNoAck
@ WriteNoAck
Definition: BTGattChar.hpp:90
direct_bt::BTGattChar::value_handle
const uint16_t value_handle
Characteristics Value Handle.
Definition: BTGattChar.hpp:186
direct_bt::POctets
Persistent octet data, i.e.
Definition: OctetTypes.hpp:451
direct_bt::operator!=
bool operator!=(const EUI48Sub &lhs, const EUI48Sub &rhs) noexcept
Definition: BTAddress.hpp:275
direct_bt::BTGattChar::enableNotificationOrIndication
bool enableNotificationOrIndication(bool enabledState[2])
BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration.
Definition: BTGattChar.cpp:241
direct_bt::BTDevice
Definition: BTDevice.hpp:57
direct_bt::BTGattDescRef
std::shared_ptr< BTGattDesc > BTGattDescRef
Definition: BTGattDesc.hpp:177
direct_bt::BTGattChar::getDeviceUnchecked
std::shared_ptr< BTDevice > getDeviceUnchecked() const noexcept
Definition: BTGattChar.cpp:174
direct_bt::BTGattChar::properties
const PropertyBitVal properties
Definition: BTGattChar.hpp:178
jau::darray::clear
constexpr void clear() noexcept
Like std::vector::clear(), but ending with zero capacity.
Definition: darray.hpp:796
direct_bt::BTGattChar::Listener
BTGattChar event listener for notification and indication events.
Definition: BTGattChar.hpp:122