gatt.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2010 Nokia Corporation
  7. * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org>
  8. *
  9. *
  10. */
  11. /*
  12. * GATT Characteristic Property bit field
  13. * Reference: Core SPEC 4.1 page 2183 (Table 3.5: Characteristic Properties
  14. * bit field) defines how the Characteristic Value can be used, or how the
  15. * characteristic descriptors (see Section 3.3.3 - page 2184) can be accessed.
  16. * In the core spec, regular properties are included in the characteristic
  17. * declaration, and the extended properties are defined as descriptor.
  18. */
  19. #define GATT_CHR_PROP_BROADCAST 0x01
  20. #define GATT_CHR_PROP_READ 0x02
  21. #define GATT_CHR_PROP_WRITE_WITHOUT_RESP 0x04
  22. #define GATT_CHR_PROP_WRITE 0x08
  23. #define GATT_CHR_PROP_NOTIFY 0x10
  24. #define GATT_CHR_PROP_INDICATE 0x20
  25. #define GATT_CHR_PROP_AUTH 0x40
  26. #define GATT_CHR_PROP_EXT_PROP 0x80
  27. /* Client Characteristic Configuration bit field */
  28. #define GATT_CLIENT_CHARAC_CFG_NOTIF_BIT 0x0001
  29. #define GATT_CLIENT_CHARAC_CFG_IND_BIT 0x0002
  30. typedef void (*gatt_cb_t) (uint8_t status, GSList *l, void *user_data);
  31. struct gatt_primary {
  32. char uuid[MAX_LEN_UUID_STR + 1];
  33. gboolean changed;
  34. struct att_range range;
  35. };
  36. struct gatt_included {
  37. char uuid[MAX_LEN_UUID_STR + 1];
  38. uint16_t handle;
  39. struct att_range range;
  40. };
  41. struct gatt_char {
  42. char uuid[MAX_LEN_UUID_STR + 1];
  43. uint16_t handle;
  44. uint8_t properties;
  45. uint16_t value_handle;
  46. };
  47. struct gatt_desc {
  48. char uuid[MAX_LEN_UUID_STR + 1];
  49. uint16_t handle;
  50. uint16_t uuid16;
  51. };
  52. guint gatt_discover_primary(GAttrib *attrib, bt_uuid_t *uuid, gatt_cb_t func,
  53. gpointer user_data);
  54. unsigned int gatt_find_included(GAttrib *attrib, uint16_t start, uint16_t end,
  55. gatt_cb_t func, gpointer user_data);
  56. guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
  57. bt_uuid_t *uuid, gatt_cb_t func,
  58. gpointer user_data);
  59. guint gatt_read_char(GAttrib *attrib, uint16_t handle, GAttribResultFunc func,
  60. gpointer user_data);
  61. guint gatt_write_char(GAttrib *attrib, uint16_t handle, const uint8_t *value,
  62. size_t vlen, GAttribResultFunc func,
  63. gpointer user_data);
  64. guint gatt_discover_desc(GAttrib *attrib, uint16_t start, uint16_t end,
  65. bt_uuid_t *uuid, gatt_cb_t func,
  66. gpointer user_data);
  67. guint gatt_reliable_write_char(GAttrib *attrib, uint16_t handle,
  68. const uint8_t *value, size_t vlen,
  69. GAttribResultFunc func,
  70. gpointer user_data);
  71. guint gatt_execute_write(GAttrib *attrib, uint8_t flags,
  72. GAttribResultFunc func, gpointer user_data);
  73. guint gatt_write_cmd(GAttrib *attrib, uint16_t handle, const uint8_t *value,
  74. int vlen, GDestroyNotify notify, gpointer user_data);
  75. guint gatt_signed_write_cmd(GAttrib *attrib, uint16_t handle,
  76. const uint8_t *value, int vlen,
  77. struct bt_crypto *crypto,
  78. const uint8_t csrk[16],
  79. uint32_t sign_cnt,
  80. GDestroyNotify notify,
  81. gpointer user_data);
  82. guint gatt_read_char_by_uuid(GAttrib *attrib, uint16_t start, uint16_t end,
  83. bt_uuid_t *uuid, GAttribResultFunc func,
  84. gpointer user_data);
  85. guint gatt_exchange_mtu(GAttrib *attrib, uint16_t mtu, GAttribResultFunc func,
  86. gpointer user_data);
  87. gboolean gatt_parse_record(const sdp_record_t *rec,
  88. uuid_t *prim_uuid, uint16_t *psm,
  89. uint16_t *start, uint16_t *end);