mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-06-06 05:14:45 +00:00
nimble/ll: Cleanup connsm flag names
This commit is contained in:
@@ -100,35 +100,33 @@ struct ble_ll_conn_enc_data
|
||||
/* Connection state machine flags. */
|
||||
struct ble_ll_conn_sm_flags {
|
||||
uint32_t pkt_rxd : 1;
|
||||
uint32_t last_txd_md : 1;
|
||||
uint32_t empty_pdu_txd : 1;
|
||||
uint32_t periph_use_latency : 1;
|
||||
uint32_t periph_set_last_anchor : 1;
|
||||
uint32_t csa2 : 1;
|
||||
uint32_t encrypted : 1;
|
||||
uint32_t encrypt_ltk_req : 1;
|
||||
uint32_t encrypt_event_sent : 1;
|
||||
uint32_t version_ind_txd : 1;
|
||||
uint32_t version_ind_rxd : 1;
|
||||
uint32_t features_rxd : 1;
|
||||
uint32_t features_host_req : 1;
|
||||
uint32_t terminate_started : 1;
|
||||
uint32_t terminate_ind_txd : 1;
|
||||
uint32_t terminate_ind_rxd : 1;
|
||||
uint32_t terminate_ind_rxd_acked : 1;
|
||||
uint32_t allow_periph_latency : 1;
|
||||
uint32_t periph_set_last_anchor : 1;
|
||||
uint32_t awaiting_host_reply : 1;
|
||||
uint32_t terminate_started : 1;
|
||||
uint32_t conn_update_sched : 1;
|
||||
uint32_t conn_update_use_cp : 1;
|
||||
uint32_t host_expects_upd_event : 1;
|
||||
uint32_t version_ind_sent : 1;
|
||||
uint32_t rxd_version_ind : 1;
|
||||
uint32_t chanmap_update_scheduled : 1;
|
||||
uint32_t conn_empty_pdu_txd : 1;
|
||||
uint32_t last_txd_md : 1;
|
||||
uint32_t conn_req_txd : 1;
|
||||
uint32_t send_ltk_req : 1;
|
||||
uint32_t encrypted : 1;
|
||||
uint32_t encrypt_chg_sent : 1;
|
||||
uint32_t conn_update_host_w4reply : 1;
|
||||
uint32_t conn_update_host_w4event : 1;
|
||||
uint32_t chanmap_update_sched : 1;
|
||||
uint32_t phy_update_sched : 1;
|
||||
uint32_t phy_update_self_initiated : 1;
|
||||
uint32_t phy_update_peer_initiated : 1;
|
||||
uint32_t phy_update_host_initiated : 1;
|
||||
uint32_t phy_update_host_w4event : 1;
|
||||
uint32_t le_ping_supp : 1;
|
||||
uint32_t csa2_supp : 1;
|
||||
uint32_t host_phy_update: 1;
|
||||
uint32_t phy_update_sched: 1;
|
||||
uint32_t ctrlr_phy_update: 1;
|
||||
uint32_t phy_update_event: 1;
|
||||
uint32_t peer_phy_update: 1; /* XXX:combine with ctrlr udpate bit? */
|
||||
uint32_t aux_conn_req: 1;
|
||||
uint32_t rxd_features : 1;
|
||||
uint32_t pending_hci_rd_features : 1;
|
||||
#if MYNEWT_VAL(BLE_LL_CONN_INIT_AUTO_DLE)
|
||||
uint32_t pending_initiate_dle : 1;
|
||||
#endif
|
||||
|
||||
@@ -801,7 +801,7 @@ ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn, uint16_t latency)
|
||||
uint8_t index;
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2)
|
||||
if (conn->flags.csa2_supp) {
|
||||
if (conn->flags.csa2) {
|
||||
return ble_ll_utils_dci_csa2(conn->event_cntr, conn->channel_id,
|
||||
conn->chan_map_used, conn->chan_map);
|
||||
}
|
||||
@@ -969,7 +969,7 @@ ble_ll_conn_chk_csm_flags(struct ble_ll_conn_sm *connsm)
|
||||
uint8_t update_status;
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
|
||||
if (connsm->flags.send_ltk_req) {
|
||||
if (connsm->flags.encrypt_ltk_req) {
|
||||
/*
|
||||
* Send Long term key request event to host. If masked, we need to
|
||||
* send a REJECT_IND.
|
||||
@@ -978,7 +978,7 @@ ble_ll_conn_chk_csm_flags(struct ble_ll_conn_sm *connsm)
|
||||
ble_ll_ctrl_reject_ind_send(connsm, BLE_LL_CTRL_ENC_REQ,
|
||||
BLE_ERR_PINKEY_MISSING);
|
||||
}
|
||||
connsm->flags.send_ltk_req = 0;
|
||||
connsm->flags.encrypt_ltk_req = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -988,7 +988,7 @@ ble_ll_conn_chk_csm_flags(struct ble_ll_conn_sm *connsm)
|
||||
* has passed the instant.
|
||||
* 2) We successfully sent the reject reason.
|
||||
*/
|
||||
if (connsm->flags.host_expects_upd_event) {
|
||||
if (connsm->flags.conn_update_host_w4event) {
|
||||
update_status = BLE_ERR_SUCCESS;
|
||||
if (IS_PENDING_CTRL_PROC(connsm, BLE_LL_CTRL_PROC_CONN_UPDATE)) {
|
||||
ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_CONN_UPDATE);
|
||||
@@ -999,15 +999,15 @@ ble_ll_conn_chk_csm_flags(struct ble_ll_conn_sm *connsm)
|
||||
}
|
||||
}
|
||||
ble_ll_hci_ev_conn_update(connsm, update_status);
|
||||
connsm->flags.host_expects_upd_event = 0;
|
||||
connsm->flags.conn_update_host_w4event = 0;
|
||||
}
|
||||
|
||||
/* Check if we need to send PHY update complete event */
|
||||
#if (BLE_LL_BT5_PHY_SUPPORTED == 1)
|
||||
if (connsm->flags.phy_update_event) {
|
||||
if (connsm->flags.phy_update_host_w4event) {
|
||||
if (!ble_ll_hci_ev_phy_update(connsm, BLE_ERR_SUCCESS)) {
|
||||
/* Sent event. Clear flag */
|
||||
connsm->flags.phy_update_event = 0;
|
||||
connsm->flags.phy_update_host_w4event = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1113,7 +1113,7 @@ ble_ll_conn_tx_pdu(struct ble_ll_conn_sm *connsm)
|
||||
/* We just received terminate indication.
|
||||
* Just send empty packet as an ACK
|
||||
*/
|
||||
connsm->flags.conn_empty_pdu_txd = 1;
|
||||
connsm->flags.empty_pdu_txd = 1;
|
||||
goto conn_tx_pdu;
|
||||
}
|
||||
|
||||
@@ -1122,8 +1122,8 @@ ble_ll_conn_tx_pdu(struct ble_ll_conn_sm *connsm)
|
||||
* the transmit queue.
|
||||
*/
|
||||
pkthdr = STAILQ_FIRST(&connsm->conn_txq);
|
||||
if (!connsm->cur_tx_pdu && !connsm->flags.conn_empty_pdu_txd && !pkthdr) {
|
||||
connsm->flags.conn_empty_pdu_txd = 1;
|
||||
if (!connsm->cur_tx_pdu && !connsm->flags.empty_pdu_txd && !pkthdr) {
|
||||
connsm->flags.empty_pdu_txd = 1;
|
||||
goto conn_tx_pdu;
|
||||
}
|
||||
|
||||
@@ -1132,7 +1132,7 @@ ble_ll_conn_tx_pdu(struct ble_ll_conn_sm *connsm)
|
||||
* the connection transmit queue
|
||||
*/
|
||||
cur_offset = 0;
|
||||
if (!connsm->cur_tx_pdu && !connsm->flags.conn_empty_pdu_txd) {
|
||||
if (!connsm->cur_tx_pdu && !connsm->flags.empty_pdu_txd) {
|
||||
/* Convert packet header to mbuf */
|
||||
m = OS_MBUF_PKTHDR_TO_MBUF(pkthdr);
|
||||
nextpkthdr = STAILQ_NEXT(pkthdr, omp_next);
|
||||
@@ -1150,7 +1150,7 @@ ble_ll_conn_tx_pdu(struct ble_ll_conn_sm *connsm)
|
||||
((connsm->enc_data.enc_state > CONN_ENC_S_ENC_RSP_TO_BE_SENT) &&
|
||||
CONN_IS_PERIPHERAL(connsm))) {
|
||||
if (!ble_ll_ctrl_enc_allowed_pdu_tx(pkthdr)) {
|
||||
connsm->flags.conn_empty_pdu_txd = 1;
|
||||
connsm->flags.empty_pdu_txd = 1;
|
||||
goto conn_tx_pdu;
|
||||
}
|
||||
|
||||
@@ -1292,7 +1292,7 @@ ble_ll_conn_tx_pdu(struct ble_ll_conn_sm *connsm)
|
||||
|
||||
/* If we send an empty PDU we need to initialize the header */
|
||||
conn_tx_pdu:
|
||||
if (connsm->flags.conn_empty_pdu_txd) {
|
||||
if (connsm->flags.empty_pdu_txd) {
|
||||
/*
|
||||
* This looks strange, but we dont use the data pointer in the mbuf
|
||||
* when we have an empty pdu.
|
||||
@@ -1448,7 +1448,7 @@ conn_tx_pdu:
|
||||
connsm->flags.last_txd_md = md;
|
||||
|
||||
/* Increment packets transmitted */
|
||||
if (connsm->flags.conn_empty_pdu_txd) {
|
||||
if (connsm->flags.empty_pdu_txd) {
|
||||
if (connsm->flags.terminate_ind_rxd) {
|
||||
connsm->flags.terminate_ind_rxd_acked = 1;
|
||||
}
|
||||
@@ -1945,7 +1945,7 @@ ble_ll_conn_set_csa(struct ble_ll_conn_sm *connsm, bool chsel)
|
||||
{
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2)
|
||||
if (chsel) {
|
||||
connsm->flags.csa2_supp = 1;
|
||||
connsm->flags.csa2 = 1;
|
||||
connsm->channel_id = ((connsm->access_addr & 0xffff0000) >> 16) ^
|
||||
(connsm->access_addr & 0x0000ffff);
|
||||
|
||||
@@ -2239,19 +2239,19 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
|
||||
* If we have features and there's pending HCI command, send an event before
|
||||
* disconnection event so it does make sense to host.
|
||||
*/
|
||||
if (connsm->flags.pending_hci_rd_features &&
|
||||
connsm->flags.rxd_features) {
|
||||
if (connsm->flags.features_host_req &&
|
||||
connsm->flags.features_rxd) {
|
||||
ble_ll_hci_ev_rd_rem_used_feat(connsm, BLE_ERR_SUCCESS);
|
||||
connsm->flags.pending_hci_rd_features = 0;
|
||||
connsm->flags.features_host_req = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If there is still pending read features request HCI command, send an
|
||||
* event to complete it.
|
||||
*/
|
||||
if (connsm->flags.pending_hci_rd_features) {
|
||||
if (connsm->flags.features_host_req) {
|
||||
ble_ll_hci_ev_rd_rem_used_feat(connsm, ble_err);
|
||||
connsm->flags.pending_hci_rd_features = 0;
|
||||
connsm->flags.features_host_req = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2263,7 +2263,7 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
|
||||
* received and we should not send an event.
|
||||
*/
|
||||
if (ble_err && (ble_err != BLE_ERR_UNK_CONN_ID ||
|
||||
connsm->flags.terminate_ind_rxd)) {
|
||||
connsm->flags.terminate_ind_rxd)) {
|
||||
ble_ll_disconn_comp_event_send(connsm, ble_err);
|
||||
}
|
||||
|
||||
@@ -2413,10 +2413,10 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
|
||||
/* Set event counter to the next connection event that we will tx/rx in */
|
||||
|
||||
use_periph_latency = next_is_subrated &&
|
||||
connsm->flags.allow_periph_latency &&
|
||||
connsm->flags.periph_use_latency &&
|
||||
!connsm->flags.conn_update_sched &&
|
||||
!connsm->flags.phy_update_sched &&
|
||||
!connsm->flags.chanmap_update_scheduled &&
|
||||
!connsm->flags.chanmap_update_sched &&
|
||||
connsm->flags.pkt_rxd;
|
||||
|
||||
if (next_is_subrated) {
|
||||
@@ -2535,7 +2535,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
|
||||
(connsm->conn_itvl != upd->interval) ||
|
||||
(connsm->periph_latency != upd->latency) ||
|
||||
(connsm->supervision_tmo != upd->timeout)) {
|
||||
connsm->flags.host_expects_upd_event = 1;
|
||||
connsm->flags.conn_update_host_w4event = 1;
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE)
|
||||
@@ -2614,7 +2614,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
|
||||
* new channel map once the event counter equals or has passed channel
|
||||
* map update instant.
|
||||
*/
|
||||
if (connsm->flags.chanmap_update_scheduled &&
|
||||
if (connsm->flags.chanmap_update_sched &&
|
||||
((int16_t)(connsm->chanmap_instant - connsm->event_cntr) <= 0)) {
|
||||
|
||||
/* XXX: there is a chance that the control packet is still on
|
||||
@@ -2625,7 +2625,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
|
||||
ble_ll_utils_chan_map_used_get(connsm->req_chanmap);
|
||||
memcpy(connsm->chan_map, connsm->req_chanmap, BLE_LL_CHAN_MAP_LEN);
|
||||
|
||||
connsm->flags.chanmap_update_scheduled = 0;
|
||||
connsm->flags.chanmap_update_sched = 0;
|
||||
|
||||
ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_CHAN_MAP_UPD);
|
||||
|
||||
@@ -2660,7 +2660,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
|
||||
|
||||
/* Clear flags and set flag to send event at next instant */
|
||||
connsm->flags.phy_update_sched = 0;
|
||||
connsm->flags.phy_update_event = 1;
|
||||
connsm->flags.phy_update_host_w4event = 1;
|
||||
|
||||
ble_ll_ctrl_phy_update_proc_complete(connsm);
|
||||
|
||||
@@ -2856,7 +2856,7 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, struct ble_mbuf_hdr *rxhdr)
|
||||
* the other side can support it?
|
||||
*/
|
||||
if (!ble_ll_conn_phy_update_if_needed(connsm)) {
|
||||
connsm->flags.ctrlr_phy_update = 1;
|
||||
connsm->flags.phy_update_self_initiated = 1;
|
||||
}
|
||||
#endif
|
||||
switch (connsm->conn_role) {
|
||||
@@ -3030,10 +3030,10 @@ ble_ll_conn_event_end(struct ble_npl_event *ev)
|
||||
ble_ll_conn_num_comp_pkts_event_send(connsm);
|
||||
|
||||
/* If we have features and there's pending HCI command, send an event */
|
||||
if (connsm->flags.pending_hci_rd_features &&
|
||||
connsm->flags.rxd_features) {
|
||||
if (connsm->flags.features_host_req &&
|
||||
connsm->flags.features_rxd) {
|
||||
ble_ll_hci_ev_rd_rem_used_feat(connsm, BLE_ERR_SUCCESS);
|
||||
connsm->flags.pending_hci_rd_features = 0;
|
||||
connsm->flags.features_host_req = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3519,7 +3519,7 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
|
||||
#if MYNEWT_VAL(BLE_LL_ROLE_PERIPHERAL)
|
||||
if (connsm->conn_role == BLE_LL_CONN_ROLE_PERIPHERAL) {
|
||||
if (hdr_byte & BLE_LL_DATA_HDR_NESN_MASK) {
|
||||
connsm->flags.allow_periph_latency = 1;
|
||||
connsm->flags.periph_use_latency = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -3773,7 +3773,7 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
|
||||
* Check NESN bit from header. If same as tx seq num, the transmission
|
||||
* is acknowledged. Otherwise we need to resend this PDU.
|
||||
*/
|
||||
if (connsm->flags.conn_empty_pdu_txd || connsm->cur_tx_pdu) {
|
||||
if (connsm->flags.empty_pdu_txd || connsm->cur_tx_pdu) {
|
||||
hdr_nesn = hdr_byte & BLE_LL_DATA_HDR_NESN_MASK;
|
||||
conn_sn = connsm->tx_seqnum;
|
||||
if ((hdr_nesn && conn_sn) || (!hdr_nesn && !conn_sn)) {
|
||||
@@ -3785,8 +3785,8 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
|
||||
STATS_INC(ble_ll_conn_stats, data_pdu_txg);
|
||||
|
||||
/* If we transmitted the empty pdu, clear flag */
|
||||
if (connsm->flags.conn_empty_pdu_txd) {
|
||||
connsm->flags.conn_empty_pdu_txd = 0;
|
||||
if (connsm->flags.empty_pdu_txd) {
|
||||
connsm->flags.empty_pdu_txd = 0;
|
||||
goto chk_rx_terminate_ind;
|
||||
}
|
||||
|
||||
|
||||
@@ -921,7 +921,7 @@ ble_ll_conn_hci_read_rem_features(const uint8_t *cmdbuf, uint8_t len)
|
||||
}
|
||||
|
||||
/* If already pending exit with error */
|
||||
if (connsm->flags.pending_hci_rd_features) {
|
||||
if (connsm->flags.features_host_req) {
|
||||
return BLE_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
|
||||
@@ -929,7 +929,7 @@ ble_ll_conn_hci_read_rem_features(const uint8_t *cmdbuf, uint8_t len)
|
||||
* Start control procedure if we did not receive peer's features and did not
|
||||
* start procedure already.
|
||||
*/
|
||||
if (!connsm->flags.rxd_features &&
|
||||
if (!connsm->flags.features_rxd &&
|
||||
!IS_PENDING_CTRL_PROC(connsm, BLE_LL_CTRL_PROC_FEATURE_XCHG)) {
|
||||
#if MYNEWT_VAL(BLE_LL_ROLE_PERIPHERAL)
|
||||
if ((connsm->conn_role == BLE_LL_CONN_ROLE_PERIPHERAL) &&
|
||||
@@ -941,7 +941,7 @@ ble_ll_conn_hci_read_rem_features(const uint8_t *cmdbuf, uint8_t len)
|
||||
ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_FEATURE_XCHG, NULL);
|
||||
}
|
||||
|
||||
connsm->flags.pending_hci_rd_features = 1;
|
||||
connsm->flags.features_host_req = 1;
|
||||
|
||||
return BLE_ERR_SUCCESS;
|
||||
}
|
||||
@@ -1062,11 +1062,11 @@ ble_ll_conn_hci_update(const uint8_t *cmdbuf, uint8_t len)
|
||||
* peripheral has initiated the procedure, we need to send a reject to the
|
||||
* peripheral.
|
||||
*/
|
||||
if (connsm->flags.awaiting_host_reply) {
|
||||
if (connsm->flags.conn_update_host_w4reply) {
|
||||
switch (connsm->conn_role) {
|
||||
#if MYNEWT_VAL(BLE_LL_ROLE_CENTRAL)
|
||||
case BLE_LL_CONN_ROLE_CENTRAL:
|
||||
connsm->flags.awaiting_host_reply = 0;
|
||||
connsm->flags.conn_update_host_w4reply = 0;
|
||||
|
||||
/* XXX: If this fails no reject ind will be sent! */
|
||||
ble_ll_ctrl_reject_ind_send(connsm, connsm->host_reply_opcode,
|
||||
@@ -1089,7 +1089,7 @@ ble_ll_conn_hci_update(const uint8_t *cmdbuf, uint8_t len)
|
||||
* update procedure we should deny the peripheral request for now.
|
||||
*/
|
||||
#if MYNEWT_VAL(BLE_LL_ROLE_PERIPHERAL)
|
||||
if (connsm->flags.chanmap_update_scheduled) {
|
||||
if (connsm->flags.chanmap_update_sched) {
|
||||
if (connsm->conn_role == BLE_LL_CONN_ROLE_PERIPHERAL) {
|
||||
return BLE_ERR_DIFF_TRANS_COLL;
|
||||
}
|
||||
@@ -1159,7 +1159,7 @@ ble_ll_conn_hci_param_rr(const uint8_t *cmdbuf, uint8_t len,
|
||||
rc = ble_ll_conn_process_conn_params(cmd, connsm);
|
||||
|
||||
/* The connection should be awaiting a reply. If not, just discard */
|
||||
if (connsm->flags.awaiting_host_reply) {
|
||||
if (connsm->flags.conn_update_host_w4reply) {
|
||||
/* Get a control packet buffer */
|
||||
if (rc == BLE_ERR_SUCCESS) {
|
||||
om = os_msys_get_pkthdr(BLE_LL_CTRL_MAX_PDU_LEN,
|
||||
@@ -1177,7 +1177,7 @@ ble_ll_conn_hci_param_rr(const uint8_t *cmdbuf, uint8_t len,
|
||||
ble_ll_ctrl_reject_ind_send(connsm, connsm->host_reply_opcode,
|
||||
BLE_ERR_CONN_PARMS);
|
||||
}
|
||||
connsm->flags.awaiting_host_reply = 0;
|
||||
connsm->flags.conn_update_host_w4reply = 0;
|
||||
|
||||
/* XXX: if we cant get a buffer, what do we do? We need to remember
|
||||
* reason if it was a negative reply. We also would need to have
|
||||
@@ -1224,11 +1224,11 @@ ble_ll_conn_hci_param_nrr(const uint8_t *cmdbuf, uint8_t len,
|
||||
rc = BLE_ERR_SUCCESS;
|
||||
|
||||
/* The connection should be awaiting a reply. If not, just discard */
|
||||
if (connsm->flags.awaiting_host_reply) {
|
||||
if (connsm->flags.conn_update_host_w4reply) {
|
||||
/* XXX: check return code and deal */
|
||||
ble_ll_ctrl_reject_ind_send(connsm, connsm->host_reply_opcode,
|
||||
cmd->reason);
|
||||
connsm->flags.awaiting_host_reply = 0;
|
||||
connsm->flags.conn_update_host_w4reply = 0;
|
||||
|
||||
/* XXX: if we cant get a buffer, what do we do? We need to remember
|
||||
* reason if it was a negative reply. We also would need to have
|
||||
@@ -1393,7 +1393,7 @@ ble_ll_conn_hci_rd_rem_ver_cmd(const uint8_t *cmdbuf, uint8_t len)
|
||||
* NOTE: we cant just send the event here. That would cause the event to
|
||||
* be queued before the command status.
|
||||
*/
|
||||
if (!connsm->flags.version_ind_sent) {
|
||||
if (!connsm->flags.version_ind_txd) {
|
||||
ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_VERSION_XCHG, NULL);
|
||||
} else {
|
||||
connsm->pending_ctrl_procs |= (1 << BLE_LL_CTRL_PROC_VERSION_XCHG);
|
||||
@@ -1468,7 +1468,7 @@ ble_ll_conn_hci_rd_chan_map(const uint8_t *cmdbuf, uint8_t len,
|
||||
rc = BLE_ERR_UNK_CONN_ID;
|
||||
memset(rsp->chan_map, 0, sizeof(rsp->chan_map));
|
||||
} else {
|
||||
if (connsm->flags.chanmap_update_scheduled) {
|
||||
if (connsm->flags.chanmap_update_sched) {
|
||||
memcpy(rsp->chan_map, connsm->req_chanmap, BLE_LL_CHAN_MAP_LEN);
|
||||
} else {
|
||||
memcpy(rsp->chan_map, connsm->chan_map, BLE_LL_CHAN_MAP_LEN);
|
||||
@@ -1990,7 +1990,7 @@ ble_ll_conn_hci_le_set_phy(const uint8_t *cmdbuf, uint8_t len)
|
||||
* If host has requested a PHY update and we are not finished do
|
||||
* not allow another one
|
||||
*/
|
||||
if (connsm->flags.host_phy_update) {
|
||||
if (connsm->flags.phy_update_host_initiated) {
|
||||
return BLE_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
|
||||
@@ -2019,9 +2019,9 @@ ble_ll_conn_hci_le_set_phy(const uint8_t *cmdbuf, uint8_t len)
|
||||
*/
|
||||
if (IS_PENDING_CTRL_PROC(connsm, BLE_LL_CTRL_PROC_PHY_UPDATE)) {
|
||||
if (connsm->cur_ctrl_proc != BLE_LL_CTRL_PROC_PHY_UPDATE) {
|
||||
connsm->flags.ctrlr_phy_update = 0;
|
||||
connsm->flags.phy_update_self_initiated = 0;
|
||||
}
|
||||
connsm->flags.host_phy_update = 1;
|
||||
connsm->flags.phy_update_host_initiated = 1;
|
||||
} else {
|
||||
/*
|
||||
* We could be doing a peer-initiated PHY update procedure. If this
|
||||
@@ -2029,20 +2029,20 @@ ble_ll_conn_hci_le_set_phy(const uint8_t *cmdbuf, uint8_t len)
|
||||
* we are not done with a peer-initiated procedure we just set the
|
||||
* pending bit but do not start the control procedure.
|
||||
*/
|
||||
if (connsm->flags.peer_phy_update) {
|
||||
if (connsm->flags.phy_update_peer_initiated) {
|
||||
connsm->pending_ctrl_procs |= (1 << BLE_LL_CTRL_PROC_PHY_UPDATE);
|
||||
connsm->flags.host_phy_update = 1;
|
||||
connsm->flags.phy_update_host_initiated = 1;
|
||||
} else {
|
||||
/* Check if we should start phy update procedure */
|
||||
if (!ble_ll_conn_phy_update_if_needed(connsm)) {
|
||||
connsm->flags.host_phy_update = 1;
|
||||
connsm->flags.phy_update_host_initiated = 1;
|
||||
} else {
|
||||
/*
|
||||
* Set flag to send a PHY update complete event. We set flag
|
||||
* even if we do not do an update procedure since we have to
|
||||
* inform the host even if we decide not to change anything.
|
||||
*/
|
||||
connsm->flags.phy_update_event = 1;
|
||||
connsm->flags.phy_update_host_w4event = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,13 +198,13 @@ ble_ll_ctrl_phy_update_cancel(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
|
||||
CLR_PENDING_CTRL_PROC(connsm, BLE_LL_CTRL_PROC_PHY_UPDATE);
|
||||
|
||||
/* Check if the host wants an event */
|
||||
if (connsm->flags.host_phy_update) {
|
||||
if (connsm->flags.phy_update_host_initiated) {
|
||||
ble_ll_hci_ev_phy_update(connsm, ble_err);
|
||||
connsm->flags.host_phy_update = 0;
|
||||
connsm->flags.phy_update_host_initiated = 0;
|
||||
}
|
||||
|
||||
/* Clear any bits for phy updates that might be in progress */
|
||||
connsm->flags.ctrlr_phy_update = 0;
|
||||
connsm->flags.phy_update_self_initiated = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -367,7 +367,7 @@ conn_parm_req_do_indicate:
|
||||
*/
|
||||
ble_ll_hci_ev_rem_conn_parm_req(connsm, req);
|
||||
connsm->host_reply_opcode = opcode;
|
||||
connsm->flags.awaiting_host_reply = 1;
|
||||
connsm->flags.conn_update_host_w4reply = 1;
|
||||
rsp_opcode = 255;
|
||||
} else {
|
||||
/* Create reply to connection request */
|
||||
@@ -570,11 +570,11 @@ ble_ll_ctrl_proc_unk_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr, uint8_t *
|
||||
if (ctrl_proc == BLE_LL_CTRL_PROC_CONN_PARAM_REQ) {
|
||||
ble_ll_hci_ev_conn_update(connsm, BLE_ERR_UNSUPP_REM_FEATURE);
|
||||
} else if (ctrl_proc == BLE_LL_CTRL_PROC_FEATURE_XCHG) {
|
||||
if (connsm->flags.pending_hci_rd_features) {
|
||||
if (connsm->flags.features_host_req) {
|
||||
ble_ll_hci_ev_rd_rem_used_feat(connsm,
|
||||
BLE_ERR_UNSUPP_REM_FEATURE);
|
||||
}
|
||||
connsm->flags.pending_hci_rd_features = 0;
|
||||
connsm->flags.features_host_req = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,24 +687,24 @@ ble_ll_ctrl_phy_update_proc_complete(struct ble_ll_conn_sm *connsm)
|
||||
|
||||
connsm->phy_tx_transition = 0;
|
||||
|
||||
if (connsm->flags.peer_phy_update) {
|
||||
connsm->flags.peer_phy_update = 0;
|
||||
} else if (connsm->flags.ctrlr_phy_update) {
|
||||
connsm->flags.ctrlr_phy_update = 0;
|
||||
if (connsm->flags.phy_update_peer_initiated) {
|
||||
connsm->flags.phy_update_peer_initiated = 0;
|
||||
} else if (connsm->flags.phy_update_self_initiated) {
|
||||
connsm->flags.phy_update_self_initiated = 0;
|
||||
} else {
|
||||
/* Must be a host-initiated update */
|
||||
connsm->flags.host_phy_update = 0;
|
||||
connsm->flags.phy_update_host_initiated = 0;
|
||||
chk_host_phy = 0;
|
||||
if (connsm->flags.phy_update_event == 0) {
|
||||
if (connsm->flags.phy_update_host_w4event == 0) {
|
||||
ble_ll_hci_ev_phy_update(connsm, BLE_ERR_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
/* Must check if we need to start host procedure */
|
||||
if (chk_host_phy) {
|
||||
if (connsm->flags.host_phy_update) {
|
||||
if (connsm->flags.phy_update_host_initiated) {
|
||||
if (ble_ll_conn_phy_update_if_needed(connsm)) {
|
||||
connsm->flags.host_phy_update = 0;
|
||||
connsm->flags.phy_update_host_initiated = 0;
|
||||
} else {
|
||||
chk_proc_stop = 0;
|
||||
}
|
||||
@@ -829,14 +829,14 @@ ble_ll_ctrl_phy_update_ind_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
|
||||
* one running.
|
||||
*/
|
||||
if ((m_to_s == 0) && (s_to_m == 0)) {
|
||||
if (connsm->flags.peer_phy_update) {
|
||||
connsm->flags.peer_phy_update = 0;
|
||||
} else if (connsm->flags.ctrlr_phy_update) {
|
||||
connsm->flags.ctrlr_phy_update = 0;
|
||||
if (connsm->flags.phy_update_peer_initiated) {
|
||||
connsm->flags.phy_update_peer_initiated = 0;
|
||||
} else if (connsm->flags.phy_update_self_initiated) {
|
||||
connsm->flags.phy_update_self_initiated = 0;
|
||||
ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_PHY_UPDATE);
|
||||
} else {
|
||||
ble_ll_hci_ev_phy_update(connsm, BLE_ERR_SUCCESS);
|
||||
connsm->flags.host_phy_update = 0;
|
||||
connsm->flags.phy_update_host_initiated = 0;
|
||||
ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_PHY_UPDATE);
|
||||
}
|
||||
instant = 0;
|
||||
@@ -921,7 +921,7 @@ ble_ll_ctrl_rx_phy_req(struct ble_ll_conn_sm *connsm, uint8_t *req,
|
||||
* NOTE: do not change order of these two lines as the call to
|
||||
* make the LL_PHY_UPDATE_IND pdu might clear the flag.
|
||||
*/
|
||||
connsm->flags.peer_phy_update = 1;
|
||||
connsm->flags.phy_update_peer_initiated = 1;
|
||||
ble_ll_ctrl_phy_update_ind_make(connsm, req, rsp, 1);
|
||||
rsp_opcode = BLE_LL_CTRL_PHY_UPDATE_IND;
|
||||
}
|
||||
@@ -940,14 +940,14 @@ ble_ll_ctrl_rx_phy_req(struct ble_ll_conn_sm *connsm, uint8_t *req,
|
||||
ble_ll_ctrl_phy_update_cancel(connsm, err);
|
||||
|
||||
/* XXX: ? Should not be any phy update events */
|
||||
connsm->flags.phy_update_event = 0;
|
||||
connsm->flags.phy_update_host_w4event = 0;
|
||||
}
|
||||
|
||||
/* XXX: TODO: if we started another procedure with an instant
|
||||
* why are we doing this? Need to look into this.*/
|
||||
|
||||
/* Respond to central's phy update procedure */
|
||||
connsm->flags.peer_phy_update = 1;
|
||||
connsm->flags.phy_update_peer_initiated = 1;
|
||||
ble_ll_ctrl_phy_req_rsp_make(connsm, rsp);
|
||||
rsp_opcode = BLE_LL_CTRL_PHY_RSP;
|
||||
|
||||
@@ -1875,7 +1875,7 @@ static void
|
||||
ble_ll_ctrl_version_ind_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
|
||||
{
|
||||
/* Set flag to denote we have sent/received this */
|
||||
connsm->flags.version_ind_sent = 1;
|
||||
connsm->flags.version_ind_txd = 1;
|
||||
|
||||
/* Fill out response */
|
||||
pyld[0] = BLE_HCI_VER_BCS;
|
||||
@@ -1901,7 +1901,7 @@ ble_ll_ctrl_chanmap_req_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
|
||||
put_le16(pyld + BLE_LL_CHAN_MAP_LEN, connsm->chanmap_instant);
|
||||
|
||||
/* Set scheduled flag */
|
||||
connsm->flags.chanmap_update_scheduled = 1;
|
||||
connsm->flags.chanmap_update_sched = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2125,7 +2125,7 @@ ble_ll_ctrl_update_features(struct ble_ll_conn_sm *connsm, uint8_t *feat)
|
||||
memcpy(connsm->remote_features, feat + 1, 7);
|
||||
|
||||
/* If we received peer's features for the 1st time, we should try DLE */
|
||||
if (!connsm->flags.rxd_features) {
|
||||
if (!connsm->flags.features_rxd) {
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CODED_PHY)
|
||||
/*
|
||||
* If connection was established on uncoded PHY, by default we use
|
||||
@@ -2154,7 +2154,7 @@ ble_ll_ctrl_update_features(struct ble_ll_conn_sm *connsm, uint8_t *feat)
|
||||
connsm->flags.pending_initiate_dle = 1;
|
||||
#endif
|
||||
|
||||
connsm->flags.rxd_features = 1;
|
||||
connsm->flags.features_rxd = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2234,9 +2234,9 @@ ble_ll_ctrl_rx_feature_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
|
||||
}
|
||||
|
||||
/* Send event to host if pending features read */
|
||||
if (connsm->flags.pending_hci_rd_features) {
|
||||
if (connsm->flags.features_host_req) {
|
||||
ble_ll_hci_ev_rd_rem_used_feat(connsm, BLE_ERR_SUCCESS);
|
||||
connsm->flags.pending_hci_rd_features = 0;
|
||||
connsm->flags.features_host_req = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2265,7 +2265,7 @@ ble_ll_ctrl_rx_conn_param_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
|
||||
* well. This is not expected to happen anyway. A return of BLE_ERR_MAX
|
||||
* means that we will simply discard the connection parameter request
|
||||
*/
|
||||
if (connsm->flags.awaiting_host_reply) {
|
||||
if (connsm->flags.conn_update_host_w4reply) {
|
||||
return BLE_ERR_MAX;
|
||||
}
|
||||
|
||||
@@ -2326,7 +2326,7 @@ ble_ll_ctrl_rx_conn_param_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
|
||||
*/
|
||||
#if MYNEWT_VAL(BLE_LL_ROLE_CENTRAL)
|
||||
if ((connsm->conn_role == BLE_LL_CONN_ROLE_CENTRAL) &&
|
||||
(connsm->flags.chanmap_update_scheduled)) {
|
||||
(connsm->flags.chanmap_update_sched)) {
|
||||
rsp_opcode = BLE_LL_CTRL_REJECT_IND_EXT;
|
||||
rspbuf[1] = BLE_LL_CTRL_CONN_PARM_REQ;
|
||||
rspbuf[2] = BLE_ERR_DIFF_TRANS_COLL;
|
||||
@@ -2359,8 +2359,8 @@ ble_ll_ctrl_rx_conn_param_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
|
||||
* state just clear the awaiting reply. The peripheral will hopefully stop its
|
||||
* procedure when we reply.
|
||||
*/
|
||||
if (connsm->flags.awaiting_host_reply) {
|
||||
connsm->flags.awaiting_host_reply = 0;
|
||||
if (connsm->flags.conn_update_host_w4reply) {
|
||||
connsm->flags.conn_update_host_w4reply = 0;
|
||||
}
|
||||
|
||||
/* If we receive a response and no procedure is pending, just leave */
|
||||
@@ -2395,10 +2395,10 @@ ble_ll_ctrl_rx_version_ind(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
|
||||
connsm->vers_nr = dptr[0];
|
||||
connsm->comp_id = get_le16(dptr + 1);
|
||||
connsm->sub_vers_nr = get_le16(dptr + 3);
|
||||
connsm->flags.rxd_version_ind = 1;
|
||||
connsm->flags.version_ind_rxd = 1;
|
||||
|
||||
rsp_opcode = BLE_ERR_MAX;
|
||||
if (!connsm->flags.version_ind_sent) {
|
||||
if (!connsm->flags.version_ind_txd) {
|
||||
rsp_opcode = BLE_LL_CTRL_VERSION_IND;
|
||||
ble_ll_ctrl_version_ind_make(connsm, rspbuf);
|
||||
}
|
||||
@@ -2439,7 +2439,7 @@ ble_ll_ctrl_rx_chanmap_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
|
||||
} else {
|
||||
connsm->chanmap_instant = instant;
|
||||
memcpy(connsm->req_chanmap, dptr, BLE_LL_CHAN_MAP_LEN);
|
||||
connsm->flags.chanmap_update_scheduled = 1;
|
||||
connsm->flags.chanmap_update_sched = 1;
|
||||
}
|
||||
|
||||
return BLE_ERR_MAX;
|
||||
@@ -2734,7 +2734,7 @@ ble_ll_ctrl_chk_proc_start(struct ble_ll_conn_sm *connsm)
|
||||
* received the information dont start it.
|
||||
*/
|
||||
if ((i == BLE_LL_CTRL_PROC_VERSION_XCHG) &&
|
||||
(connsm->flags.rxd_version_ind)) {
|
||||
(connsm->flags.version_ind_rxd)) {
|
||||
ble_ll_hci_ev_rd_rem_ver(connsm, BLE_ERR_SUCCESS);
|
||||
CLR_PENDING_CTRL_PROC(connsm, i);
|
||||
} else {
|
||||
@@ -3184,7 +3184,7 @@ ble_ll_ctrl_tx_done(struct os_mbuf *txpdu, struct ble_ll_conn_sm *connsm)
|
||||
if (txpdu->om_data[1] == BLE_LL_CTRL_CONN_PARM_REQ &&
|
||||
txpdu->om_data[2] != BLE_ERR_LMP_COLLISION) {
|
||||
connsm->reject_reason = txpdu->om_data[2];
|
||||
connsm->flags.host_expects_upd_event = 1;
|
||||
connsm->flags.conn_update_host_w4event = 1;
|
||||
}
|
||||
}
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
|
||||
@@ -3206,7 +3206,7 @@ ble_ll_ctrl_tx_done(struct os_mbuf *txpdu, struct ble_ll_conn_sm *connsm)
|
||||
break;
|
||||
case BLE_LL_CTRL_ENC_RSP:
|
||||
connsm->enc_data.enc_state = CONN_ENC_S_LTK_REQ_WAIT;
|
||||
connsm->flags.send_ltk_req = 1;
|
||||
connsm->flags.encrypt_ltk_req = 1;
|
||||
break;
|
||||
#if MYNEWT_VAL(BLE_LL_ROLE_PERIPHERAL)
|
||||
case BLE_LL_CTRL_START_ENC_RSP:
|
||||
|
||||
@@ -135,7 +135,7 @@ ble_ll_hci_ev_encrypt_chg(struct ble_ll_conn_sm *connsm, uint8_t status)
|
||||
struct ble_hci_ev_enrypt_chg *ev_enc_chf;
|
||||
struct ble_hci_ev *hci_ev;
|
||||
|
||||
if (connsm->flags.encrypt_chg_sent == 0) {
|
||||
if (connsm->flags.encrypt_event_sent == 0) {
|
||||
if (ble_ll_hci_is_event_enabled(BLE_HCI_EVCODE_ENCRYPT_CHG)) {
|
||||
hci_ev = ble_transport_alloc_evt(0);
|
||||
if (hci_ev) {
|
||||
@@ -151,7 +151,7 @@ ble_ll_hci_ev_encrypt_chg(struct ble_ll_conn_sm *connsm, uint8_t status)
|
||||
}
|
||||
}
|
||||
|
||||
connsm->flags.encrypt_chg_sent = 1;
|
||||
connsm->flags.encrypt_event_sent = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ ble_ll_hci_ev_le_csa(struct ble_ll_conn_sm *connsm)
|
||||
|
||||
ev->subev_code = BLE_HCI_LE_SUBEV_CHAN_SEL_ALG;
|
||||
ev->conn_handle = htole16(connsm->conn_handle);
|
||||
ev->csa = connsm->flags.csa2_supp ? 0x01 : 0x00;
|
||||
ev->csa = connsm->flags.csa2 ? 0x01 : 0x00;
|
||||
|
||||
ble_ll_hci_event_send(hci_ev);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ TEST_CASE_SELF(ble_ll_csa2_test_1)
|
||||
*/
|
||||
|
||||
memset(&conn, 0, sizeof(conn));
|
||||
conn.flags.csa2_supp = 1;
|
||||
conn.flags.csa2 = 1;
|
||||
|
||||
/*
|
||||
* based on sample data from CoreSpec 5.0 Vol 6 Part C 3.1
|
||||
@@ -75,7 +75,7 @@ TEST_CASE_SELF(ble_ll_csa2_test_2)
|
||||
*/
|
||||
|
||||
memset(&conn, 0, sizeof(conn));
|
||||
conn.flags.csa2_supp = 1;
|
||||
conn.flags.csa2 = 1;
|
||||
|
||||
/*
|
||||
* based on sample data from CoreSpec 5.0 Vol 6 Part C 3.2
|
||||
|
||||
Reference in New Issue
Block a user