SmartSnippets DA1459x SDK
ble_gattc.h
Go to the documentation of this file.
1 
39 #ifndef BLE_GATTC_H_
40 #define BLE_GATTC_H_
41 
42 #include <stdint.h>
43 #include "ble_att.h"
44 #include "ble_common.h"
45 #include "ble_gatt.h"
46 
73 };
74 
76 typedef enum {
82 
84 typedef enum {
90 
92 typedef struct {
93  att_uuid_t uuid;
94  uint16_t handle;
96 
97  union {
99  struct {
100  uint16_t start_h;
101  uint16_t end_h;
102  } i;
103 
105  struct {
106  uint16_t value_handle;
107  uint8_t properties;
108  } c;
109 
111  struct {
112  // nothing here
113  } d;
114  };
115 } gattc_item_t;
116 
118 typedef struct {
120  uint16_t conn_idx;
121  att_uuid_t uuid;
122  uint16_t start_h;
123  uint16_t end_h;
124  uint16_t num_items;
125  gattc_item_t items[];
127 
129 typedef struct {
131  uint16_t conn_idx;
132  uint8_t status;
134 
136 typedef struct {
138  uint16_t conn_idx;
139  att_uuid_t uuid;
140  uint16_t start_h;
141  uint16_t end_h;
143 
145 typedef struct {
147  uint16_t conn_idx;
148  uint16_t handle;
149  att_uuid_t uuid;
150  uint16_t start_h;
151  uint16_t end_h;
153 
155 typedef struct {
157  uint16_t conn_idx;
158  att_uuid_t uuid;
159  uint16_t handle;
160  uint16_t value_handle;
161  uint8_t properties;
163 
165 typedef struct {
167  uint16_t conn_idx;
168  att_uuid_t uuid;
169  uint16_t handle;
171 
173 typedef struct {
175  uint16_t conn_idx;
177  uint8_t status;
179 
181 typedef struct {
183  uint16_t conn_idx;
184  uint16_t handle;
186  uint16_t offset;
187  uint16_t length;
188  uint8_t value[];
190 
192 typedef struct {
194  uint16_t conn_idx;
195  uint16_t handle;
197  uint8_t operation;
199 
201 typedef struct {
203  uint16_t conn_idx;
204  uint16_t handle;
205  uint16_t length;
206  uint8_t value[];
208 
210 typedef struct {
212  uint16_t conn_idx;
213  uint16_t handle;
214  uint16_t length;
215  uint8_t value[];
217 
219 typedef struct {
221  uint16_t conn_idx;
222  uint16_t mtu;
224 
245 ble_error_t ble_gattc_browse(uint16_t conn_idx, const att_uuid_t *uuid);
246 
269 ble_error_t ble_gattc_browse_range(uint16_t conn_idx, uint16_t start_h, uint16_t end_h,
270  const att_uuid_t *uuid);
271 
290 ble_error_t ble_gattc_discover_svc(uint16_t conn_idx, const att_uuid_t *uuid);
291 
305 ble_error_t ble_gattc_discover_include(uint16_t conn_idx, uint16_t start_h, uint16_t end_h);
306 
325 ble_error_t ble_gattc_discover_char(uint16_t conn_idx, uint16_t start_h, uint16_t end_h,
326  const att_uuid_t *uuid);
327 
341 ble_error_t ble_gattc_discover_desc(uint16_t conn_idx, uint16_t start_h, uint16_t end_h);
342 
359 ble_error_t ble_gattc_read(uint16_t conn_idx, uint16_t handle, uint16_t offset);
360 
381 ble_error_t ble_gattc_write(uint16_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length,
382  const uint8_t *value);
383 
404 ble_error_t ble_gattc_write_no_resp(uint16_t conn_idx, uint16_t handle, bool signed_write,
405  uint16_t length, const uint8_t *value);
406 
422 ble_error_t ble_gattc_write_prepare(uint16_t conn_idx, uint16_t handle, uint16_t offset,
423  uint16_t length, const uint8_t *value);
424 
439 ble_error_t ble_gattc_write_execute(uint16_t conn_idx, bool commit);
440 
455 ble_error_t ble_gattc_indication_cfm(uint16_t conn_idx, uint16_t handle) __attribute__((deprecated));
456 
466 ble_error_t ble_gattc_get_mtu(uint16_t conn_idx, uint16_t *mtu);
467 
480 ble_error_t ble_gattc_exchange_mtu(uint16_t conn_idx);
481 
482 #endif /* BLE_GATTC_H_ */
483 
ble_evt_gattc_browse_svc_t
Definition: ble_gattc.h:118
ble_evt_gattc_browse_completed_t::status
uint8_t status
browsing status
Definition: ble_gattc.h:132
ble_evt_gattc_discover_include_t::handle
uint16_t handle
include attribute handle
Definition: ble_gattc.h:148
ble_evt_gattc_write_completed_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:194
ble_evt_gattc_write_completed_t::handle
uint16_t handle
attribute handle (will be 0 for ble_gatts_write_execute())
Definition: ble_gattc.h:195
ble_evt_gattc_discover_char_t::uuid
att_uuid_t uuid
characteristic UUID
Definition: ble_gattc.h:158
ble_evt_gattc_write_completed_t::operation
uint8_t operation
operation type
Definition: ble_gattc.h:197
ble_evt_gattc_discover_char_t
Definition: ble_gattc.h:155
ble_evt_gattc_discover_include_t::end_h
uint16_t end_h
included service end handle
Definition: ble_gattc.h:151
ble_evt_gattc
ble_evt_gattc
Definition: ble_gattc.h:48
ble_evt_gattc_discover_char_t::handle
uint16_t handle
characteristic handle
Definition: ble_gattc.h:159
BLE_EVT_GATTC_INDICATION
Definition: ble_gattc.h:70
BLE_EVT_GATTC_READ_COMPLETED
Definition: ble_gattc.h:64
ble_evt_gattc_mtu_changed_t::mtu
uint16_t mtu
current MTU
Definition: ble_gattc.h:222
ble_gattc_exchange_mtu
ble_error_t ble_gattc_exchange_mtu(uint16_t conn_idx)
Exchange MTU.
ble_evt_gattc_discover_completed_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:174
gattc_item_t::handle
uint16_t handle
item handle
Definition: ble_gattc.h:94
ble_gattc_read
ble_error_t ble_gattc_read(uint16_t conn_idx, uint16_t handle, uint16_t offset)
Read attribute from remote GATT server.
ble_gattc_get_mtu
ble_error_t ble_gattc_get_mtu(uint16_t conn_idx, uint16_t *mtu)
Get current TX MTU for peer.
gattc_item_t
Definition: ble_gattc.h:92
ble_evt_gattc_mtu_changed_t
Definition: ble_gattc.h:219
BLE_EVT_GATTC_WRITE_COMPLETED
Definition: ble_gattc.h:66
ble_evt_gattc_discover_svc_t::end_h
uint16_t end_h
service end handle
Definition: ble_gattc.h:141
gattc_item_t::end_h
uint16_t end_h
included service end handle
Definition: ble_gattc.h:101
ble_evt_gattc_read_completed_t::status
att_error_t status
operation status
Definition: ble_gattc.h:185
att_error_t
att_error_t
Definition: ble_att.h:64
BLE_EVT_GATTC_BROWSE_SVC
Definition: ble_gattc.h:50
gattc_item_type_t
gattc_item_type_t
Definition: ble_gattc.h:76
ble_gatt.h
Common definitions for GATT API.
BLE_EVT_GATTC_MTU_CHANGED
Definition: ble_gattc.h:72
ble_evt_gattc_discover_include_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:146
BLE_EVT_GATTC_DISCOVER_CHAR
Definition: ble_gattc.h:58
ble_evt_gattc_read_completed_t
Definition: ble_gattc.h:181
gattc_item_t::properties
uint8_t properties
characteristic properties
Definition: ble_gattc.h:107
ble_evt_gattc_browse_completed_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:131
ble_evt_gattc_discover_desc_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:166
ble_evt_gattc_discover_include_t::uuid
att_uuid_t uuid
included service UUID
Definition: ble_gattc.h:149
ble_evt_gattc_discover_svc_t::start_h
uint16_t start_h
service start handle
Definition: ble_gattc.h:140
BLE_EVT_GATTC_NOTIFICATION
Definition: ble_gattc.h:68
BLE_EVT_GATTC_DISCOVER_INCLUDE
Definition: ble_gattc.h:56
GATTC_DISCOVERY_TYPE_INCLUDED
discovery included services type
Definition: ble_gattc.h:86
ble_evt_gattc_discover_char_t::properties
uint8_t properties
characteristic properties
Definition: ble_gattc.h:161
ble_evt_gattc_read_completed_t::offset
uint16_t offset
value offset
Definition: ble_gattc.h:186
ble_evt_gattc_discover_completed_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:175
ble_evt_gattc_notification_t::handle
uint16_t handle
attribute handle
Definition: ble_gattc.h:204
ble_gattc_discover_include
ble_error_t ble_gattc_discover_include(uint16_t conn_idx, uint16_t start_h, uint16_t end_h)
Discover included services on remote GATT server.
GATTC_ITEM_TYPE_CHARACTERISTIC
characteristic
Definition: ble_gattc.h:79
ble_evt_gattc_indication_t::length
uint16_t length
value length
Definition: ble_gattc.h:214
ble_evt_gattc_discover_svc_t::uuid
att_uuid_t uuid
service UUID
Definition: ble_gattc.h:139
ble_evt_gattc_discover_desc_t
Definition: ble_gattc.h:165
__attribute__
__attribute__
Definition: suota_security_ext.h:98
ble_evt_gattc_discover_char_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:156
ble_evt_gattc_notification_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:203
ble_evt_gattc_discover_svc_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:138
ble_evt_gattc_discover_svc_t
Definition: ble_gattc.h:136
ble_gattc_write_no_resp
ble_error_t ble_gattc_write_no_resp(uint16_t conn_idx, uint16_t handle, bool signed_write, uint16_t length, const uint8_t *value)
Write attribute to remote GATT server (without response)
ble_evt_gattc_discover_desc_t::handle
uint16_t handle
characteristic descriptor handle
Definition: ble_gattc.h:169
ble_gattc_browse_range
ble_error_t ble_gattc_browse_range(uint16_t conn_idx, uint16_t start_h, uint16_t end_h, const att_uuid_t *uuid)
Browse services on remote GATT server in a given range.
BLE_EVT_GATTC_DISCOVER_SVC
Definition: ble_gattc.h:54
ble_evt_gattc_write_completed_t::status
att_error_t status
operation status
Definition: ble_gattc.h:196
ble_evt_gattc_discover_include_t
Definition: ble_gattc.h:145
ble_evt_hdr_t
Definition: ble_common.h:156
ble_gattc_discover_svc
ble_error_t ble_gattc_discover_svc(uint16_t conn_idx, const att_uuid_t *uuid)
Discover services on remote GATT server.
ble_evt_gattc_discover_include_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:147
ble_evt_gattc_mtu_changed_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:221
ble_evt_gattc_read_completed_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:183
GATTC_ITEM_TYPE_INCLUDE
included service
Definition: ble_gattc.h:78
ble_evt_gattc_indication_t::handle
uint16_t handle
attribute handle
Definition: ble_gattc.h:213
GATTC_ITEM_TYPE_NONE
invalid or unknown item
Definition: ble_gattc.h:77
ble_evt_gattc_discover_svc_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:137
ble_gattc_write_prepare
ble_error_t ble_gattc_write_prepare(uint16_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *value)
Prepare long/reliable write to remote GATT server.
BLE_EVT_GATTC_BROWSE_COMPLETED
Definition: ble_gattc.h:52
ble_evt_gattc_browse_completed_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:130
BLE_EVT_CAT_FIRST
#define BLE_EVT_CAT_FIRST(CAT)
Definition: ble_common.h:153
ble_evt_gattc_indication_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:212
BLE_EVT_GATTC_DISCOVER_COMPLETED
Definition: ble_gattc.h:62
gattc_item_t::type
gattc_item_type_t type
item type
Definition: ble_gattc.h:95
ble_evt_gattc_indication_t
Definition: ble_gattc.h:210
ble_gattc_write
ble_error_t ble_gattc_write(uint16_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *value)
Write attribute to remote GATT server.
ble_gattc_browse
ble_error_t ble_gattc_browse(uint16_t conn_idx, const att_uuid_t *uuid)
Browse services on remote GATT server.
ble_evt_gattc_browse_completed_t
Definition: ble_gattc.h:129
ble_evt_gattc_discover_completed_t::status
uint8_t status
discovery status
Definition: ble_gattc.h:177
ble_evt_gattc_browse_svc_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:119
ble_gattc_write_execute
ble_error_t ble_gattc_write_execute(uint16_t conn_idx, bool commit)
Execute reliable/long write to remote GATT server.
ble_evt_gattc_discover_desc_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:167
GATTC_DISCOVERY_TYPE_CHARACTERISTICS
discovery characteristics type
Definition: ble_gattc.h:87
ble_att.h
Attribute protocol API.
GATTC_ITEM_TYPE_DESCRIPTOR
characteristic description
Definition: ble_gattc.h:80
ble_gattc_discover_desc
ble_error_t ble_gattc_discover_desc(uint16_t conn_idx, uint16_t start_h, uint16_t end_h)
Discover descriptors on remote GATT server.
ble_error_t
ble_error_t
Definition: ble_common.h:53
BLE_EVT_GATTC_DISCOVER_DESC
Definition: ble_gattc.h:60
ble_evt_gattc_notification_t
Definition: ble_gattc.h:201
ble_evt_gattc_read_completed_t::handle
uint16_t handle
attribute handle
Definition: ble_gattc.h:184
ble_evt_gattc_discover_char_t::value_handle
uint16_t value_handle
characteristic value handle
Definition: ble_gattc.h:160
ble_common.h
Common definitions for BLE API.
ble_evt_gattc_notification_t::length
uint16_t length
value length
Definition: ble_gattc.h:205
ble_evt_gattc_discover_completed_t
Definition: ble_gattc.h:173
ble_evt_gattc_read_completed_t::length
uint16_t length
value length
Definition: ble_gattc.h:187
ble_evt_gattc_browse_svc_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:120
ble_gattc_indication_cfm
ble_error_t ble_gattc_indication_cfm(uint16_t conn_idx, uint16_t handle) __attribute__((deprecated))
Send confirmation for received indication.
ble_evt_gattc_browse_svc_t::num_items
uint16_t num_items
number of items in service
Definition: ble_gattc.h:124
ble_gattc_discover_char
ble_error_t ble_gattc_discover_char(uint16_t conn_idx, uint16_t start_h, uint16_t end_h, const att_uuid_t *uuid)
Discover characteristics on remote GATT server.
ble_evt_gattc_browse_svc_t::start_h
uint16_t start_h
service start handle
Definition: ble_gattc.h:122
gattc_item_t::value_handle
uint16_t value_handle
characteristic value handle
Definition: ble_gattc.h:106
gattc_discovery_type_t
gattc_discovery_type_t
Definition: ble_gattc.h:84
GATTC_DISCOVERY_TYPE_DESCRIPTORS
discovery descriptors type
Definition: ble_gattc.h:88
gattc_item_t::uuid
att_uuid_t uuid
item UUID
Definition: ble_gattc.h:93
ble_evt_gattc_write_completed_t
Definition: ble_gattc.h:192
GATTC_DISCOVERY_TYPE_SVC
discovery services type
Definition: ble_gattc.h:85
ble_evt_gattc_read_completed_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:182
ble_evt_gattc_mtu_changed_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:220
ble_evt_gattc_discover_include_t::start_h
uint16_t start_h
included service start handle
Definition: ble_gattc.h:150
ble_evt_gattc_write_completed_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:193
ble_evt_gattc_indication_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:211
gattc_item_t::start_h
uint16_t start_h
included service start handle
Definition: ble_gattc.h:100
ble_evt_gattc_browse_svc_t::uuid
att_uuid_t uuid
service uuid
Definition: ble_gattc.h:121
ble_evt_gattc_discover_desc_t::uuid
att_uuid_t uuid
characteristic descriptor UUID
Definition: ble_gattc.h:168
ble_evt_gattc_browse_svc_t::end_h
uint16_t end_h
service end handle
Definition: ble_gattc.h:123
ble_evt_gattc_discover_char_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gattc.h:157
ble_evt_gattc_discover_completed_t::type
gattc_discovery_type_t type
discovery type
Definition: ble_gattc.h:176
ble_evt_gattc_notification_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gattc.h:202