24#include "ble_l2cap_priv.h"
25#include "ble_gatt_priv.h"
26#include "ble_att_priv.h"
31struct hci_le_conn_complete;
32struct hci_create_conn;
35typedef uint8_t ble_hs_conn_flags_t;
37#define BLE_HS_CONN_F_MASTER 0x01
38#define BLE_HS_CONN_F_TERMINATING 0x02
39#define BLE_HS_CONN_F_TX_FRAG 0x04
41#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
42#define BLE_HS_CONN_L2CAP_COC_CID_MASK_LEN_REM \
43 ((MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) % (8 * sizeof(uint32_t))) ? 1 : 0)
45#define BLE_HS_CONN_L2CAP_COC_CID_MASK_LEN \
46 (MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) / (8 * sizeof(uint32_t)) + \
47 BLE_HS_CONN_L2CAP_COC_CID_MASK_LEN_REM)
51 SLIST_ENTRY(ble_hs_conn) bhc_next;
53 uint8_t bhc_our_addr_type;
54#if MYNEWT_VAL(BLE_EXT_ADV)
55 uint8_t bhc_our_rnd_addr[6];
57 ble_addr_t bhc_peer_addr;
58 ble_addr_t bhc_our_rpa_addr;
59 ble_addr_t bhc_peer_rpa_addr;
63 uint16_t bhc_supervision_timeout;
64 uint8_t bhc_master_clock_accuracy;
66 uint32_t supported_feat;
68 ble_hs_conn_flags_t bhc_flags;
70 struct ble_l2cap_chan_list bhc_channels;
71 struct ble_l2cap_chan *bhc_rx_chan;
72 ble_npl_time_t bhc_rx_timeout;
73#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
74 uint32_t l2cap_coc_cid_mask[BLE_HS_CONN_L2CAP_COC_CID_MASK_LEN];
81 uint16_t bhc_outstanding_pkts;
83#if MYNEWT_VAL(BLE_HS_FLOW_CTRL)
88 uint16_t bhc_completed_pkts;
94 struct ble_att_svr_conn bhc_att_svr;
95 struct ble_gatts_conn bhc_gatt_svr;
99 ble_gap_event_fn *bhc_cb;
102#if MYNEWT_VAL(BLE_PERIODIC_ADV)
103 struct ble_hs_periodic_sync *psync;
107struct ble_hs_conn_addrs {
108 ble_addr_t our_id_addr;
109 ble_addr_t peer_id_addr;
110 ble_addr_t our_ota_addr;
111 ble_addr_t peer_ota_addr;
114int ble_hs_conn_can_alloc(
void);
115struct ble_hs_conn *ble_hs_conn_alloc(uint16_t conn_handle);
116void ble_hs_conn_free(
struct ble_hs_conn *conn);
117void ble_hs_conn_insert(
struct ble_hs_conn *conn);
118void ble_hs_conn_remove(
struct ble_hs_conn *conn);
119struct ble_hs_conn *ble_hs_conn_find(uint16_t conn_handle);
120struct ble_hs_conn *ble_hs_conn_find_assert(uint16_t conn_handle);
121struct ble_hs_conn *ble_hs_conn_find_by_addr(
const ble_addr_t *addr);
122struct ble_hs_conn *ble_hs_conn_find_by_idx(
int idx);
123int ble_hs_conn_exists(uint16_t conn_handle);
124struct ble_hs_conn *ble_hs_conn_first(
void);
125struct ble_l2cap_chan *ble_hs_conn_chan_find_by_scid(
struct ble_hs_conn *conn,
127struct ble_l2cap_chan *ble_hs_conn_chan_find_by_dcid(
struct ble_hs_conn *conn,
129bool ble_hs_conn_chan_exist(
struct ble_hs_conn *conn,
struct ble_l2cap_chan *chan);
130int ble_hs_conn_chan_insert(
struct ble_hs_conn *conn,
131 struct ble_l2cap_chan *chan);
132void ble_hs_conn_delete_chan(
struct ble_hs_conn *conn,
133 struct ble_l2cap_chan *chan);
135void ble_hs_conn_addrs(
const struct ble_hs_conn *conn,
136 struct ble_hs_conn_addrs *addrs);
137int32_t ble_hs_conn_timer(
void);
139typedef int ble_hs_conn_foreach_fn(
struct ble_hs_conn *conn,
void *arg);
140void ble_hs_conn_foreach(ble_hs_conn_foreach_fn *cb,
void *arg);
142int ble_hs_conn_init(
void);