47 #define MAX(a, b) ((a) > (b) ? (a) : (b))
51 #define MIN(a, b) ((a) < (b) ? (a) : (b))
54 #define UUID_BYTES (BT_GATT_UUID_SIZE * sizeof(uint8_t))
56 #define GATT_SVC_UUID 0x1801
57 #define SVC_CHNGD_UUID 0x2a05
155 __sync_fetch_and_add(&req->
ref_count, 1);
182 if (__sync_sub_and_fetch(&req->
ref_count, 1))
221 __sync_fetch_and_add(¬ify_data->
ref_count, 1);
230 if (__sync_sub_and_fetch(¬ify_data->
ref_count, 1))
317 return notify_data->
id ==
id;
346 uint16_t start_handle, uint16_t end_handle)
350 range.
start = start_handle;
351 range.
end = end_handle;
359 uint16_t start_handle, uint16_t end_handle)
363 range.
start = start_handle;
364 range.
end = end_handle;
446 if (__sync_sub_and_fetch(&op->
ref_count, 1))
475 uint16_t
handle, start, end;
479 unsigned int includes_count, i;
499 if (includes_count == 0)
503 "Included services found: %u",
506 for (i = 0; i < includes_count; i++) {
516 "handle: 0x%04x, start: 0x%04x, end: 0x%04x,"
517 "uuid: %s", handle, start, end, uuid_str);
541 struct queue *tmp_queue;
570 "Failed to start characteristic discovery");
592 "Failed to start included discovery");
616 struct chrc *chrc_data;
619 *discovering =
false;
647 client->
att, desc_start,
658 "Failed to start descriptor discovery");
681 uint16_t
handle, start, end;
685 unsigned int desc_count;
707 "Descriptors found: %u", desc_count);
715 "handle: 0x%04x, uuid: %s",
719 &uuid, 0, NULL, NULL,
760 "Failed to start characteristic discovery");
779 struct chrc *chrc_data;
780 uint16_t start, end, value;
785 unsigned int chrc_count;
804 "Characteristics found: %u", chrc_count);
810 &properties, u128.
data)) {
816 "start: 0x%04x, end: 0x%04x, value: 0x%04x, "
817 "props: 0x%02x, uuid: %s",
818 start, end, value, properties, uuid_str);
869 "Failed to start characteristic discovery");
897 "Secondary service discovery failed."
898 " ATT ECODE: 0x%02x", att_ecode);
914 "Secondary services found: %u",
923 "start: 0x%04x, end: 0x%04x, uuid: %s",
924 start, end, uuid_str);
932 false, end - start + 1);
936 "Failed to store service");
978 "Failed to start included services discovery");
1003 "Primary service discovery failed."
1004 " ATT ECODE: 0x%02x", att_ecode);
1014 "Primary services found: %u",
1023 "start: 0x%04x, end: 0x%04x, uuid: %s",
1024 start, end, uuid_str);
1031 true, end - start + 1);
1035 "Failed to store service");
1066 "Failed to start secondary service discovery");
1082 client->
ready = success;
1097 "MTU Exchange failed. ATT ECODE: 0x%02x",
1116 "MTU exchange complete, with MTU: %u",
1129 "Failed to initiate primary service discovery");
1144 uint16_t start_handle,
1145 uint16_t end_handle);
1147 uint16_t length,
void *user_data);
1167 memset(pdu, 0,
sizeof(pdu));
1185 pdu,
sizeof(pdu), callback,
1202 return error_pdu->
ecode;
1206 uint16_t length,
void *user_data)
1283 notify_data =
new0(
struct notify_data, 1);
1287 notify_data->
client = client;
1289 notify_data->
chrc = chrc;
1291 notify_data->
notify = notify;
1293 notify_data->
destroy = destroy;
1310 return notify_data->
id;
1318 return notify_data->
id;
1328 return notify_data->
id;
1349 "Failed to register handler for \"Service Changed\"");
1358 "Registered handler for \"Service Changed\": %u",
1406 "Failed to discover services within changed range - "
1407 "error: 0x%02x", att_ecode);
1430 "Failed to re-register handler for \"Service Changed\"");
1441 uint16_t start_handle,
1442 uint16_t end_handle)
1464 NULL, start_handle, end_handle,
1477 "Failed to initiate service discovery"
1478 " after Service Changed");
1482 uint16_t length,
void *user_data)
1486 uint16_t start, end;
1496 "Service Changed received with invalid handles");
1501 "Service Changed received - start: 0x%04x end: 0x%04x",
1533 "Failed to register handler for \"Service Changed\"");
1538 "Failed to initialize gatt-client");
1587 uint16_t length,
void *user_data)
1590 struct notify_data *next_data;
1616 if (notify_data->
att_id) {
1636 uint16_t value_handle;
1637 const uint8_t *value = NULL;
1644 if (pdu_data->
length > 2)
1645 value = pdu_data->
pdu + 2;
1652 notify_data->
notify(value_handle, value, pdu_data->
length - 2,
1664 memset(&pdu_data, 0,
sizeof(pdu_data));
1727 client->
ready =
false;
1799 __sync_fetch_and_add(&client->
ref_count, 1);
1809 if (__sync_sub_and_fetch(&client->
ref_count, 1))
1817 return (client && client->
ready);
1875 if (!client || !client->
att)
1883 if (!client || !client->
db)
1891 const struct request *req = a;
1894 return req->
id ==
id;
1929 struct request *req = user_data;
1963 if (!client || !
id || !client->
att)
1976 if (!client || !client->
att)
2013 struct request *req = user_data;
2016 uint8_t att_ecode = 0;
2017 const uint8_t *value = NULL;
2018 uint16_t value_len = 0;
2051 uint16_t value_handle,
2098 struct request *req = user_data;
2123 uint16_t *handles, uint8_t num_handles,
2128 uint8_t pdu[num_handles * 2];
2136 if (num_handles < 2)
2159 for (i = 0; i < num_handles; i++)
2160 put_le16(handles[i], pdu + (2 * i));
2193 free(op->
iov.iov_base);
2206 buf = realloc(op->
iov.iov_base, op->
iov.iov_len + len);
2210 op->
iov.iov_base = buf;
2212 memcpy(op->
iov.iov_base + op->
iov.iov_len, data, len);
2214 op->
iov.iov_len += len;
2223 struct request *req = user_data;
2226 uint8_t att_ecode = 0;
2275 op->
callback(success, att_ecode, op->
iov.iov_base,
2332 const uint8_t *value, uint16_t length) {
2333 uint8_t pdu[2 + length];
2354 memcpy(pdu + 2, value, length);
2386 struct request *req = user_data;
2388 bool success =
true;
2389 uint8_t att_ecode = 0;
2406 uint16_t value_handle,
2407 const uint8_t *value, uint16_t length,
2414 uint8_t pdu[2 + length];
2437 memcpy(pdu + 2, value, length);
2549 struct request *req = user_data;
2610 struct request *req = user_data;
2615 uint16_t next_index;
2629 if (!pdu || length != (op->
cur_length + 4)) {
2631 reliable_error =
true;
2638 reliable_error =
true;
2644 reliable_error =
true;
2650 if (next_index == op->
length) {
2659 op->
index = next_index;
2685 if ((
size_t)(length + offset) > UINT16_MAX)
2691 if (!length || !value)
2698 op->
value = malloc(length);
2711 memcpy(op->
value, value, length);
2782 struct request *req = user_data;
2786 bool reliable_error;
2790 reliable_error =
false;
2797 reliable_error =
false;
2802 if (!pdu || length != op->
pdu_len ||
2805 reliable_error =
true;
2811 reliable_error =
false;
2847 unsigned int id, uint16_t value_handle,
2848 uint16_t offset,
const uint8_t *value,
2856 uint8_t
pdu[4 + length];
2870 "There is other reliable write session ongoing %u",
2891 memcpy(pdu + 4, value, length);
2901 op->
pdu = malloc(length);
2908 memcpy(op->
pdu, pdu, length);
2937 struct request *req = user_data;
3019 uint16_t chrc_value_handle,
3025 if (!client || !client->
db || !chrc_value_handle || !callback)
3032 user_data, destroy);
static void service_changed_complete(struct discovery_op *op, bool success, uint8_t att_ecode)
static void disable_ccc_callback(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
bool gatt_db_attribute_get_char_data(const struct gatt_db_attribute *attrib, uint16_t *handle, uint16_t *value_handle, uint8_t *properties, bt_uuid_t *uuid)
static bool cancel_request(struct request *req)
#define BT_ATT_OP_HANDLE_VAL_CONF
bt_gatt_client_destroy_func_t destroy
void * queue_find(struct queue *queue, queue_match_func_t function, const void *match_data)
static void request_unref(void *data)
void queue_foreach(struct queue *queue, queue_foreach_func_t function, void *user_data)
static void complete_unregister_notify(void *data)
void bt_gatt_request_unref(struct bt_gatt_request *req)
static uint8_t process_error(const void *pdu, uint16_t length)
static void att_disconnect_cb(int err, void *user_data)
void bt_gatt_client_unref(struct bt_gatt_client *client)
static struct discovery_op * discovery_op_create(struct bt_gatt_client *client, uint16_t start, uint16_t end, discovery_op_complete_func_t complete_func, discovery_op_fail_func_t failure_func)
#define BT_ATT_OP_READ_RSP
static void gatt_client_remove_notify_chrcs_in_range(struct bt_gatt_client *client, uint16_t start_handle, uint16_t end_handle)
static bool append_chunk(struct read_long_op *op, const uint8_t *data, uint16_t len)
static bool cancel_long_write_req(struct bt_gatt_client *client, struct request *req)
static struct request * get_reliable_request(struct bt_gatt_client *client, unsigned int id)
#define GATT_CLIENT_CHARAC_CFG_UUID
uint16_t bt_gatt_client_get_mtu(struct bt_gatt_client *client)
bt_gatt_client_destroy_func_t debug_destroy
struct queue * notify_list
bt_gatt_client_destroy_func_t destroy
static void discovery_req_clear(struct bt_gatt_client *client)
#define BT_ATT_OP_SIGNED_WRITE_CMD
void gatt_db_unref(struct gatt_db *db)
void(* queue_destroy_func_t)(void *data)
struct bt_gatt_client * client
static void gatt_client_remove_all_notify_in_range(struct bt_gatt_client *client, uint16_t start_handle, uint16_t end_handle)
struct gatt_db_attribute * attr
static void read_long_cb(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
bt_gatt_client_callback_t callback
bt_gatt_client_service_changed_callback_t svc_chngd_callback
struct queue * pending_chrcs
unsigned int ccc_write_id
static bool match_req_id(const void *a, const void *b)
bool bt_att_unregister_disconnect(struct bt_att *att, unsigned int id)
static void init_fail(struct discovery_op *op)
bool bt_gatt_client_set_security(struct bt_gatt_client *client, int level)
unsigned int bt_gatt_client_write_value(struct bt_gatt_client *client, uint16_t value_handle, const uint8_t *value, uint16_t length, bt_gatt_client_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
bluetooth GATT client structure
static void destroy_read_long_op(void *data)
uint16_t gatt_db_attribute_get_handle(const struct gatt_db_attribute *attrib)
void(* bt_gatt_client_service_changed_callback_t)(uint16_t start_handle, uint16_t end_handle, void *user_data)
bool bt_gatt_client_is_ready(struct bt_gatt_client *client)
static void destroy_read_op(void *data)
bt_gatt_client_notify_callback_t notify
static void notify_chrc_free(void *data)
struct gatt_db_attribute * cur_svc
static void cancel_prep_write_cb(uint8_t opcode, const void *pdu, uint16_t len, void *user_data)
static void find_ccc(struct gatt_db_attribute *attr, void *user_data)
const bt_uuid_t * gatt_db_attribute_get_type(const struct gatt_db_attribute *attrib)
unsigned int bt_gatt_client_register_notify(struct bt_gatt_client *client, uint16_t chrc_value_handle, bt_gatt_client_register_callback_t callback, bt_gatt_client_notify_callback_t notify, void *user_data, bt_gatt_client_destroy_func_t destroy)
#define BT_ATT_OP_HANDLE_VAL_IND
void * queue_pop_head(struct queue *queue)
static void destroy_write_op(void *data)
bt_gatt_destroy_func_t destroy
static void long_write_op_free(void *data)
struct gatt_db_attribute * gatt_db_service_add_included(struct gatt_db_attribute *attrib, struct gatt_db_attribute *include)
void(* discovery_op_fail_func_t)(struct discovery_op *op)
discovery_op_fail_func_t failure_func
static void service_changed_failure(struct discovery_op *op)
static void cancel_long_write_cb(uint8_t opcode, const void *pdu, uint16_t len, void *user_data)
void(* discovery_op_complete_func_t)(struct discovery_op *op, bool success, uint8_t att_ecode)
#define BT_ATT_OP_READ_BLOB_REQ
static bool register_service_changed(struct bt_gatt_client *client)
#define BT_ATT_OP_PREP_WRITE_REQ
struct bt_gatt_request * bt_gatt_discover_characteristics(struct bt_att *att, uint16_t start, uint16_t end, bt_gatt_request_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy)
#define BT_ATT_OP_PREP_WRITE_RSP
struct gatt_db_attribute * gatt_db_service_insert_characteristic(struct gatt_db_attribute *attrib, uint16_t handle, const bt_uuid_t *uuid, uint32_t permissions, uint8_t properties, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data)
struct bt_gatt_request * bt_gatt_discover_included_services(struct bt_att *att, uint16_t start, uint16_t end, bt_gatt_request_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy)
struct queue * notify_chrcs
static struct discovery_op * discovery_op_ref(struct discovery_op *op)
static void notify_client_ready(struct bt_gatt_client *client, bool success, uint8_t att_ecode)
bool gatt_db_service_set_active(struct gatt_db_attribute *attrib, bool active)
bool bt_gatt_client_set_service_changed(struct bt_gatt_client *client, bt_gatt_client_service_changed_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
bool bt_gatt_iter_next_characteristic(struct bt_gatt_iter *iter, uint16_t *start_handle, uint16_t *end_handle, uint16_t *value_handle, uint8_t *properties, uint8_t uuid[16])
struct gatt_db_attribute * gatt_db_service_insert_descriptor(struct gatt_db_attribute *attrib, uint16_t handle, const bt_uuid_t *uuid, uint32_t permissions, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data)
static void discover_primary_cb(bool success, uint8_t att_ecode, struct bt_gatt_result *result, void *user_data)
bt_gatt_client_destroy_func_t ready_destroy
unsigned int gatt_db_find_by_type(struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, const bt_uuid_t *type, gatt_db_attribute_cb_t func, void *user_data)
bool bt_att_unregister(struct bt_att *att, unsigned int id)
#define BT_ATT_OP_WRITE_REQ
static bool match_notify_data_handle_range(const void *a, const void *b)
void(* bt_gatt_client_write_long_callback_t)(bool success, bool reliable_error, uint8_t att_ecode, void *user_data)
bt_gatt_client_debug_func_t debug_callback
struct queue * reg_notify_queue
static void put_le16(uint16_t val, void *dst)
void(* bt_gatt_destroy_func_t)(void *user_data)
static unsigned int register_notify(struct bt_gatt_client *client, uint16_t handle, bt_gatt_client_register_callback_t callback, bt_gatt_client_notify_callback_t notify, void *user_data, bt_gatt_client_destroy_func_t destroy)
static void exchange_mtu_cb(bool success, uint8_t att_ecode, void *user_data)
bool queue_isempty(struct queue *queue)
#define BT_ATT_OP_READ_BLOB_RSP
static void exec_write_cb(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
struct bt_gatt_client * client
struct bt_gatt_request * bt_gatt_discover_descriptors(struct bt_att *att, uint16_t start, uint16_t end, bt_gatt_request_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy)
bt_gatt_client_write_long_callback_t callback
int bt_uuid_cmp(const bt_uuid_t *uuid1, const bt_uuid_t *uuid2)
bool bt_gatt_client_cancel_all(struct bt_gatt_client *client)
#define BT_ATT_OP_WRITE_RSP
void(* bt_gatt_client_debug_func_t)(const char *str, void *user_data)
#define BT_ATT_OP_READ_MULT_RSP
bt_gatt_destroy_func_t destroy
bt_gatt_client_destroy_func_t destroy
bt_gatt_client_write_long_callback_t callback
void queue_destroy(struct queue *queue, queue_destroy_func_t destroy)
bool bt_att_set_security(struct bt_att *att, int level)
struct bt_gatt_client * bt_gatt_client_new(struct gatt_db *db, struct bt_att *att, uint16_t mtu)
discovery_op_complete_func_t complete_func
struct bt_gatt_client * client
static void notify_data_unref(void *data)
bt_gatt_client_destroy_func_t svc_chngd_destroy
void(* bt_gatt_client_register_callback_t)(uint16_t att_ecode, void *user_data)
bt_gatt_client_read_callback_t callback
bt_gatt_client_read_callback_t callback
bool bt_att_cancel(struct bt_att *att, unsigned int id)
bool gatt_db_clear_range(struct gatt_db *db, uint16_t start_handle, uint16_t end_handle)
bool bt_gatt_client_set_debug(struct bt_gatt_client *client, bt_gatt_client_debug_func_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
struct bt_gatt_client * bt_gatt_client_ref(struct bt_gatt_client *client)
static void bt_gatt_client_free(struct bt_gatt_client *client)
struct notify_chrc * chrc
static struct notify_data * notify_data_ref(struct notify_data *notify_data)
uint16_t bt_att_get_mtu(struct bt_att *att)
bool queue_push_tail(struct queue *queue, void *data)
static void destroy_prep_write_op(void *data)
struct queue * queue_new(void)
#define BT_ATT_OP_EXEC_WRITE_REQ
static void get_first_attribute(struct gatt_db_attribute *attrib, void *user_data)
bool bt_gatt_iter_next_included_service(struct bt_gatt_iter *iter, uint16_t *handle, uint16_t *start_handle, uint16_t *end_handle, uint8_t uuid[16])
static struct notify_chrc * notify_chrc_create(struct bt_gatt_client *client, uint16_t value_handle)
static void discover_incl_cb(bool success, uint8_t att_ecode, struct bt_gatt_result *result, void *user_data)
bool bt_gatt_client_unregister_notify(struct bt_gatt_client *client, unsigned int id)
bool queue_remove(struct queue *queue, void *data)
static void process_service_changed(struct bt_gatt_client *client, uint16_t start_handle, uint16_t end_handle)
struct bt_gatt_client * client
static bool match_notify_data_id(const void *a, const void *b)
bt_gatt_client_register_callback_t callback
#define BT_ATT_OP_ERROR_RSP
unsigned int queue_remove_all(struct queue *queue, queue_match_func_t function, void *user_data, queue_destroy_func_t destroy)
unsigned int svc_chngd_ind_id
#define BT_ATT_OP_WRITE_CMD
bool bt_gatt_iter_init(struct bt_gatt_iter *iter, struct bt_gatt_result *result)
unsigned int bt_gatt_client_read_multiple(struct bt_gatt_client *client, uint16_t *handles, uint8_t num_handles, bt_gatt_client_read_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
static void service_changed_cb(uint16_t value_handle, const uint8_t *value, uint16_t length, void *user_data)
#define BT_ATT_ERROR_UNSUPPORTED_GROUP_TYPE
int bt_uuid16_create(bt_uuid_t *btuuid, uint16_t value)
#define BT_ATT_OP_HANDLE_VAL_NOT
static void discover_chrcs_cb(bool success, uint8_t att_ecode, struct bt_gatt_result *result, void *user_data)
void util_debug(util_debug_func_t function, void *user_data, const char *format,...)
#define BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND
unsigned int bt_gatt_client_write_long_value(struct bt_gatt_client *client, bool reliable, uint16_t value_handle, uint16_t offset, const uint8_t *value, uint16_t length, bt_gatt_client_write_long_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
struct bt_gatt_request * bt_gatt_discover_secondary_services(struct bt_att *att, bt_uuid_t *uuid, uint16_t start, uint16_t end, bt_gatt_request_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy)
static void discovery_op_unref(void *data)
bool gatt_db_attribute_get_service_handles(const struct gatt_db_attribute *attrib, uint16_t *start_handle, uint16_t *end_handle)
void(* bt_gatt_client_read_callback_t)(bool success, uint8_t att_ecode, const uint8_t *value, uint16_t length, void *user_data)
static void enable_ccc_callback(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
unsigned int bt_gatt_result_descriptor_count(struct bt_gatt_result *result)
#define BT_ATT_OP_READ_MULT_REQ
bool bt_gatt_client_set_ready_handler(struct bt_gatt_client *client, bt_gatt_client_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
static void prepare_write_cb(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
void * queue_remove_if(struct queue *queue, queue_match_func_t function, void *user_data)
static void handle_next_prep_write(struct request *req)
bool gatt_db_clear(struct gatt_db *db)
#define BT_GATT_CHRC_PROP_INDICATE
struct queue * pending_svcs
void(* bt_gatt_client_callback_t)(bool success, uint8_t att_ecode, void *user_data)
static void complete_write_long_op(struct request *req, bool success, uint8_t att_ecode, bool reliable_error)
static struct request * request_create(struct bt_gatt_client *client)
struct gatt_db * bt_gatt_client_get_db(struct bt_gatt_client *client)
static void notify_handler(void *data, void *user_data)
struct bt_gatt_client * client
int bt_gatt_client_get_security(struct bt_gatt_client *client)
struct queue * pending_requests
static bool discover_descs(struct discovery_op *op, bool *discovering)
static bool match_notify_chrc_handle_range(const void *a, const void *b)
struct bt_gatt_client * client
struct gatt_db * gatt_db_ref(struct gatt_db *db)
static void service_changed_register_cb(uint16_t att_ecode, void *user_data)
unsigned int next_request_id
struct queue * svc_chngd_queue
static void discover_secondary_cb(bool success, uint8_t att_ecode, struct bt_gatt_result *result, void *user_data)
#define BT_ATT_DEFAULT_LE_MTU
int bt_att_get_security(struct bt_att *att)
void gatt_db_service_foreach_desc(struct gatt_db_attribute *attrib, gatt_db_attribute_cb_t func, void *user_data)
void(* bt_att_response_func_t)(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
struct gatt_db_attribute * gatt_db_get_attribute(struct gatt_db *db, uint16_t handle)
static void complete_notify_request(void *data)
struct bt_gatt_client * client
unsigned int bt_gatt_client_write_execute(struct bt_gatt_client *client, unsigned int id, bt_gatt_client_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
void(* bt_gatt_client_notify_callback_t)(uint16_t value_handle, const uint8_t *value, uint16_t length, void *user_data)
unsigned int bt_gatt_client_write_without_response(struct bt_gatt_client *client, uint16_t value_handle, bool signed_write, const uint8_t *value, uint16_t length)
#define BT_ATT_OP_EXEC_WRITE_RSP
bool svc_chngd_registered
unsigned int bt_gatt_client_prepare_write(struct bt_gatt_client *client, unsigned int id, uint16_t value_handle, uint16_t offset, const uint8_t *value, uint16_t length, bt_gatt_client_write_long_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
static void read_multiple_cb(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
unsigned int bt_gatt_result_characteristic_count(struct bt_gatt_result *result)
static struct request * request_ref(struct request *req)
struct bt_gatt_request * bt_gatt_discover_primary_services(struct bt_att *att, bt_uuid_t *uuid, uint16_t start, uint16_t end, bt_gatt_request_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy)
static bool gatt_client_init(struct bt_gatt_client *client, uint16_t mtu)
bool bt_gatt_iter_next_descriptor(struct bt_gatt_iter *iter, uint16_t *handle, uint8_t uuid[16])
bool bt_gatt_iter_next_service(struct bt_gatt_iter *iter, uint16_t *start_handle, uint16_t *end_handle, uint8_t uuid[16])
static uint16_t get_le16(const void *ptr)
static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable, bt_att_response_func_t callback)
static void write_cb(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
bt_gatt_client_callback_t ready_callback
static void discover_descs_cb(bool success, uint8_t att_ecode, struct bt_gatt_result *result, void *user_data)
static void start_next_long_write(struct bt_gatt_client *client)
void(* bt_gatt_client_destroy_func_t)(void *user_data)
#define BT_ATT_ERROR_REQUEST_NOT_SUPPORTED
struct gatt_db_attribute * gatt_db_insert_service(struct gatt_db *db, uint16_t handle, const bt_uuid_t *uuid, bool primary, uint16_t num_handles)
unsigned int bt_gatt_exchange_mtu(struct bt_att *att, uint16_t client_rx_mtu, bt_gatt_result_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy)
static bool match_notify_chrc_value_handle(const void *a, const void *b)
#define BT_ATT_OP_READ_REQ
static void prep_write_cb(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
static void notify_data_cleanup(void *data)
#define BT_ATT_MAX_VALUE_LEN
struct bt_gatt_request * discovery_req
static void notify_cb(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
unsigned int bt_att_register(struct bt_att *att, uint8_t opcode, bt_att_notify_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
bt_gatt_client_destroy_func_t destroy
unsigned int bt_gatt_client_read_long_value(struct bt_gatt_client *client, uint16_t value_handle, uint16_t offset, bt_gatt_client_read_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
void bt_gatt_request_cancel(struct bt_gatt_request *req)
struct queue * long_write_queue
unsigned int bt_gatt_result_service_count(struct bt_gatt_result *result)
unsigned int bt_att_register_disconnect(struct bt_att *att, bt_att_disconnect_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
unsigned int bt_att_send(struct bt_att *att, uint8_t opcode, const void *pdu, uint16_t length, bt_att_response_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
static void read_cb(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
void bt_att_unref(struct bt_att *att)
unsigned int bt_gatt_result_included_count(struct bt_gatt_result *result)
static bool cancel_prep_write_session(struct bt_gatt_client *client, struct request *req)
#define BT_GATT_CHRC_PROP_NOTIFY
static void discovery_op_free(struct discovery_op *op)
int bt_uuid128_create(bt_uuid_t *btuuid, uint128_t value)
unsigned int bt_gatt_client_read_value(struct bt_gatt_client *client, uint16_t value_handle, bt_gatt_client_read_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy)
struct bt_att * bt_att_ref(struct bt_att *att)
static void init_complete(struct discovery_op *op, bool success, uint8_t att_ecode)
unsigned int reliable_write_session_id
static void execute_write_cb(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
struct bt_gatt_request * bt_gatt_discover_all_primary_services(struct bt_att *att, bt_uuid_t *uuid, bt_gatt_request_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy)
bool gatt_db_service_get_active(struct gatt_db_attribute *attrib)
bool bt_gatt_client_cancel(struct bt_gatt_client *client, unsigned int id)
int bt_uuid_to_string(const bt_uuid_t *uuid, char *str, size_t n)