NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_gap_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_GAP_CONN_
21#define H_BLE_GAP_CONN_
22
23#include <inttypes.h>
24#include "nimble/porting/nimble/include/syscfg/syscfg.h"
25#include "nimble/porting/nimble/include/stats/stats.h"
26#include "nimble/nimble/host/include/host/ble_gap.h"
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31struct hci_le_conn_upd_complete;
32struct hci_le_conn_param_req;
33struct hci_le_conn_complete;
34struct hci_disconn_complete;
35struct hci_encrypt_change;
36struct ble_hs_hci_ack;
37struct ble_hs_adv;
38
39STATS_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)
71STATS_SECT_END
72
73extern 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
79void ble_gap_rx_le_scan_timeout(void);
80#endif
81
82#if MYNEWT_VAL(BLE_EXT_ADV)
83void ble_gap_rx_ext_adv_report(struct ble_gap_ext_disc_desc *desc);
84void ble_gap_rx_adv_set_terminated(const struct ble_hci_ev_le_subev_adv_set_terminated *ev);
85#if MYNEWT_VAL(BLE_PERIODIC_ADV)
86void ble_gap_rx_peroidic_adv_sync_estab(const struct ble_hci_ev_le_subev_periodic_adv_sync_estab *ev);
87void ble_gap_rx_periodic_adv_rpt(const struct ble_hci_ev_le_subev_periodic_adv_rpt *ev);
88void ble_gap_rx_periodic_adv_sync_lost(const struct ble_hci_ev_le_subev_periodic_adv_sync_lost *ev);
89void ble_gap_rx_periodic_adv_sync_transfer(const struct ble_hci_ev_le_subev_periodic_adv_sync_transfer *ev);
90#endif
91void ble_gap_rx_scan_req_rcvd(const struct ble_hci_ev_le_subev_scan_req_rcvd *ev);
92#endif
93void ble_gap_rx_adv_report(struct ble_gap_disc_desc *desc);
94void ble_gap_rx_rd_rem_sup_feat_complete(const struct ble_hci_ev_le_subev_rd_rem_used_feat *ev);
95#if MYNEWT_VAL(BLE_CONN_SUBRATING)
96void ble_gap_rx_subrate_change(const struct ble_hci_ev_le_subev_subrate_change *ev);
97#endif
98#if MYNEWT_VAL(BLE_POWER_CONTROL)
99void ble_gap_rx_transmit_power_report(const struct ble_hci_ev_le_subev_transmit_power_report *ev);
100void ble_gap_rx_le_pathloss_threshold(const struct ble_hci_ev_le_subev_path_loss_threshold *ev);
101#endif
102
103struct ble_gap_conn_complete
104{
105 uint8_t status;
106 uint16_t connection_handle;
107 uint8_t role;
108 uint8_t peer_addr_type;
109 uint8_t peer_addr[BLE_DEV_ADDR_LEN];
110 uint16_t conn_itvl;
111 uint16_t conn_latency;
112 uint16_t supervision_timeout;
113 uint8_t master_clk_acc;
114 uint8_t local_rpa[BLE_DEV_ADDR_LEN];
115 uint8_t peer_rpa[BLE_DEV_ADDR_LEN];
116};
117
118int ble_gap_rx_conn_complete(struct ble_gap_conn_complete *evt, uint8_t instance);
119void ble_gap_rx_disconn_complete(const struct ble_hci_ev_disconn_cmp *ev);
120void ble_gap_rx_update_complete(const struct ble_hci_ev_le_subev_conn_upd_complete *ev);
121void ble_gap_rx_param_req(const struct ble_hci_ev_le_subev_rem_conn_param_req *ev);
122int ble_gap_rx_l2cap_update_req(uint16_t conn_handle,
123 struct ble_gap_upd_params *params);
124void ble_gap_rx_phy_update_complete(const struct ble_hci_ev_le_subev_phy_update_complete *ev);
125void ble_gap_enc_event(uint16_t conn_handle, int status,
126 int security_restored, int bonded);
127void ble_gap_passkey_event(uint16_t conn_handle,
128 struct ble_gap_passkey_params *passkey_params);
129void ble_gap_notify_rx_event(uint16_t conn_handle, uint16_t attr_handle,
130 struct os_mbuf *om, int is_indication);
131void ble_gap_notify_tx_event(int status, uint16_t conn_handle,
132 uint16_t attr_handle, int is_indication);
133void ble_gap_subscribe_event(uint16_t conn_handle, uint16_t attr_handle,
134 uint8_t reason,
135 uint8_t prev_notify, uint8_t cur_notify,
136 uint8_t prev_indicate, uint8_t cur_indicate);
137void ble_gap_mtu_event(uint16_t conn_handle, uint16_t cid, uint16_t mtu);
138void ble_gap_identity_event(uint16_t conn_handle);
139int ble_gap_repeat_pairing_event(const struct ble_gap_repeat_pairing *rp);
140void ble_gap_vs_hci_event(const void *buf, uint8_t len);
141int ble_gap_authorize_event(uint16_t conn_handle, uint16_t attr_handle, int is_read);
142int ble_gap_master_in_progress(void);
143
144void ble_gap_preempt(void);
145void ble_gap_preempt_done(void);
146
147int ble_gap_terminate_with_conn(struct ble_hs_conn *conn, uint8_t hci_reason);
148void ble_gap_reset_state(int reason);
149void ble_gap_conn_broken(uint16_t conn_handle, int reason);
150void ble_gap_reset_state(int reason);
151int32_t ble_gap_timer(void);
152
153int ble_gap_init(void);
154void ble_gap_deinit(void);
155
156#if MYNEWT_VAL(BLE_HS_DEBUG)
157int ble_gap_dbg_update_active(uint16_t conn_handle);
158#endif
159
160#if MYNEWT_VAL(BLE_ENABLE_CONN_REATTEMPT)
161void ble_gap_reattempt_count(uint16_t conn_handle, uint8_t count);
162#endif
163
164void ble_gap_rx_data_len_change(const struct ble_hci_ev_le_subev_data_len_chg *ev);
165
166#ifdef __cplusplus
167}
168#endif
169
170#endif
Advertising report.
Definition ble_gap.h:458
Passkey query.
Definition ble_gap.h:368
Connection parameters update parameters.
Definition ble_gap.h:347
Definition os_mbuf.h:86