12
12
13
13
/**
14
14
* @brief Generic Attribute Profile (GATT)
15
+ * @details The GATT layer manages the service database by providing APIs for
16
+ * service registration and attribute declaration. For more
17
+ * information, see @ref bt_gatt_client and @ref bt_gatt_server.
15
18
* @defgroup bt_gatt Generic Attribute Profile (GATT)
16
19
* @ingroup bluetooth
17
20
* @{
@@ -222,9 +225,9 @@ typedef ssize_t (*bt_gatt_attr_write_func_t)(struct bt_conn *conn,
222
225
* pass the pointer to GATT server APIs.
223
226
*/
224
227
struct bt_gatt_attr {
225
- /** @brief Attribute Type, aka. "UUID"
228
+ /** @brief Attribute Type
226
229
*
227
- * The Attribute Type determines the interface that can
230
+ * The Attribute Type is a UUID which determines the interface that can
228
231
* be expected from the read() and write() methods and
229
232
* the possible permission configurations.
230
233
*
@@ -275,16 +278,13 @@ struct bt_gatt_attr {
275
278
*/
276
279
void * user_data ;
277
280
278
- /** @brief Attribute Handle or zero, maybe?
281
+ /** @brief Attribute Handle
279
282
*
280
- * The meaning of this field varies and is not specified here.
281
- * Some APIs use this field as input/output. It does not always
282
- * contain the Attribute Handle.
283
+ * The Attribute Handle is an index corresponding to a specific
284
+ * Attribute in the ATT database.
283
285
*
284
286
* @note Use bt_gatt_attr_get_handle() for attributes in the
285
287
* local ATT database.
286
- *
287
- * @sa bt_gatt_discover_func_t about this field.
288
288
*/
289
289
uint16_t handle ;
290
290
@@ -294,8 +294,6 @@ struct bt_gatt_attr {
294
294
*
295
295
* The permissions are security requirements that must be
296
296
* satisfied before calling read() or write().
297
- *
298
- * @sa bt_gatt_discover_func_t about this field.
299
297
*/
300
298
uint16_t perm : 15 ;
301
299
@@ -311,39 +309,61 @@ struct bt_gatt_attr {
311
309
/** @endcond */
312
310
};
313
311
314
- /** @brief GATT Service structure */
312
+ /** @brief Static GATT Service structure
313
+ *
314
+ * Allows the user the declare static GATT Services with the aim of reducing the
315
+ * used RAM. The @ref BT_GATT_SERVICE_DEFINE macro can be used to statically
316
+ * define and register a service.
317
+ */
315
318
struct bt_gatt_service_static {
316
319
/** Service Attributes */
317
320
const struct bt_gatt_attr * attrs ;
318
321
/** Service Attribute count */
319
322
size_t attr_count ;
320
323
};
321
324
322
- /** @brief GATT Service structure */
325
+ /** @brief GATT Service structure
326
+ *
327
+ * This structure is used to define GATT services which can be registered and
328
+ * unregistered at runtime. See @ref bt_gatt_service_register for when services
329
+ * should be registered.
330
+ */
323
331
struct bt_gatt_service {
324
332
/** Service Attributes */
325
333
struct bt_gatt_attr * attrs ;
326
334
/** Service Attribute count */
327
335
size_t attr_count ;
328
-
336
+ /** @cond INTERNAL_HIDDEN
337
+ * Field used for list handling.
338
+ */
329
339
sys_snode_t node ;
340
+ /** @endcond */
330
341
};
331
342
332
- /** @brief Service Attribute Value. */
343
+ /** @brief Service Attribute Value.
344
+ *
345
+ * This is the data described by the Attribute Type and indexed by the
346
+ * Attribute Handle in the database.
347
+ */
333
348
struct bt_gatt_service_val {
334
349
/** Service UUID. */
335
350
const struct bt_uuid * uuid ;
336
- /** Service end handle . */
351
+ /** Handle of the last Attribute within the Service . */
337
352
uint16_t end_handle ;
338
353
};
339
354
340
- /** @brief Include Attribute Value. */
355
+ /** @brief Include Attribute Value.
356
+ *
357
+ * This structure represents an included service attribute in the GATT
358
+ * server. An included service is a service that is referenced within another
359
+ * service, allowing for the reuse of common service definitions.
360
+ */
341
361
struct bt_gatt_include {
342
362
/** Service UUID. */
343
363
const struct bt_uuid * uuid ;
344
- /** Service start handle . */
364
+ /** Handle of the first attribute within the included service . */
345
365
uint16_t start_handle ;
346
- /** Service end handle . */
366
+ /** Handle of the last attribute within the included service . */
347
367
uint16_t end_handle ;
348
368
};
349
369
@@ -360,7 +380,11 @@ struct bt_gatt_cb {
360
380
*/
361
381
void (* att_mtu_updated )(struct bt_conn * conn , uint16_t tx , uint16_t rx );
362
382
383
+ /** @cond INTERNAL_HIDDEN
384
+ * Field used for list handling.
385
+ */
363
386
sys_snode_t node ;
387
+ /** @endcond */
364
388
};
365
389
366
390
/** @brief GATT authorization callback structure. */
@@ -448,23 +472,33 @@ struct bt_gatt_authorization_cb {
448
472
*/
449
473
#define BT_GATT_CHRC_EXT_PROP 0x80
450
474
451
- /** @brief Characteristic Attribute Value. */
475
+ /** @brief Attribute Value of a Characteristic Declaration.
476
+ *
477
+ * This is the data associated with the characteristic, and can be read from or
478
+ * written to by a GATT client depending on the characteristic properties.
479
+ */
452
480
struct bt_gatt_chrc {
453
481
/** Characteristic UUID. */
454
482
const struct bt_uuid * uuid ;
455
483
/** Characteristic Value handle. */
456
484
uint16_t value_handle ;
457
- /** Characteristic properties. */
485
+ /** Characteristic properties, a bitmap of ``BT_GATT_CHRC_*`` macros . */
458
486
uint8_t properties ;
459
487
};
460
488
461
489
/** Characteristic Extended Properties Bit field values */
462
490
#define BT_GATT_CEP_RELIABLE_WRITE 0x0001
463
491
#define BT_GATT_CEP_WRITABLE_AUX 0x0002
464
492
465
- /** @brief Characteristic Extended Properties Attribute Value. */
493
+ /** @brief Characteristic Extended Properties Attribute Value.
494
+ *
495
+ * Used in the discovery of standard characteristic descriptor values. Shall
496
+ * exist if the @ref BT_GATT_CHRC_EXT_PROP bit is set in the characteristic
497
+ * properties. Can be used with the @ref BT_GATT_CEP macro to declare the CEP
498
+ * descriptor.
499
+ */
466
500
struct bt_gatt_cep {
467
- /** Characteristic Extended properties */
501
+ /** Characteristic Extended properties, a bitmap of ``BT_GATT_CEP_*`` macros. */
468
502
uint16_t properties ;
469
503
};
470
504
@@ -483,9 +517,12 @@ struct bt_gatt_cep {
483
517
*/
484
518
#define BT_GATT_CCC_INDICATE 0x0002
485
519
486
- /** Client Characteristic Configuration Attribute Value */
520
+ /** @brief Client Characteristic Configuration Attribute Value
521
+ *
522
+ * Used in the discovery of standard characteristic descriptor values.
523
+ */
487
524
struct bt_gatt_ccc {
488
- /** Client Characteristic Configuration flags */
525
+ /** Client Characteristic Configuration flags, a bitmap of ``BT_GATT_CCC_*`` macros. */
489
526
uint16_t flags ;
490
527
};
491
528
@@ -499,25 +536,52 @@ struct bt_gatt_ccc {
499
536
*/
500
537
#define BT_GATT_SCC_BROADCAST 0x0001
501
538
502
- /** Server Characteristic Configuration Attribute Value */
539
+ /** @brief Server Characteristic Configuration Attribute Value
540
+ *
541
+ * Used in the discovery of standard characteristic descriptor values.
542
+ */
503
543
struct bt_gatt_scc {
504
- /** Server Characteristic Configuration flags */
544
+ /** Server Characteristic Configuration flags, a bitmap of ``BT_GATT_SCC_*`` macros. */
505
545
uint16_t flags ;
506
546
};
507
547
508
- /** @brief GATT Characteristic Presentation Format Attribute Value. */
548
+ /** @brief GATT Characteristic Presentation Format Attribute Value.
549
+ *
550
+ * Used in the discovery of standard characteristic descriptor values. Can be
551
+ * used with the @ref BT_GATT_CPF macro to declare the CPF descriptor.
552
+ */
509
553
struct bt_gatt_cpf {
510
- /** Format of the value of the characteristic */
554
+ /** @brief Format of the value of the characteristic.
555
+ *
556
+ * The format types can be found in section 2.4.1 of the Bluetooth SIG
557
+ * Assigned Numbers document.
558
+ */
511
559
uint8_t format ;
512
- /** Exponent field to determine how the value of this characteristic is
513
- * further formatted
560
+ /** @brief Exponent field for value formatting.
561
+ *
562
+ * Only used on integer format types.
563
+ * actual value = Characteristic Value x 10^Exponent
514
564
*/
515
565
int8_t exponent ;
516
- /** Unit of the characteristic */
566
+ /** @brief UUID of the unit of the characteristic.
567
+ *
568
+ * The units can be found in section 3.5 of the Bluetooth SIG Assigned
569
+ * Numbers document.
570
+ */
517
571
uint16_t unit ;
518
- /** Name space of the description */
572
+ /** @brief Name space of the description.
573
+ *
574
+ * Used to identify the organization that is responsible for defining
575
+ * the enumerations for the description field. See section 2.4.2 of the
576
+ * Bluetooth SIG Assigned Numbers document.
577
+ */
519
578
uint8_t name_space ;
520
- /** Description of the characteristic as defined in a higher layer profile */
579
+ /** @brief Description of the characteristic as defined in a higher layer profile.
580
+ *
581
+ * An enumerated value defined by the organization identified by the
582
+ * name_space field. See section 2.4.2.1 of the Bluetooth SIG Assigned
583
+ * Numbers document.
584
+ */
521
585
uint16_t description ;
522
586
};
523
587
@@ -721,8 +785,8 @@ uint16_t bt_gatt_attr_get_handle(const struct bt_gatt_attr *attr);
721
785
*
722
786
* @param attr A Characteristic Attribute.
723
787
*
724
- * @note The ``user_data`` of the attribute must of type @ref bt_gatt_chrc and the ``uuid`` shall be
725
- * BT_UUID_GATT_CHRC
788
+ * @note The ``user_data`` of the attribute must be of type @ref bt_gatt_chrc and the ``uuid`` shall
789
+ * be BT_UUID_GATT_CHRC.
726
790
*
727
791
* @return the handle of the corresponding Characteristic Value. The value will
728
792
* be zero (the invalid handle) if @p attr was not a characteristic
@@ -1722,6 +1786,7 @@ struct bt_gatt_discover_params {
1722
1786
/** Discover attribute callback */
1723
1787
bt_gatt_discover_func_t func ;
1724
1788
union {
1789
+ /** See @ref bt_gatt_include for more on included services. */
1725
1790
struct {
1726
1791
/** Include service attribute declaration handle */
1727
1792
uint16_t attr_handle ;
@@ -1841,9 +1906,9 @@ struct bt_gatt_read_params {
1841
1906
bool variable ;
1842
1907
} multiple ;
1843
1908
struct {
1844
- /** First requested handle number . */
1909
+ /** Attribute handle to start reading from . */
1845
1910
uint16_t start_handle ;
1846
- /** Last requested handle number . */
1911
+ /** Attribute handle to stop reading at . */
1847
1912
uint16_t end_handle ;
1848
1913
/** 2 or 16 octet UUID. */
1849
1914
const struct bt_uuid * uuid ;
@@ -2133,7 +2198,11 @@ struct bt_gatt_subscribe_params {
2133
2198
/** Subscription flags */
2134
2199
ATOMIC_DEFINE (flags , BT_GATT_SUBSCRIBE_NUM_FLAGS );
2135
2200
2201
+ /** @cond INTERNAL_HIDDEN
2202
+ * Field used for list handling.
2203
+ */
2136
2204
sys_snode_t node ;
2205
+ /** @endcond */
2137
2206
#if defined(CONFIG_BT_EATT ) || defined(__DOXYGEN__ )
2138
2207
/** Att channel options. */
2139
2208
enum bt_att_chan_opt chan_opt ;
0 commit comments