20#ifndef H_BLE_GATT_PRIV_
21#define H_BLE_GATT_PRIV_
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"
34struct ble_att_prep_write_cmd;
36STATS_SECT_START(ble_gattc_stats)
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)
75extern STATS_SECT_DECL(ble_gattc_stats) ble_gattc_stats;
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)
89extern STATS_SECT_DECL(ble_gatts_stats) ble_gatts_stats;
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
100typedef uint8_t ble_gatts_conn_flags;
102struct ble_gatts_conn {
103#if MYNEWT_VAL(BLE_DYNAMIC_SERVICE)
104 struct ble_gatts_clt_cfg_list clt_cfgs;
106 struct ble_gatts_clt_cfg *clt_cfgs;
109#if MYNEWT_VAL(BLE_GATT_CACHING)
114 uint16_t indicate_val_handle;
122 uint8_t peer_cl_sup_feat[BLE_GATT_CHR_CLI_SUP_FEAT_SZ];
127int ble_gattc_locked_by_cur_task(
void);
128void ble_gatts_indicate_fail_notconn(uint16_t conn_handle);
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,
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,
137void ble_gattc_rx_read_blob_rsp(uint16_t conn_handle,
int status,
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(
143void ble_gattc_rx_read_group_type_complete(uint16_t conn_handle,
int rc);
144void ble_gattc_rx_find_type_value_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,
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,
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);
160int ble_gattc_any_jobs(
void);
161int ble_gattc_init(
void);
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
167#define BLE_GATTS_CLT_CFG_F_RESERVED 0xfffc
169#define BLE_GATTS_INC_SVC_LEN_NO_UUID 4
170#define BLE_GATTS_INC_SVC_LEN_UUID 6
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,
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,
226#if MYNEWT_VAL(BLE_GATT_CACHING)
227struct ble_gatts_aware_state {
228 uint8_t peer_id_addr[6];
231extern struct ble_gatts_aware_state ble_gatts_conn_aware_states[MYNEWT_VAL(BLE_STORE_MAX_BONDS)];
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();
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