You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2017/04/11 22:45:35 UTC

[06/14] incubator-mynewt-core git commit: nimble/controller: Improve CSA #2 channel identifier calculation

nimble/controller: Improve CSA #2 channel identifier calculation

Channel identifier is fixed for connection (calculated from access
address) so there is no need to calculate it every time algorithm
function is called. The drawback is extra 2 bytes in ble_ll_conn_sm
structure.


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/c74e47a4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c74e47a4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c74e47a4

Branch: refs/heads/bluetooth5
Commit: c74e47a4f8133a9941864bac6167c4a0eea61403
Parents: 96797c9
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Fri Apr 7 13:53:11 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Fri Apr 7 13:59:51 2017 +0200

----------------------------------------------------------------------
 net/nimble/controller/include/controller/ble_ll_conn.h | 1 +
 net/nimble/controller/src/ble_ll_conn.c                | 8 +++-----
 2 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c74e47a4/net/nimble/controller/include/controller/ble_ll_conn.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_conn.h b/net/nimble/controller/include/controller/ble_ll_conn.h
index ef33b96..c365b0f 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -149,6 +149,7 @@ struct ble_ll_conn_sm
     uint8_t chanmap[BLE_LL_CONN_CHMAP_LEN];
     uint8_t req_chanmap[BLE_LL_CONN_CHMAP_LEN];
     uint16_t chanmap_instant;
+    uint16_t channel_id; /* TODO could be union with hop and last chan used */
     uint8_t hop_inc;
     uint8_t data_chan_index;
     uint8_t unmapped_chan;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c74e47a4/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 46b8d4d..0e5a904 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -641,16 +641,12 @@ uint8_t
 ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn)
 {
     uint16_t channel_unmapped;
-    uint16_t channel_id;
     uint8_t remap_index;
 
     uint16_t prn_e;
     uint8_t bitpos;
 
-    channel_id = ((conn->access_addr & 0xffff0000) >> 16) ^
-                  (conn->access_addr & 0x0000ffff);
-
-    prn_e = ble_ll_conn_csa2_prng(conn->event_cntr, channel_id);
+    prn_e = ble_ll_conn_csa2_prng(conn->event_cntr, conn->channel_id);
 
     channel_unmapped = prn_e % 37;
 
@@ -1580,6 +1576,8 @@ ble_ll_conn_set_csa(struct ble_ll_conn_sm *connsm, bool use_csa2)
     /* calculate the next data channel */
     if (use_csa2) {
         CONN_F_CSA2_SUPP(connsm) = 1;
+        connsm->channel_id = ((connsm->access_addr & 0xffff0000) >> 16) ^
+                              (connsm->access_addr & 0x0000ffff);
         connsm->data_chan_index = ble_ll_conn_calc_dci_csa2(connsm);
     } else {
         connsm->last_unmapped_chan = 0;