32#define BLE_LL_CTRL_PROC_CONN_UPDATE (0)
33#define BLE_LL_CTRL_PROC_CHAN_MAP_UPD (1)
34#define BLE_LL_CTRL_PROC_ENCRYPT (2)
35#define BLE_LL_CTRL_PROC_FEATURE_XCHG (3)
36#define BLE_LL_CTRL_PROC_VERSION_XCHG (4)
37#define BLE_LL_CTRL_PROC_TERMINATE (5)
38#define BLE_LL_CTRL_PROC_CONN_PARAM_REQ (6)
39#define BLE_LL_CTRL_PROC_LE_PING (7)
40#define BLE_LL_CTRL_PROC_DATA_LEN_UPD (8)
41#define BLE_LL_CTRL_PROC_PHY_UPDATE (9)
42#define BLE_LL_CTRL_PROC_SCA_UPDATE (10)
43#define BLE_LL_CTRL_PROC_CIS_CREATE (11)
44#define BLE_LL_CTRL_PROC_SUBRATE_REQ (12)
45#define BLE_LL_CTRL_PROC_SUBRATE_UPDATE (13)
46#define BLE_LL_CTRL_PROC_NUM (14)
47#define BLE_LL_CTRL_PROC_IDLE (255)
50#define IS_PENDING_CTRL_PROC(sm, proc) (sm->pending_ctrl_procs & (1 << proc))
51#define CLR_PENDING_CTRL_PROC(sm, proc) (sm->pending_ctrl_procs &= ~(1 << proc))
54#define BLE_LL_CTRL_PROC_TIMEOUT_MS (40000)
61#define BLE_LL_CTRL_CONN_UPDATE_IND (0x00)
62#define BLE_LL_CTRL_CHANNEL_MAP_REQ (0x01)
63#define BLE_LL_CTRL_TERMINATE_IND (0x02)
64#define BLE_LL_CTRL_ENC_REQ (0x03)
65#define BLE_LL_CTRL_ENC_RSP (0x04)
66#define BLE_LL_CTRL_START_ENC_REQ (0x05)
67#define BLE_LL_CTRL_START_ENC_RSP (0x06)
68#define BLE_LL_CTRL_UNKNOWN_RSP (0x07)
69#define BLE_LL_CTRL_FEATURE_REQ (0x08)
70#define BLE_LL_CTRL_FEATURE_RSP (0x09)
71#define BLE_LL_CTRL_PAUSE_ENC_REQ (0x0A)
72#define BLE_LL_CTRL_PAUSE_ENC_RSP (0x0B)
73#define BLE_LL_CTRL_VERSION_IND (0x0C)
74#define BLE_LL_CTRL_REJECT_IND (0x0D)
75#define BLE_LL_CTRL_PERIPH_FEATURE_REQ (0x0E)
76#define BLE_LL_CTRL_CONN_PARM_REQ (0x0F)
77#define BLE_LL_CTRL_CONN_PARM_RSP (0x10)
78#define BLE_LL_CTRL_REJECT_IND_EXT (0x11)
79#define BLE_LL_CTRL_PING_REQ (0x12)
80#define BLE_LL_CTRL_PING_RSP (0x13)
81#define BLE_LL_CTRL_LENGTH_REQ (0x14)
82#define BLE_LL_CTRL_LENGTH_RSP (0x15)
83#define BLE_LL_CTRL_PHY_REQ (0x16)
84#define BLE_LL_CTRL_PHY_RSP (0x17)
85#define BLE_LL_CTRL_PHY_UPDATE_IND (0x18)
86#define BLE_LL_CTRL_MIN_USED_CHAN_IND (0x19)
87#define BLE_LL_CTRL_CTE_REQ (0x1A)
88#define BLE_LL_CTRL_CTE_RSP (0x1B)
89#define BLE_LL_CTRL_PERIODIC_SYNC_IND (0x1C)
90#define BLE_LL_CTRL_CLOCK_ACCURACY_REQ (0x1D)
91#define BLE_LL_CTRL_CLOCK_ACCURACY_RSP (0x1E)
92#define BLE_LL_CTRL_CIS_REQ (0x1F)
93#define BLE_LL_CTRL_CIS_RSP (0x20)
94#define BLE_LL_CTRL_CIS_IND (0x21)
95#define BLE_LL_CTRL_CIS_TERMINATE_IND (0x22)
96#define BLE_LL_CTRL_POWER_CONTROL_REQ (0x23)
97#define BLE_LL_CTRL_POWER_CONTROL_RSP (0x24)
98#define BLE_LL_CTRL_POWER_CHANGE_IND (0x25)
99#define BLE_LL_CTRL_SUBRATE_REQ (0x26)
100#define BLE_LL_CTRL_SUBRATE_IND (0x27)
101#define BLE_LL_CTRL_CHAN_REPORTING_IND (0x28)
102#define BLE_LL_CTRL_CHAN_STATUS_IND (0x29)
105#define BLE_LL_CTRL_OPCODES (BLE_LL_CTRL_CHAN_STATUS_IND + 1)
107extern const uint8_t g_ble_ll_ctrl_pkt_lengths[BLE_LL_CTRL_OPCODES];
110#if MYNEWT_VAL(BLE_ISO)
111#define BLE_LL_CTRL_MAX_PDU_LEN (42)
112#elif MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_SYNC_TRANSFER)
113#define BLE_LL_CTRL_MAX_PDU_LEN (35)
115#define BLE_LL_CTRL_MAX_PDU_LEN (27)
119struct ble_ll_conn_upd_req
128#define BLE_LL_CTRL_CONN_UPD_REQ_LEN (11)
131struct ble_ll_chan_map_req
136#define BLE_LL_CTRL_CHAN_MAP_LEN (7)
142#define BLE_LL_CTRL_TERMINATE_IND_LEN (1)
153#define BLE_LL_CTRL_ENC_REQ_LEN (22)
162#define BLE_LL_CTRL_ENC_RSP_LEN (12)
165#define BLE_LL_CTRL_START_ENC_REQ_LEN (0)
166#define BLE_LL_CTRL_START_ENC_RSP_LEN (0)
167#define BLE_LL_CTRL_PAUSE_ENC_REQ_LEN (0)
168#define BLE_LL_CTRL_PAUSE_ENC_RSP_LEN (0)
174#define BLE_LL_CTRL_UNK_RSP_LEN (1)
180#define BLE_LL_CTRL_FEATURE_LEN (8)
191struct ble_ll_version_ind
193 uint8_t ble_ctrlr_ver;
195 uint16_t sub_ver_num;
198#define BLE_LL_CTRL_VERSION_IND_LEN (5)
204#define BLE_LL_CTRL_REJ_IND_LEN (1)
210#define BLE_LL_CTRL_PERIPH_FEATURE_REQ_LEN (8)
213struct ble_ll_conn_params
215 uint16_t interval_min;
216 uint16_t interval_max;
219 uint8_t pref_periodicity;
220 uint16_t ref_conn_event_cnt;
229#define BLE_LL_CTRL_CONN_PARAMS_LEN (23)
232struct ble_ll_reject_ind_ext
234 uint8_t reject_opcode;
238#define BLE_LL_CTRL_REJECT_IND_EXT_LEN (2)
241#define BLE_LL_CTRL_PING_LEN (0)
252 uint16_t max_rx_bytes;
253 uint16_t max_rx_time;
254 uint16_t max_tx_bytes;
255 uint16_t max_tx_time;
258#define BLE_LL_CTRL_LENGTH_REQ_LEN (8)
261#define BLE_LL_CTRL_PHY_REQ_LEN (2)
262#define BLE_LL_CTRL_PHY_RSP_LEN (2)
263#define BLE_LL_CTRL_PHY_UPD_IND_LEN (4)
266#define BLE_LL_CTRL_MIN_USED_CHAN_LEN (2)
269#define BLE_LL_CTRL_CTE_REQ_LEN (1)
272#define BLE_LL_CTRL_CTE_RSP_LEN (0)
275#define BLE_LL_CTRL_PERIODIC_SYNC_IND_LEN (34)
278#define BLE_LL_CTRL_CLOCK_ACCURACY_REQ_LEN (1)
279#define BLE_LL_CTRL_CLOCK_ACCURACY_RSP_LEN (1)
282#define BLE_LL_CTRL_CIS_REQ_LEN (42)
283#define BLE_LL_CTRL_CIS_RSP_LEN (8)
284#define BLE_LL_CTRL_CIS_IND_LEN (15)
285#define BLE_LL_CTRL_CIS_TERMINATE_LEN (3)
287#define BLE_LL_CTRL_POWER_CONTROL_REQ_LEN (3)
288#define BLE_LL_CTRL_POWER_CONTROL_RSP_LEN (4)
289#define BLE_LL_CTRL_POWER_CHANGE_IND_LEN (4)
290#define BLE_LL_CTRL_SUBRATE_REQ_LEN (10)
291#define BLE_LL_CTRL_SUBRATE_IND_LEN (10)
292#define BLE_LL_CTRL_CHAN_REPORTING_IND_LEN (3)
293#define BLE_LL_CTRL_CHAN_STATUS_IND_LEN (10)
296struct ble_ll_conn_sm;
297void ble_ll_ctrl_proc_start(
struct ble_ll_conn_sm *connsm,
int ctrl_proc,
299void ble_ll_ctrl_proc_stop(
struct ble_ll_conn_sm *connsm,
int ctrl_proc);
300int ble_ll_ctrl_rx_pdu(
struct ble_ll_conn_sm *connsm,
struct os_mbuf *om);
301void ble_ll_ctrl_chk_proc_start(
struct ble_ll_conn_sm *connsm);
302void ble_ll_ctrl_terminate_start(
struct ble_ll_conn_sm *connsm);
303int ble_ll_ctrl_is_terminate_ind(uint8_t hdr, uint8_t opcode);
304uint8_t ble_ll_ctrl_conn_param_reply(
struct ble_ll_conn_sm *connsm,
306 struct ble_ll_conn_params *req);
307int ble_ll_ctrl_reject_ind_send(
struct ble_ll_conn_sm *connsm,
308 uint8_t rej_opcode, uint8_t err);
309int ble_ll_ctrl_start_enc_send(
struct ble_ll_conn_sm *connsm);
310int ble_ll_ctrl_enc_allowed_pdu_rx(
struct os_mbuf *rxpdu);
312int ble_ll_ctrl_tx_start(
struct ble_ll_conn_sm *connsm,
struct os_mbuf *txpdu);
313int ble_ll_ctrl_tx_done(
struct os_mbuf *txpdu,
struct ble_ll_conn_sm *connsm);
314int ble_ll_ctrl_is_start_enc_rsp(
struct os_mbuf *txpdu);
316void ble_ll_hci_ev_datalen_chg(
struct ble_ll_conn_sm *connsm);
317void ble_ll_hci_ev_rem_conn_parm_req(
struct ble_ll_conn_sm *connsm,
318 struct ble_ll_conn_params *cp);
319void ble_ll_hci_ev_conn_update(
struct ble_ll_conn_sm *connsm, uint8_t status);
320void ble_ll_hci_ev_rd_rem_used_feat(
struct ble_ll_conn_sm *connsm,
322void ble_ll_hci_ev_rd_rem_ver(
struct ble_ll_conn_sm *connsm, uint8_t status);
323void ble_ll_hci_ev_encrypt_chg(
struct ble_ll_conn_sm *connsm, uint8_t status);
324int ble_ll_hci_ev_ltk_req(
struct ble_ll_conn_sm *connsm);
325int ble_ll_hci_ev_hw_err(uint8_t hw_err);
326void ble_ll_hci_ev_databuf_overflow(
void);
327void ble_ll_hci_ev_le_csa(
struct ble_ll_conn_sm *connsm);
328void ble_ll_hci_ev_send_scan_req_recv(uint8_t adv_handle,
const uint8_t *peer,
329 uint8_t peer_addr_type);
330void ble_ll_hci_ev_send_scan_timeout(
void);
331void ble_ll_hci_ev_send_adv_set_terminated(uint8_t status, uint8_t adv_handle,
332 uint16_t conn_handle, uint8_t events);
333int ble_ll_hci_ev_phy_update(
struct ble_ll_conn_sm *connsm, uint8_t status);
334void ble_ll_calc_session_key(
struct ble_ll_conn_sm *connsm);
335void ble_ll_ctrl_phy_update_proc_complete(
struct ble_ll_conn_sm *connsm);
336void ble_ll_ctrl_initiate_dle(
struct ble_ll_conn_sm *connsm);
337void ble_ll_hci_ev_send_vs_assert(
const char *file, uint32_t line);
338void ble_ll_hci_ev_send_vs_llcp_trace(uint8_t type, uint16_t handle, uint16_t count,
339 void *pdu,
size_t length);
341uint8_t ble_ll_ctrl_phy_tx_transition_get(uint8_t phy_mask);
342uint8_t ble_ll_ctrl_phy_from_phy_mask(uint8_t phy_mask);
344#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_SCA_UPDATE)
345void ble_ll_hci_ev_sca_update(
struct ble_ll_conn_sm *connsm,
346 uint8_t status, uint8_t peer_sca);
349#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE)
350void ble_ll_hci_ev_subrate_change(
struct ble_ll_conn_sm *connsm, uint8_t status);