NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_gatt_priv.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef H_BLE_GATT_PRIV_
21#define H_BLE_GATT_PRIV_
22
23#include "nimble/porting/nimble/include/syscfg/syscfg.h"
24#include "nimble/porting/nimble/include/stats/stats.h"
25#include "nimble/nimble/host/include/host/ble_gatt.h"
26#ifdef __cplusplus
27extern "C" {
28#endif
29
34struct ble_att_prep_write_cmd;
35
36STATS_SECT_START(ble_gattc_stats)
37 STATS_SECT_ENTRY(mtu)
38 STATS_SECT_ENTRY(mtu_fail)
39 STATS_SECT_ENTRY(disc_all_svcs)
40 STATS_SECT_ENTRY(disc_all_svcs_fail)
41 STATS_SECT_ENTRY(disc_svc_uuid)
42 STATS_SECT_ENTRY(disc_svc_uuid_fail)
43 STATS_SECT_ENTRY(find_inc_svcs)
44 STATS_SECT_ENTRY(find_inc_svcs_fail)
45 STATS_SECT_ENTRY(disc_all_chrs)
46 STATS_SECT_ENTRY(disc_all_chrs_fail)
47 STATS_SECT_ENTRY(disc_chrs_uuid)
48 STATS_SECT_ENTRY(disc_chrs_uuid_fail)
49 STATS_SECT_ENTRY(disc_all_dscs)
50 STATS_SECT_ENTRY(disc_all_dscs_fail)
51 STATS_SECT_ENTRY(read)
52 STATS_SECT_ENTRY(read_fail)
53 STATS_SECT_ENTRY(read_uuid)
54 STATS_SECT_ENTRY(read_uuid_fail)
55 STATS_SECT_ENTRY(read_long)
56 STATS_SECT_ENTRY(read_long_fail)
57 STATS_SECT_ENTRY(read_mult)
58 STATS_SECT_ENTRY(read_mult_fail)
59 STATS_SECT_ENTRY(signed_write)
60 STATS_SECT_ENTRY(signed_write_fail)
61 STATS_SECT_ENTRY(write_no_rsp)
62 STATS_SECT_ENTRY(write_no_rsp_fail)
63 STATS_SECT_ENTRY(write)
64 STATS_SECT_ENTRY(write_fail)
65 STATS_SECT_ENTRY(write_long)
66 STATS_SECT_ENTRY(write_long_fail)
67 STATS_SECT_ENTRY(write_reliable)
68 STATS_SECT_ENTRY(write_reliable_fail)
69 STATS_SECT_ENTRY(notify)
70 STATS_SECT_ENTRY(notify_fail)
71 STATS_SECT_ENTRY(indicate)
72 STATS_SECT_ENTRY(indicate_fail)
73 STATS_SECT_ENTRY(proc_timeout)
74STATS_SECT_END
75extern STATS_SECT_DECL(ble_gattc_stats) ble_gattc_stats;
76
77STATS_SECT_START(ble_gatts_stats)
78 STATS_SECT_ENTRY(svcs)
79 STATS_SECT_ENTRY(chrs)
80 STATS_SECT_ENTRY(dscs)
81 STATS_SECT_ENTRY(svc_def_reads)
82 STATS_SECT_ENTRY(svc_inc_reads)
83 STATS_SECT_ENTRY(chr_def_reads)
84 STATS_SECT_ENTRY(chr_val_reads)
85 STATS_SECT_ENTRY(chr_val_writes)
86 STATS_SECT_ENTRY(dsc_reads)
87 STATS_SECT_ENTRY(dsc_writes)
88STATS_SECT_END
89extern STATS_SECT_DECL(ble_gatts_stats) ble_gatts_stats;
90
91#define BLE_GATT_CHR_DECL_SZ_16 5
92#define BLE_GATT_CHR_DECL_SZ_128 19
93#define BLE_GATT_CHR_CLI_SUP_FEAT_SZ 1
98#define BLE_GATT_CHR_CLI_SUP_FEAT_MASK 7
99
100typedef uint8_t ble_gatts_conn_flags;
101
102struct ble_gatts_conn {
103#if MYNEWT_VAL(BLE_DYNAMIC_SERVICE)
104 struct ble_gatts_clt_cfg_list clt_cfgs;
105#else
106 struct ble_gatts_clt_cfg *clt_cfgs;
107#endif
108 int num_clt_cfgs;
109#if MYNEWT_VAL(BLE_GATT_CACHING)
110 bool aware_state;
111 bool sent_err;
112#endif
113
114 uint16_t indicate_val_handle;
115
122 uint8_t peer_cl_sup_feat[BLE_GATT_CHR_CLI_SUP_FEAT_SZ];
123};
124
125/*** @client. */
126
127int ble_gattc_locked_by_cur_task(void);
128void ble_gatts_indicate_fail_notconn(uint16_t conn_handle);
129
130void ble_gattc_rx_err(uint16_t conn_handle, uint16_t handle, uint16_t status);
131void ble_gattc_rx_mtu(uint16_t conn_handle, int status, uint16_t chan_mtu);
132void ble_gattc_rx_read_type_adata(uint16_t conn_handle,
133 struct ble_att_read_type_adata *adata);
134void ble_gattc_rx_read_type_complete(uint16_t conn_handle, int status);
135void ble_gattc_rx_read_rsp(uint16_t conn_handle, int status,
136 struct os_mbuf **rxom);
137void ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, int status,
138 struct os_mbuf **rxom);
139void ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, int status,
140 struct os_mbuf **rxom, bool variable);
141void ble_gattc_rx_read_group_type_adata(
142 uint16_t conn_handle, struct ble_att_read_group_type_adata *adata);
143void ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, int rc);
144void ble_gattc_rx_find_type_value_hinfo(
145 uint16_t conn_handle, struct ble_att_find_type_value_hinfo *hinfo);
146void ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, int status);
147void ble_gattc_rx_write_rsp(uint16_t conn_handle);
148void ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
149 uint16_t handle, uint16_t offset,
150 struct os_mbuf **rxom);
151void ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status);
152void ble_gatts_rx_indicate_rsp(uint16_t conn_handle);
153void ble_gattc_rx_find_info_idata(uint16_t conn_handle,
154 struct ble_att_find_info_idata *idata);
155void ble_gattc_rx_find_info_complete(uint16_t conn_handle, int status);
156void ble_gattc_connection_txable(uint16_t conn_handle);
157void ble_gattc_connection_broken(uint16_t conn_handle);
158int32_t ble_gattc_timer(void);
159
160int ble_gattc_any_jobs(void);
161int ble_gattc_init(void);
162
163/*** @server. */
164#define BLE_GATTS_CLT_CFG_F_NOTIFY 0x0001
165#define BLE_GATTS_CLT_CFG_F_INDICATE 0x0002
166#define BLE_GATTS_CLT_CFG_F_MODIFIED 0x0080 /* Internal only. */
167#define BLE_GATTS_CLT_CFG_F_RESERVED 0xfffc
168
169#define BLE_GATTS_INC_SVC_LEN_NO_UUID 4
170#define BLE_GATTS_INC_SVC_LEN_UUID 6
171
179 uint16_t svcs;
180
182 uint16_t incs;
183
185 uint16_t chrs;
186
188 uint16_t dscs;
189
194 uint16_t cccds;
195
200 uint16_t cpfds;
201
206 uint16_t cafds;
207
209 uint16_t attrs;
210};
211
212int ble_gatts_rx_indicate_ack(uint16_t conn_handle, uint16_t chr_val_handle);
213int ble_gatts_send_next_indicate(uint16_t conn_handle);
214void ble_gatts_tx_notifications(void);
215void ble_gatts_bonding_established(uint16_t conn_handle);
216void ble_gatts_bonding_restored(uint16_t conn_handle);
217void ble_gatts_connection_broken(uint16_t conn_handle);
218void ble_gatts_lcl_svc_foreach(ble_gatt_svc_foreach_fn cb, void *arg);
219int ble_gatts_register_svcs(const struct ble_gatt_svc_def *svcs,
220 ble_gatt_register_fn *register_cb,
221 void *cb_arg);
222int ble_gatts_clt_cfg_access(uint16_t conn_handle, uint16_t attr_handle,
223 uint8_t op, uint16_t offset, struct os_mbuf **om,
224 void *arg);
225
226#if MYNEWT_VAL(BLE_GATT_CACHING)
227struct ble_gatts_aware_state {
228 uint8_t peer_id_addr[6];
229 bool aware;
230};
231extern struct ble_gatts_aware_state ble_gatts_conn_aware_states[MYNEWT_VAL(BLE_STORE_MAX_BONDS)];
232#endif
233
234/*** @misc. */
235int ble_gatts_conn_can_alloc(void);
236int ble_gatts_conn_init(struct ble_gatts_conn *gatts_conn);
237int ble_gatts_init(void);
238#if MYNEWT_VAL(BLE_GATT_CACHING)
239int ble_gattc_cache_conn_init();
240#endif
241
242#ifdef __cplusplus
243}
244#endif
245
246#endif
Definition ble_att_priv.h:242
Definition ble_att_priv.h:248
Definition ble_att_priv.h:262
Definition ble_att_priv.h:254
Definition ble_gatt_priv.h:177
uint16_t cafds
Definition ble_gatt_priv.h:206
uint16_t cccds
Definition ble_gatt_priv.h:194
uint16_t attrs
Definition ble_gatt_priv.h:209
uint16_t cpfds
Definition ble_gatt_priv.h:200
uint16_t chrs
Definition ble_gatt_priv.h:185
uint16_t dscs
Definition ble_gatt_priv.h:188
uint16_t svcs
Definition ble_gatt_priv.h:179
uint16_t incs
Definition ble_gatt_priv.h:182
Definition os_mbuf.h:86