nimble/controller: Allow to configure CSA #2 support This allows to enable/disable CSA #2 support in Nimble controller. By default it is disabled.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1630d8e3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1630d8e3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1630d8e3 Branch: refs/heads/bluetooth5 Commit: 1630d8e37459fc2ce8259a05c2f1e0f6bf5c2e98 Parents: 3acdf38 Author: Szymon Janc <[email protected]> Authored: Tue Apr 11 14:47:26 2017 +0200 Committer: Szymon Janc <[email protected]> Committed: Tue Apr 11 14:47:26 2017 +0200 ---------------------------------------------------------------------- net/nimble/controller/src/ble_ll.c | 2 ++ net/nimble/controller/src/ble_ll_adv.c | 9 +++++++-- net/nimble/controller/src/ble_ll_conn.c | 12 +++++++++++- net/nimble/controller/src/ble_ll_conn_hci.c | 3 ++- net/nimble/controller/src/ble_ll_hci_ev.c | 2 ++ net/nimble/controller/syscfg.yml | 6 ++++++ net/nimble/controller/test/syscfg.yml | 1 + 7 files changed, 31 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1630d8e3/net/nimble/controller/src/ble_ll.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll.c b/net/nimble/controller/src/ble_ll.c index dd71dbd..5fe03d0 100644 --- a/net/nimble/controller/src/ble_ll.c +++ b/net/nimble/controller/src/ble_ll.c @@ -1339,8 +1339,10 @@ ble_ll_init(void) features |= BLE_LL_FEAT_LE_PING; #endif +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) /* CSA2 */ features |= BLE_LL_FEAT_CSA2; +#endif /* Initialize random number generation */ ble_ll_rand_init(); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1630d8e3/net/nimble/controller/src/ble_ll_adv.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c index 8ce9bf3..f72446a 100644 --- a/net/nimble/controller/src/ble_ll_adv.c +++ b/net/nimble/controller/src/ble_ll_adv.c @@ -244,8 +244,9 @@ ble_ll_adv_pdu_make(struct ble_ll_adv_sm *advsm, struct os_mbuf *m) case BLE_HCI_ADV_TYPE_ADV_IND: pdu_type = BLE_ADV_PDU_TYPE_ADV_IND; - /* CSA #2 is supported */ +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) pdu_type |= BLE_ADV_PDU_HDR_CHSEL; +#endif break; case BLE_HCI_ADV_TYPE_ADV_NONCONN_IND: @@ -260,8 +261,9 @@ ble_ll_adv_pdu_make(struct ble_ll_adv_sm *advsm, struct os_mbuf *m) case BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD: pdu_type = BLE_ADV_PDU_TYPE_ADV_DIRECT_IND; - /* CSA #2 is supported */ +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) pdu_type |= BLE_ADV_PDU_HDR_CHSEL; +#endif adv_data_len = 0; pdulen = BLE_ADV_DIRECT_IND_LEN; @@ -1724,7 +1726,10 @@ ble_ll_adv_send_conn_comp_ev(struct ble_ll_conn_sm *connsm, advsm->conn_comp_ev = NULL; ble_ll_conn_comp_event_send(connsm, BLE_ERR_SUCCESS, evbuf, advsm); + +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) ble_ll_hci_ev_le_csa(connsm); +#endif } /** http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1630d8e3/net/nimble/controller/src/ble_ll_conn.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c index 9a86bbb..681a122 100644 --- a/net/nimble/controller/src/ble_ll_conn.c +++ b/net/nimble/controller/src/ble_ll_conn.c @@ -599,6 +599,7 @@ ble_ll_conn_remapped_channel(uint8_t remap_index, const uint8_t *chanmap) return 0; } +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) static uint16_t ble_ll_conn_csa2_perm(uint16_t in) { @@ -663,6 +664,7 @@ ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn) return ble_ll_conn_remapped_channel(remap_index, conn->chanmap); } +#endif static uint8_t ble_ll_conn_calc_dci_csa1(struct ble_ll_conn_sm *conn) @@ -706,9 +708,11 @@ 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) == 1) if (CONN_F_CSA2_SUPP(conn)) { return ble_ll_conn_calc_dci_csa2(conn); } +#endif index = conn->data_chan_index; @@ -1593,17 +1597,21 @@ ble_ll_conn_master_init(struct ble_ll_conn_sm *connsm, static void ble_ll_conn_set_csa(struct ble_ll_conn_sm *connsm, bool chsel) { - /* calculate the next data channel */ +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) if (chsel) { CONN_F_CSA2_SUPP(connsm) = 1; connsm->channel_id = ((connsm->access_addr & 0xffff0000) >> 16) ^ (connsm->access_addr & 0x0000ffff); + /* calculate the next data channel */ connsm->data_chan_index = ble_ll_conn_calc_dci(connsm, 0); return; } +#endif connsm->last_unmapped_chan = 0; + + /* calculate the next data channel */ connsm->data_chan_index = ble_ll_conn_calc_dci(connsm, 1); } @@ -2133,7 +2141,9 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, struct ble_mbuf_hdr *rxhdr) } else { evbuf = ble_ll_init_get_conn_comp_ev(); ble_ll_conn_comp_event_send(connsm, BLE_ERR_SUCCESS, evbuf, NULL); +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) ble_ll_hci_ev_le_csa(connsm); +#endif } } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1630d8e3/net/nimble/controller/src/ble_ll_conn_hci.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_conn_hci.c b/net/nimble/controller/src/ble_ll_conn_hci.c index 84d1b53..31b6c04 100644 --- a/net/nimble/controller/src/ble_ll_conn_hci.c +++ b/net/nimble/controller/src/ble_ll_conn_hci.c @@ -126,8 +126,9 @@ ble_ll_conn_req_pdu_make(struct ble_ll_conn_sm *connsm) /* Construct first PDU header byte */ pdu_type = BLE_ADV_PDU_TYPE_CONNECT_REQ; - /* CSA #2 is supported */ +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) pdu_type |= BLE_ADV_PDU_HDR_CHSEL; +#endif /* Set BLE transmit header */ ble_ll_mbuf_init(m, BLE_CONNECT_REQ_LEN, pdu_type); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1630d8e3/net/nimble/controller/src/ble_ll_hci_ev.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_hci_ev.c b/net/nimble/controller/src/ble_ll_hci_ev.c index ac9398e..3319db3 100644 --- a/net/nimble/controller/src/ble_ll_hci_ev.c +++ b/net/nimble/controller/src/ble_ll_hci_ev.c @@ -273,6 +273,7 @@ ble_ll_hci_ev_databuf_overflow(void) * * @param connsm Pointer to connection state machine */ +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) void ble_ll_hci_ev_le_csa(struct ble_ll_conn_sm *connsm) { @@ -290,3 +291,4 @@ ble_ll_hci_ev_le_csa(struct ble_ll_conn_sm *connsm) } } } +#endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1630d8e3/net/nimble/controller/syscfg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/controller/syscfg.yml b/net/nimble/controller/syscfg.yml index fd4f48a..0fe7a48 100644 --- a/net/nimble/controller/syscfg.yml +++ b/net/nimble/controller/syscfg.yml @@ -204,6 +204,12 @@ syscfg.defs: nimble controller. value: '0' + BLE_LL_CFG_FEAT_LE_CSA2: + description: > + This option is used to enable/disable support for LE Channel + Selection Algorithm #2. + value: '0' + BLE_PUBLIC_DEV_ADDR: description: > Allows the target or app to override the public device address http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1630d8e3/net/nimble/controller/test/syscfg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/controller/test/syscfg.yml b/net/nimble/controller/test/syscfg.yml index 47a61a2..979e7a0 100644 --- a/net/nimble/controller/test/syscfg.yml +++ b/net/nimble/controller/test/syscfg.yml @@ -19,3 +19,4 @@ # Package: net/nimble/controller/test syscfg.vals: + BLE_LL_CFG_FEAT_LE_CSA2: 1
