20#ifndef H_BLE_ATT_PRIV_
21#define H_BLE_ATT_PRIV_
24#include "nimble/porting/nimble/include/stats/stats.h"
25#include "nimble/nimble/host/include/host/ble_att.h"
26#include "nimble/nimble/host/include/host/ble_uuid.h"
27#include "nimble/nimble/include/nimble/nimble_npl.h"
28#include "nimble/porting/nimble/include/syscfg/syscfg.h"
37struct ble_att_find_info_req;
38struct ble_att_error_rsp;
39struct ble_att_mtu_cmd;
40struct ble_att_read_req;
41struct ble_att_read_blob_req;
42struct ble_att_read_type_req;
43struct ble_att_read_group_type_req;
44struct ble_att_read_group_type_rsp;
45struct ble_att_find_type_value_req;
46struct ble_att_write_req;
47struct ble_att_prep_write_cmd;
48struct ble_att_exec_write_req;
49struct ble_att_notify_req;
50struct ble_att_indicate_req;
52STATS_SECT_START(ble_att_stats)
53 STATS_SECT_ENTRY(error_rsp_rx)
54 STATS_SECT_ENTRY(error_rsp_tx)
55 STATS_SECT_ENTRY(mtu_req_rx)
56 STATS_SECT_ENTRY(mtu_req_tx)
57 STATS_SECT_ENTRY(mtu_rsp_rx)
58 STATS_SECT_ENTRY(mtu_rsp_tx)
59 STATS_SECT_ENTRY(find_info_req_rx)
60 STATS_SECT_ENTRY(find_info_req_tx)
61 STATS_SECT_ENTRY(find_info_rsp_rx)
62 STATS_SECT_ENTRY(find_info_rsp_tx)
63 STATS_SECT_ENTRY(find_type_value_req_rx)
64 STATS_SECT_ENTRY(find_type_value_req_tx)
65 STATS_SECT_ENTRY(find_type_value_rsp_rx)
66 STATS_SECT_ENTRY(find_type_value_rsp_tx)
67 STATS_SECT_ENTRY(read_type_req_rx)
68 STATS_SECT_ENTRY(read_type_req_tx)
69 STATS_SECT_ENTRY(read_type_rsp_rx)
70 STATS_SECT_ENTRY(read_type_rsp_tx)
71 STATS_SECT_ENTRY(read_req_rx)
72 STATS_SECT_ENTRY(read_req_tx)
73 STATS_SECT_ENTRY(read_rsp_rx)
74 STATS_SECT_ENTRY(read_rsp_tx)
75 STATS_SECT_ENTRY(read_blob_req_rx)
76 STATS_SECT_ENTRY(read_blob_req_tx)
77 STATS_SECT_ENTRY(read_blob_rsp_rx)
78 STATS_SECT_ENTRY(read_blob_rsp_tx)
79 STATS_SECT_ENTRY(read_mult_req_rx)
80 STATS_SECT_ENTRY(read_mult_req_tx)
81 STATS_SECT_ENTRY(read_mult_rsp_rx)
82 STATS_SECT_ENTRY(read_mult_rsp_tx)
83 STATS_SECT_ENTRY(read_group_type_req_rx)
84 STATS_SECT_ENTRY(read_group_type_req_tx)
85 STATS_SECT_ENTRY(read_group_type_rsp_rx)
86 STATS_SECT_ENTRY(read_group_type_rsp_tx)
87 STATS_SECT_ENTRY(write_req_rx)
88 STATS_SECT_ENTRY(write_req_tx)
89 STATS_SECT_ENTRY(write_rsp_rx)
90 STATS_SECT_ENTRY(write_rsp_tx)
91 STATS_SECT_ENTRY(prep_write_req_rx)
92 STATS_SECT_ENTRY(prep_write_req_tx)
93 STATS_SECT_ENTRY(prep_write_rsp_rx)
94 STATS_SECT_ENTRY(prep_write_rsp_tx)
95 STATS_SECT_ENTRY(exec_write_req_rx)
96 STATS_SECT_ENTRY(exec_write_req_tx)
97 STATS_SECT_ENTRY(exec_write_rsp_rx)
98 STATS_SECT_ENTRY(exec_write_rsp_tx)
99 STATS_SECT_ENTRY(notify_req_rx)
100 STATS_SECT_ENTRY(notify_req_tx)
101 STATS_SECT_ENTRY(indicate_req_rx)
102 STATS_SECT_ENTRY(indicate_req_tx)
103 STATS_SECT_ENTRY(indicate_rsp_rx)
104 STATS_SECT_ENTRY(indicate_rsp_tx)
105 STATS_SECT_ENTRY(write_cmd_rx)
106 STATS_SECT_ENTRY(write_cmd_tx)
108extern STATS_SECT_DECL(ble_att_stats) ble_att_stats;
110struct ble_att_prep_entry {
111 SLIST_ENTRY(ble_att_prep_entry) bape_next;
112 uint16_t bape_handle;
113 uint16_t bape_offset;
121SLIST_HEAD(ble_att_prep_entry_list, ble_att_prep_entry);
123struct ble_att_svr_conn {
125 struct ble_att_prep_entry_list basc_prep_list;
126 ble_npl_time_t basc_prep_timeout_at;
141typedef int ble_att_svr_access_fn(uint16_t conn_handle, uint16_t attr_handle,
142 uint8_t op, uint16_t offset,
143 struct os_mbuf **om,
void *arg);
145int ble_att_svr_register(
const ble_uuid_t *uuid, uint8_t flags,
146 uint8_t min_key_size, uint16_t *handle_id,
147 ble_att_svr_access_fn *cb,
void *cb_arg);
149#if MYNEWT_VAL(BLE_DYNAMIC_SERVICE)
150int ble_att_svr_deregister(uint16_t start_handle, uint16_t end_group_handle);
152#if MYNEWT_VAL(BLE_GATT_CACHING)
153int ble_att_get_database_size(
int *out_size);
154int ble_att_fill_database_info(uint8_t *out_data);
158struct ble_att_svr_entry {
159 STAILQ_ENTRY(ble_att_svr_entry) ha_next;
163 uint8_t ha_min_key_size;
164 uint16_t ha_handle_id;
165 ble_att_svr_access_fn *ha_cb;
169SLIST_HEAD(ble_att_clt_entry_list, ble_att_clt_entry);
173struct ble_l2cap_chan *ble_att_create_chan(uint16_t conn_handle);
174int ble_att_conn_chan_find(uint16_t conn_handle,
struct ble_hs_conn **out_conn,
175 struct ble_l2cap_chan **out_chan);
176void ble_att_inc_tx_stat(uint8_t att_op);
177void ble_att_truncate_to_mtu(
const struct ble_l2cap_chan *att_chan,
179void ble_att_set_peer_mtu(
struct ble_l2cap_chan *chan, uint16_t peer_mtu);
180uint16_t ble_att_chan_mtu(
const struct ble_l2cap_chan *chan);
181int ble_att_init(
void);
185int ble_att_svr_start(
void);
186void ble_att_svr_stop(
void);
188struct ble_att_svr_entry *
189ble_att_svr_find_by_uuid(
struct ble_att_svr_entry *start_at,
191 uint16_t end_handle);
192uint16_t ble_att_svr_prev_handle(
void);
193int ble_att_svr_rx_mtu(uint16_t conn_handle,
struct os_mbuf **rxom);
194struct ble_att_svr_entry *ble_att_svr_find_by_handle(uint16_t handle_id);
195int32_t ble_att_svr_ticks_until_tmo(
const struct ble_att_svr_conn *svr,
197int ble_att_svr_rx_find_info(uint16_t conn_handle,
struct os_mbuf **rxom);
198int ble_att_svr_rx_find_type_value(uint16_t conn_handle,
200int ble_att_svr_rx_read_type(uint16_t conn_handle,
202int ble_att_svr_rx_read_group_type(uint16_t conn_handle,
204int ble_att_svr_rx_read(uint16_t conn_handle,
206int ble_att_svr_rx_read_blob(uint16_t conn_handle,
208int ble_att_svr_rx_read_mult_var(uint16_t conn_handle,
210int ble_att_svr_rx_read_mult(uint16_t conn_handle,
212int ble_att_svr_rx_write(uint16_t conn_handle,
214int ble_att_svr_rx_write_no_rsp(uint16_t conn_handle,
struct os_mbuf **rxom);
216int ble_att_svr_rx_signed_write(uint16_t conn_handle,
struct os_mbuf **rxom);
218int ble_att_svr_rx_prep_write(uint16_t conn_handle,
220int ble_att_svr_rx_exec_write(uint16_t conn_handle,
222int ble_att_svr_rx_notify(uint16_t conn_handle,
224int ble_att_svr_rx_indicate(uint16_t conn_handle,
226void ble_att_svr_prep_clear(
struct ble_att_prep_entry_list *prep_list);
227int ble_att_svr_read_handle(uint16_t conn_handle, uint16_t attr_handle,
228 uint16_t offset,
struct os_mbuf *om,
229 uint8_t *out_att_err);
230void ble_att_svr_reset(
void);
231int ble_att_svr_init(
void);
233void ble_att_svr_hide_range(uint16_t start_handle, uint16_t end_handle);
234void ble_att_svr_restore_range(uint16_t start_handle, uint16_t end_handle);
236int ble_att_svr_tx_error_rsp(uint16_t conn_handle,
struct os_mbuf *txom,
237 uint8_t req_op, uint16_t handle,
243 uint16_t attr_handle;
249 uint16_t attr_handle;
250 uint16_t group_end_handle;
264 uint16_t end_group_handle;
269int ble_att_clt_rx_error(uint16_t conn_handle,
struct os_mbuf **rxom);
270int ble_att_clt_tx_mtu(uint16_t conn_handle, uint16_t mtu);
271int ble_att_clt_rx_mtu(uint16_t conn_handle,
struct os_mbuf **rxom);
272int ble_att_clt_tx_read(uint16_t conn_handle, uint16_t handle);
273int ble_att_clt_rx_read(uint16_t conn_handle,
struct os_mbuf **rxom);
274int ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t handle,
276int ble_att_clt_rx_read_blob(uint16_t conn_handle,
struct os_mbuf **rxom);
277int ble_att_clt_tx_read_mult(uint16_t conn_handle,
278 const uint16_t *handles,
int num_handles,
bool variable);
279int ble_att_clt_rx_read_mult(uint16_t conn_handle,
struct os_mbuf **rxom);
280int ble_att_clt_rx_read_mult_var(uint16_t conn_handle,
struct os_mbuf **rxom);
281int ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t start_handle,
283int ble_att_clt_rx_read_type(uint16_t conn_handle,
struct os_mbuf **rxom);
284int ble_att_clt_tx_read_group_type(uint16_t conn_handle,
285 uint16_t start_handle, uint16_t end_handle,
287int ble_att_clt_rx_read_group_type(uint16_t conn_handle,
289int ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t start_handle,
290 uint16_t end_handle);
291int ble_att_clt_rx_find_info(uint16_t conn_handle,
struct os_mbuf **rxom);
292int ble_att_clt_tx_find_type_value(uint16_t conn_handle, uint16_t start_handle,
293 uint16_t end_handle, uint16_t attribute_type,
294 const void *attribute_value,
int value_len);
295int ble_att_clt_rx_find_type_value(uint16_t conn_handle,
297int ble_att_clt_tx_write_req(uint16_t conn_handle, uint16_t handle,
299int ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t handle,
301int ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t handle,
302 uint16_t offset,
struct os_mbuf *txom);
303int ble_att_clt_rx_prep_write(uint16_t conn_handle,
struct os_mbuf **rxom);
304int ble_att_clt_tx_exec_write(uint16_t conn_handle, uint8_t flags);
305int ble_att_clt_tx_signed_write_cmd(uint16_t conn_handle, uint16_t handle,
306 uint8_t * csrk, uint32_t counter,
308int ble_att_clt_rx_exec_write(uint16_t conn_handle,
struct os_mbuf **rxom);
309int ble_att_clt_rx_write(uint16_t conn_handle,
struct os_mbuf **rxom);
310int ble_att_clt_tx_notify(uint16_t conn_handle, uint16_t handle,
312int ble_att_clt_tx_indicate(uint16_t conn_handle, uint16_t handle,
314int ble_att_clt_rx_indicate(uint16_t conn_handle,
struct os_mbuf **rxom);
Definition ble_att_priv.h:242
Definition ble_att_priv.h:248
Definition ble_att_priv.h:262
Definition ble_att_priv.h:254