xref: /nrf52832-nimble/packages/NimBLE-latest/nimble/host/src/ble_gap_priv.h (revision 042d53a763ad75cb1465103098bb88c245d95138)
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_GAP_CONN_
21 #define H_BLE_GAP_CONN_
22 
23 #include <inttypes.h>
24 #include "syscfg/syscfg.h"
25 #include "stats/stats.h"
26 #include "host/ble_gap.h"
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 struct hci_le_conn_upd_complete;
32 struct hci_le_conn_param_req;
33 struct hci_le_conn_complete;
34 struct hci_disconn_complete;
35 struct hci_encrypt_change;
36 struct ble_hs_hci_ack;
37 struct ble_hs_adv;
38 
39 STATS_SECT_START(ble_gap_stats)
40     STATS_SECT_ENTRY(wl_set)
41     STATS_SECT_ENTRY(wl_set_fail)
42     STATS_SECT_ENTRY(adv_stop)
43     STATS_SECT_ENTRY(adv_stop_fail)
44     STATS_SECT_ENTRY(adv_start)
45     STATS_SECT_ENTRY(adv_start_fail)
46     STATS_SECT_ENTRY(adv_set_data)
47     STATS_SECT_ENTRY(adv_set_data_fail)
48     STATS_SECT_ENTRY(adv_rsp_set_data)
49     STATS_SECT_ENTRY(adv_rsp_set_data_fail)
50     STATS_SECT_ENTRY(discover)
51     STATS_SECT_ENTRY(discover_fail)
52     STATS_SECT_ENTRY(initiate)
53     STATS_SECT_ENTRY(initiate_fail)
54     STATS_SECT_ENTRY(terminate)
55     STATS_SECT_ENTRY(terminate_fail)
56     STATS_SECT_ENTRY(cancel)
57     STATS_SECT_ENTRY(cancel_fail)
58     STATS_SECT_ENTRY(update)
59     STATS_SECT_ENTRY(update_fail)
60     STATS_SECT_ENTRY(connect_mst)
61     STATS_SECT_ENTRY(connect_slv)
62     STATS_SECT_ENTRY(disconnect)
63     STATS_SECT_ENTRY(rx_disconnect)
64     STATS_SECT_ENTRY(rx_update_complete)
65     STATS_SECT_ENTRY(rx_adv_report)
66     STATS_SECT_ENTRY(rx_conn_complete)
67     STATS_SECT_ENTRY(discover_cancel)
68     STATS_SECT_ENTRY(discover_cancel_fail)
69     STATS_SECT_ENTRY(security_initiate)
70     STATS_SECT_ENTRY(security_initiate_fail)
71 STATS_SECT_END
72 
73 extern STATS_SECT_DECL(ble_gap_stats) ble_gap_stats;
74 
75 #define BLE_GAP_CONN_MODE_MAX               3
76 #define BLE_GAP_DISC_MODE_MAX               3
77 
78 #if MYNEWT_VAL(BLE_EXT_ADV) && NIMBLE_BLE_SCAN
79 void ble_gap_rx_le_scan_timeout(void);
80 #endif
81 
82 #if MYNEWT_VAL(BLE_EXT_ADV)
83 void ble_gap_rx_ext_adv_report(struct ble_gap_ext_disc_desc *desc);
84 void ble_gap_rx_adv_set_terminated(struct hci_le_adv_set_terminated *evt);
85 #endif
86 void ble_gap_rx_adv_report(struct ble_gap_disc_desc *desc);
87 void ble_gap_rx_rd_rem_sup_feat_complete(struct hci_le_rd_rem_supp_feat_complete *evt);
88 int ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt, uint8_t instance);
89 void ble_gap_rx_disconn_complete(struct hci_disconn_complete *evt);
90 void ble_gap_rx_update_complete(struct hci_le_conn_upd_complete *evt);
91 void ble_gap_rx_param_req(struct hci_le_conn_param_req *evt);
92 int ble_gap_rx_l2cap_update_req(uint16_t conn_handle,
93                                 struct ble_gap_upd_params *params);
94 void ble_gap_rx_phy_update_complete(struct hci_le_phy_upd_complete *evt);
95 void ble_gap_enc_event(uint16_t conn_handle, int status,
96                        int security_restored);
97 void ble_gap_passkey_event(uint16_t conn_handle,
98                            struct ble_gap_passkey_params *passkey_params);
99 void ble_gap_notify_rx_event(uint16_t conn_handle, uint16_t attr_handle,
100                              struct os_mbuf *om, int is_indication);
101 void ble_gap_notify_tx_event(int status, uint16_t conn_handle,
102                              uint16_t attr_handle, int is_indication);
103 void ble_gap_subscribe_event(uint16_t conn_handle, uint16_t attr_handle,
104                              uint8_t reason,
105                              uint8_t prev_notify, uint8_t cur_notify,
106                              uint8_t prev_indicate, uint8_t cur_indicate);
107 void ble_gap_mtu_event(uint16_t conn_handle, uint16_t cid, uint16_t mtu);
108 void ble_gap_identity_event(uint16_t conn_handle);
109 int ble_gap_repeat_pairing_event(const struct ble_gap_repeat_pairing *rp);
110 int ble_gap_master_in_progress(void);
111 
112 void ble_gap_preempt(void);
113 void ble_gap_preempt_done(void);
114 
115 void ble_gap_conn_broken(uint16_t conn_handle, int reason);
116 int32_t ble_gap_timer(void);
117 
118 int ble_gap_init(void);
119 
120 #if MYNEWT_VAL(BLE_HS_DEBUG)
121 int ble_gap_dbg_update_active(uint16_t conn_handle);
122 #endif
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif
129