ble_gatt_client
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
gatt-helpers.h
Go to the documentation of this file.
1 /*
2  *
3  * BlueZ - Bluetooth protocol stack for Linux
4  *
5  * Copyright (C) 2014 Google Inc.
6  *
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 /* This file defines helpers for performing client-side procedures defined by
25  * the Generic Attribute Profile.
26  */
27 
28 #include <stdbool.h>
29 #include <stdint.h>
30 
31 struct bt_gatt_result;
32 
33 struct bt_gatt_iter {
35  uint16_t pos;
36 };
37 
38 unsigned int bt_gatt_result_service_count(struct bt_gatt_result *result);
39 unsigned int bt_gatt_result_characteristic_count(struct bt_gatt_result *result);
40 unsigned int bt_gatt_result_descriptor_count(struct bt_gatt_result *result);
41 unsigned int bt_gatt_result_included_count(struct bt_gatt_result *result);
42 
43 bool bt_gatt_iter_init(struct bt_gatt_iter *iter, struct bt_gatt_result *result);
44 bool bt_gatt_iter_next_service(struct bt_gatt_iter *iter,
45  uint16_t *start_handle, uint16_t *end_handle,
46  uint8_t uuid[16]);
48  uint16_t *start_handle, uint16_t *end_handle,
49  uint16_t *value_handle, uint8_t *properties,
50  uint8_t uuid[16]);
51 bool bt_gatt_iter_next_descriptor(struct bt_gatt_iter *iter, uint16_t *handle,
52  uint8_t uuid[16]);
54  uint16_t *handle, uint16_t *start_handle,
55  uint16_t *end_handle, uint8_t uuid[16]);
57  uint16_t *handle, uint16_t *length,
58  const uint8_t **value);
59 
60 typedef void (*bt_gatt_destroy_func_t)(void *user_data);
61 
62 typedef void (*bt_gatt_result_callback_t)(bool success, uint8_t att_ecode,
63  void *user_data);
64 typedef void (*bt_gatt_request_callback_t)(bool success, uint8_t att_ecode,
65  struct bt_gatt_result *result,
66  void *user_data);
67 
68 struct bt_gatt_request;
69 
71 void bt_gatt_request_unref(struct bt_gatt_request *req);
72 void bt_gatt_request_cancel(struct bt_gatt_request *req);
73 
74 unsigned int bt_gatt_exchange_mtu(struct bt_att *att, uint16_t client_rx_mtu,
76  void *user_data,
78 
80  struct bt_att *att, bt_uuid_t *uuid,
82  void *user_data,
85  struct bt_att *att, bt_uuid_t *uuid,
86  uint16_t start, uint16_t end,
88  void *user_data,
91  struct bt_att *att, bt_uuid_t *uuid,
92  uint16_t start, uint16_t end,
94  void *user_data,
97  uint16_t start, uint16_t end,
99  void *user_data,
102  uint16_t start, uint16_t end,
104  void *user_data,
107  uint16_t start, uint16_t end,
109  void *user_data,
111 
112 bool bt_gatt_read_by_type(struct bt_att *att, uint16_t start, uint16_t end,
113  const bt_uuid_t *uuid,
115  void *user_data,
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)
Definition: gatt-helpers.c:582
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)
unsigned int bt_gatt_result_included_count(struct bt_gatt_result *result)
Definition: gatt-helpers.c:160
void(* bt_gatt_request_callback_t)(bool success, uint8_t att_ecode, struct bt_gatt_result *result, void *user_data)
Definition: gatt-helpers.h:64
void bt_gatt_request_unref(struct bt_gatt_request *req)
Definition: gatt-helpers.c:632
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)
Definition: gatt-helpers.c:925
bool bt_gatt_read_by_type(struct bt_att *att, uint16_t start, uint16_t end, const bt_uuid_t *uuid, bt_gatt_request_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy)
struct bt_gatt_request * bt_gatt_request_ref(struct bt_gatt_request *req)
Definition: gatt-helpers.c:622
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])
Definition: gatt-helpers.c:378
bool bt_gatt_iter_init(struct bt_gatt_iter *iter, struct bt_gatt_result *result)
Definition: gatt-helpers.c:188
struct bt_gatt_result * result
Definition: gatt-helpers.h:34
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)
Definition: gatt-helpers.c:936
bool bt_gatt_iter_next_descriptor(struct bt_gatt_iter *iter, uint16_t *handle, uint8_t uuid[16])
Definition: gatt-helpers.c:430
void(* bt_gatt_result_callback_t)(bool success, uint8_t att_ecode, void *user_data)
Definition: gatt-helpers.h:62
void(* bt_gatt_destroy_func_t)(void *user_data)
Definition: gatt-helpers.h:60
uint16_t pos
Definition: gatt-helpers.h:35
bt_gatt_request_callback_t callback
Definition: gatt-helpers.c:231
bt_uuid_t uuid
Definition: gatt-helpers.c:227
struct bt_att * att
Definition: gatt-helpers.c:222
bool bt_gatt_iter_next_read_by_type(struct bt_gatt_iter *iter, uint16_t *handle, uint16_t *length, const uint8_t **value)
Definition: gatt-helpers.c:455
unsigned int bt_gatt_result_characteristic_count(struct bt_gatt_result *result)
Definition: gatt-helpers.c:128
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)
Definition: gatt-helpers.c:947
unsigned int bt_gatt_result_service_count(struct bt_gatt_result *result)
Definition: gatt-helpers.c:116
Definition: att.c:64
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])
Definition: gatt-helpers.c:257
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)
bool bt_gatt_iter_next_service(struct bt_gatt_iter *iter, uint16_t *start_handle, uint16_t *end_handle, uint8_t uuid[16])
Definition: gatt-helpers.c:337
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)
void bt_gatt_request_cancel(struct bt_gatt_request *req)
Definition: gatt-helpers.c:650
bt_gatt_destroy_func_t destroy
Definition: gatt-helpers.c:233
unsigned int bt_gatt_result_descriptor_count(struct bt_gatt_result *result)
Definition: gatt-helpers.c:149