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:30 UTC

[01/14] incubator-mynewt-core git commit: nimble/controller: Use common implementation for channel remapping

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/bluetooth5 646b35dfa -> 6fba2048e


nimble/controller: Use common implementation for channel remapping

Both CSA #1 and #2 use same concept of using remapping index for
selecting used channel.


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

Branch: refs/heads/bluetooth5
Commit: 2566748c612b1c32d94f9a41150c829ca01e12c7
Parents: 51d1ea2
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Mon Apr 3 17:08:44 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Fri Apr 7 11:06:20 2017 +0200

----------------------------------------------------------------------
 net/nimble/controller/src/ble_ll_conn.c | 39 +++++-----------------------
 1 file changed, 6 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2566748c/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 d85bb5a..afe2e86 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -679,15 +679,9 @@ ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn)
 uint8_t
 ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn)
 {
-    int     i;
-    int     j;
-    uint8_t chan;
     uint8_t curchan;
     uint8_t remap_index;
     uint8_t bitpos;
-    uint8_t cntr;
-    uint8_t mask;
-    uint8_t usable_chans;
 
     /* Get next unmapped channel */
     curchan = conn->last_unmapped_chan + conn->hop_inc;
@@ -700,35 +694,14 @@ ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn)
 
     /* Is this a valid channel? */
     bitpos = 1 << (curchan & 0x07);
-    if ((conn->chanmap[curchan >> 3] & bitpos) == 0) {
-
-        /* Calculate remap index */
-        remap_index = curchan % conn->num_used_chans;
-
-        /* NOTE: possible to build a map but this would use memory. For now,
-           we just calculate */
-        /* Iterate through channel map to find this channel */
-        chan = 0;
-        cntr = 0;
-        for (i = 0; i < BLE_LL_CONN_CHMAP_LEN; i++) {
-            usable_chans = conn->chanmap[i];
-            if (usable_chans != 0) {
-                mask = 0x01;
-                for (j = 0; j < 8; j++) {
-                    if (usable_chans & mask) {
-                        if (cntr == remap_index) {
-                            return (chan + j);
-                        }
-                        ++cntr;
-                    }
-                    mask <<= 1;
-                }
-            }
-            chan += 8;
-        }
+    if (conn->chanmap[curchan >> 3] & bitpos) {
+        return curchan;
     }
 
-    return curchan;
+    /* Calculate remap index */
+    remap_index = curchan % conn->num_used_chans;
+
+    return ble_ll_conn_csa2_remapped_channel(remap_index, conn->chanmap);
 }
 
 /**


[02/14] incubator-mynewt-core git commit: nimble/controller: Add Channel Selection Algorithm #2 implementation

Posted by an...@apache.org.
nimble/controller: Add Channel Selection Algorithm #2 implementation

This adds implementation of Channel Selection Algorithm #2 as specified
in Core Specification 5.0 Vol 6 Part B 4.6.14.


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

Branch: refs/heads/bluetooth5
Commit: 51d1ea26a6436be6c9fde415e0b973bc81381ce1
Parents: 646b35d
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Mon Apr 3 17:03:13 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Fri Apr 7 11:06:20 2017 +0200

----------------------------------------------------------------------
 net/nimble/controller/src/ble_ll_conn.c | 105 +++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/51d1ea26/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 2d4c099..d85bb5a 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -563,6 +563,111 @@ ble_ll_conn_calc_access_addr(void)
     return aa;
 }
 
+static uint16_t
+ble_ll_conn_csa2_perm(uint16_t in)
+{
+    uint16_t out = 0;
+    int i;
+
+    for (i = 0; i < 8; i++) {
+        out |= ((in >> i) & 0x00000001) << (7 - i);
+    }
+
+    for (i = 8; i < 16; i++) {
+        out |= ((in >> i) & 0x00000001) << (15 + 8 - i);
+    }
+
+    return out;
+}
+
+static uint16_t
+ble_ll_conn_csa2_prng(uint16_t counter, uint16_t ch_id)
+{
+    uint16_t prn_e;
+
+    prn_e = counter ^ ch_id;
+
+    prn_e = ble_ll_conn_csa2_perm(prn_e);
+    prn_e = (prn_e * 17) + ch_id;
+
+    prn_e = ble_ll_conn_csa2_perm(prn_e);
+    prn_e = (prn_e * 17) + ch_id;
+
+    prn_e = ble_ll_conn_csa2_perm(prn_e);
+    prn_e = (prn_e * 17) + ch_id;
+
+    prn_e = prn_e ^ ch_id;
+
+    return prn_e;
+}
+
+static uint8_t
+ble_ll_conn_csa2_remapped_channel(uint8_t remap_index, const uint8_t *chanmap)
+{
+    uint8_t cntr;
+    uint8_t mask;
+    uint8_t usable_chans;
+    uint8_t chan;
+    int i, j;
+
+    /* NOTE: possible to build a map but this would use memory. For now,
+       we just calculate */
+    /* Iterate through channel map to find this channel */
+    chan = 0;
+    cntr = 0;
+    for (i = 0; i < BLE_LL_CONN_CHMAP_LEN; i++) {
+        usable_chans = chanmap[i];
+        if (usable_chans != 0) {
+            mask = 0x01;
+            for (j = 0; j < 8; j++) {
+                if (usable_chans & mask) {
+                    if (cntr == remap_index) {
+                        return (chan + j);
+                    }
+                    ++cntr;
+                }
+                mask <<= 1;
+            }
+        }
+        chan += 8;
+    }
+
+    /* we should never reach here */
+    assert(0);
+    return 0;
+}
+
+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);
+
+    channel_unmapped = prn_e % 37;
+
+    /*
+     * If unmapped channel is the channel index of a used channel it is used
+     * as channel index.
+     */
+    bitpos = 1 << (channel_unmapped & 0x07);
+    if (conn->chanmap[channel_unmapped >> 3] & bitpos) {
+        return channel_unmapped;
+    }
+
+    remap_index = (conn->num_used_chans * prn_e) / 0x10000;
+
+    return ble_ll_conn_csa2_remapped_channel(remap_index, conn->chanmap);
+}
+
 /**
  * Determine data channel index to be used for the upcoming/current
  * connection event


[08/14] incubator-mynewt-core git commit: controller: Minor comment fix

Posted by an...@apache.org.
controller: Minor comment fix

Errata 6471 clarifies what AdvA shall be in Scan Resp and nimble does good.
This errata is adopted into Bluetooth 5.0


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

Branch: refs/heads/bluetooth5
Commit: 07d7daaa065c6306b688718a25913a2e1ea52cad
Parents: 646b35d
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Mon Apr 10 12:11:25 2017 +0200
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Mon Apr 10 14:56:23 2017 +0200

----------------------------------------------------------------------
 net/nimble/controller/src/ble_ll_adv.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/07d7daaa/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 16455fd..9970b59 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -336,12 +336,11 @@ ble_ll_adv_scan_rsp_pdu_make(struct ble_ll_adv_sm *advsm)
     ble_ll_mbuf_init(m, pdulen, hdr);
 
     /*
-     * XXX: Am I sure this is correct? The adva in this packet will be the
-     * same one that was being advertised and is based on the peer identity
-     * address in the set advertising parameters. If a different peer sends
-     * us a scan request (for some reason) we will reply with an adva that
-     * was not generated based on the local irk of the peer sending the scan
-     * request.
+     * The adva in this packet will be the same one that was being advertised
+     * and is based on the peer identity address in the set advertising
+     * parameters. If a different peer sends us a scan request (for some reason)
+     * we will reply with an adva that was not generated based on the local irk
+     * of the peer sending the scan request.
      */
 
     /* Construct scan response */


[12/14] incubator-mynewt-core git commit: nimble/controller: Allow to configure CSA #2 support

Posted by an...@apache.org.
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 <sz...@codecoup.pl>
Authored: Tue Apr 11 14:47:26 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
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


[13/14] incubator-mynewt-core git commit: This closes #224.

Posted by an...@apache.org.
This closes #224.

Merge branch 'csa2' of https://github.com/sjanc/incubator-mynewt-core into bluetooth5


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

Branch: refs/heads/bluetooth5
Commit: ebd6189a43c0fcc6363a80602e13048d83a363f9
Parents: 646b35d 1630d8e
Author: Andrzej Kaczmarek <an...@codecoup.pl>
Authored: Wed Apr 12 00:45:08 2017 +0200
Committer: Andrzej Kaczmarek <an...@codecoup.pl>
Committed: Wed Apr 12 00:45:08 2017 +0200

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll.h      |  37 ++-
 .../controller/include/controller/ble_ll_conn.h |   9 +-
 .../controller/include/controller/ble_ll_ctrl.h |   2 +-
 .../controller/include/controller/ble_ll_test.h |  35 +++
 net/nimble/controller/src/ble_ll.c              |  11 +-
 net/nimble/controller/src/ble_ll_adv.c          |  13 ++
 net/nimble/controller/src/ble_ll_conn.c         | 229 ++++++++++++++-----
 net/nimble/controller/src/ble_ll_conn_hci.c     |   5 +
 net/nimble/controller/src/ble_ll_ctrl.c         |  14 +-
 net/nimble/controller/src/ble_ll_hci.c          |   3 +-
 net/nimble/controller/src/ble_ll_hci_ev.c       |  27 ++-
 net/nimble/controller/src/ble_ll_sched.c        |   1 +
 net/nimble/controller/src/ble_ll_xcvr.c         |   1 +
 net/nimble/controller/syscfg.yml                |   6 +
 net/nimble/controller/test/pkg.yml              |  33 +++
 .../controller/test/src/ble_ll_csa2_test.c      | 123 ++++++++++
 net/nimble/controller/test/src/ble_ll_test.c    |  40 ++++
 net/nimble/controller/test/syscfg.yml           |  22 ++
 net/nimble/include/nimble/hci_common.h          |   3 +
 19 files changed, 534 insertions(+), 80 deletions(-)
----------------------------------------------------------------------



[09/14] incubator-mynewt-core git commit: nimble/controller: Rename and move ble_ll_conn_csa2_remapped_channel

Posted by an...@apache.org.
nimble/controller: Rename and move ble_ll_conn_csa2_remapped_channel

This function is use both by CSA #1 and #2 so name it accordingly. Also
move it up in the source file - this is in preparation for optional
CSA #2 support.


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

Branch: refs/heads/bluetooth5
Commit: 22271049c61f4796f23f272cadd5d555ece37136
Parents: a7d39f9
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Tue Apr 11 11:13:38 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Tue Apr 11 11:13:38 2017 +0200

----------------------------------------------------------------------
 net/nimble/controller/src/ble_ll_conn.c | 76 ++++++++++++++--------------
 1 file changed, 38 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/22271049/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 10b5cc7..b827182 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -563,6 +563,42 @@ ble_ll_conn_calc_access_addr(void)
     return aa;
 }
 
+static uint8_t
+ble_ll_conn_remapped_channel(uint8_t remap_index, const uint8_t *chanmap)
+{
+    uint8_t cntr;
+    uint8_t mask;
+    uint8_t usable_chans;
+    uint8_t chan;
+    int i, j;
+
+    /* NOTE: possible to build a map but this would use memory. For now,
+       we just calculate */
+    /* Iterate through channel map to find this channel */
+    chan = 0;
+    cntr = 0;
+    for (i = 0; i < BLE_LL_CONN_CHMAP_LEN; i++) {
+        usable_chans = chanmap[i];
+        if (usable_chans != 0) {
+            mask = 0x01;
+            for (j = 0; j < 8; j++) {
+                if (usable_chans & mask) {
+                    if (cntr == remap_index) {
+                        return (chan + j);
+                    }
+                    ++cntr;
+                }
+                mask <<= 1;
+            }
+        }
+        chan += 8;
+    }
+
+    /* we should never reach here */
+    assert(0);
+    return 0;
+}
+
 static uint16_t
 ble_ll_conn_csa2_perm(uint16_t in)
 {
@@ -601,42 +637,6 @@ ble_ll_conn_csa2_prng(uint16_t counter, uint16_t ch_id)
     return prn_e;
 }
 
-static uint8_t
-ble_ll_conn_csa2_remapped_channel(uint8_t remap_index, const uint8_t *chanmap)
-{
-    uint8_t cntr;
-    uint8_t mask;
-    uint8_t usable_chans;
-    uint8_t chan;
-    int i, j;
-
-    /* NOTE: possible to build a map but this would use memory. For now,
-       we just calculate */
-    /* Iterate through channel map to find this channel */
-    chan = 0;
-    cntr = 0;
-    for (i = 0; i < BLE_LL_CONN_CHMAP_LEN; i++) {
-        usable_chans = chanmap[i];
-        if (usable_chans != 0) {
-            mask = 0x01;
-            for (j = 0; j < 8; j++) {
-                if (usable_chans & mask) {
-                    if (cntr == remap_index) {
-                        return (chan + j);
-                    }
-                    ++cntr;
-                }
-                mask <<= 1;
-            }
-        }
-        chan += 8;
-    }
-
-    /* we should never reach here */
-    assert(0);
-    return 0;
-}
-
 uint8_t
 ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn)
 {
@@ -661,7 +661,7 @@ ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn)
 
     remap_index = (conn->num_used_chans * prn_e) / 0x10000;
 
-    return ble_ll_conn_csa2_remapped_channel(remap_index, conn->chanmap);
+    return ble_ll_conn_remapped_channel(remap_index, conn->chanmap);
 }
 
 /**
@@ -697,7 +697,7 @@ ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn)
     /* Calculate remap index */
     remap_index = curchan % conn->num_used_chans;
 
-    return ble_ll_conn_csa2_remapped_channel(remap_index, conn->chanmap);
+    return ble_ll_conn_remapped_channel(remap_index, conn->chanmap);
 }
 
 /**


[05/14] incubator-mynewt-core git commit: nimble/controller: Add CSA #2 to supported features

Posted by an...@apache.org.
nimble/controller: Add CSA #2 to supported features

Feature bit should be set if CSA #2 is supported.

< HCI Command: LE Read Local Supported Features (0x08|0x0003) plen 0
> HCI Event: Command Complete (0x0e) plen 12
      LE Read Local Supported Features (0x08|0x0003) ncmd 1
        Status: Success (0x00)
        Features: 0xfd 0x40 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
          Extended Reject Indication
          Slave-initiated Features Exchange
          LE Ping
          LE Data Packet Length Extension
          LL Privacy
          Extended Scanner Filter Policies
          Channel Selection Algorithm #2


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

Branch: refs/heads/bluetooth5
Commit: 8e0cf0dc75da6597561596c09362bb7d3b14d2d6
Parents: c74e47a
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Wed Apr 5 18:20:18 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Fri Apr 7 13:59:51 2017 +0200

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll.h      | 33 +++++++++++++-------
 .../controller/include/controller/ble_ll_conn.h |  2 +-
 net/nimble/controller/src/ble_ll.c              |  9 ++++--
 net/nimble/controller/src/ble_ll_ctrl.c         | 14 ++++++---
 net/nimble/controller/src/ble_ll_hci.c          |  3 +-
 net/nimble/controller/src/ble_ll_hci_ev.c       |  2 +-
 6 files changed, 40 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8e0cf0dc/net/nimble/controller/include/controller/ble_ll.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll.h b/net/nimble/controller/include/controller/ble_ll.h
index 0aa1f44..b2cff88 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -81,12 +81,12 @@ STAILQ_HEAD(ble_ll_pkt_q, os_mbuf_pkthdr);
  */
 struct ble_ll_obj
 {
+    /* Supported features */
+    uint32_t ll_supp_features;
+
     /* Current Link Layer state */
     uint8_t ll_state;
 
-    /* Supported features */
-    uint8_t ll_supp_features;
-
     /* Number of ACL data packets supported */
     uint8_t ll_num_acl_pkts;
 
@@ -175,14 +175,23 @@ extern STATS_SECT_DECL(ble_ll_stats) ble_ll_stats;
 #define BLE_LL_STATE_CONNECTION     (4)
 
 /* LL Features */
-#define BLE_LL_FEAT_LE_ENCRYPTION   (0x01)
-#define BLE_LL_FEAT_CONN_PARM_REQ   (0x02)
-#define BLE_LL_FEAT_EXTENDED_REJ    (0x04)
-#define BLE_LL_FEAT_SLAVE_INIT      (0x08)
-#define BLE_LL_FEAT_LE_PING         (0x10)
-#define BLE_LL_FEAT_DATA_LEN_EXT    (0x20)
-#define BLE_LL_FEAT_LL_PRIVACY      (0x40)
-#define BLE_LL_FEAT_EXT_SCAN_FILT   (0x80)
+#define BLE_LL_FEAT_LE_ENCRYPTION    (0x00000001)
+#define BLE_LL_FEAT_CONN_PARM_REQ    (0x00000002)
+#define BLE_LL_FEAT_EXTENDED_REJ     (0x00000004)
+#define BLE_LL_FEAT_SLAVE_INIT       (0x00000008)
+#define BLE_LL_FEAT_LE_PING          (0x00000010)
+#define BLE_LL_FEAT_DATA_LEN_EXT     (0x00000020)
+#define BLE_LL_FEAT_LL_PRIVACY       (0x00000040)
+#define BLE_LL_FEAT_EXT_SCAN_FILT    (0x00000080)
+#define BLE_LL_FEAT_LE_2M_PHY        (0x00000100)
+#define BLE_LL_FEAT_STABLE_MOD_ID_TX (0x00000200)
+#define BLE_LL_FEAT_STABLE_MOD_ID_RX (0x00000400)
+#define BLE_LL_FEAT_LE_CODED_PHY     (0x00000800)
+#define BLE_LL_FEAT_EXT_ADV          (0x00001000)
+#define BLE_LL_FEAT_PERIODIC_ADV     (0x00002000)
+#define BLE_LL_FEAT_CSA2             (0x00004000)
+#define BLE_LL_FEAT_LE_POWER_CLASS_1 (0x00008000)
+#define BLE_LL_FEAT_MIN_USED_CHAN    (0x00010000)
 
 /* LL timing */
 #define BLE_LL_IFS                  (150)       /* usecs */
@@ -412,7 +421,7 @@ void ble_ll_wfr_disable(void);
 void ble_ll_wfr_timer_exp(void *arg);
 
 /* Read set of features supported by the Link Layer */
-uint8_t ble_ll_read_supp_features(void);
+uint32_t ble_ll_read_supp_features(void);
 
 /* Read set of states supported by the Link Layer */
 uint64_t ble_ll_read_supp_states(void);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8e0cf0dc/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 c365b0f..47b2e48 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -178,7 +178,7 @@ struct ble_ll_conn_sm
     uint8_t cur_ctrl_proc;
     uint8_t disconnect_reason;
     uint8_t rxd_disconnect_reason;
-    uint8_t common_features;        /* Just a uint8 for now */
+    uint32_t common_features;
     uint8_t vers_nr;
     uint16_t pending_ctrl_procs;
     uint16_t event_cntr;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8e0cf0dc/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 360a203..dd71dbd 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -1071,9 +1071,9 @@ ble_ll_read_supp_states(void)
 /**
  * Returns the features supported by the link layer
  *
- * @return uint8_t bitmask of supported features.
+ * @return uint32_t bitmask of supported features.
  */
-uint8_t
+uint32_t
 ble_ll_read_supp_features(void)
 {
     return g_ble_ll_data.ll_supp_features;
@@ -1231,7 +1231,7 @@ void
 ble_ll_init(void)
 {
     int rc;
-    uint8_t features;
+    uint32_t features;
 #ifdef BLE_XCVR_RFCLK
     uint32_t xtal_ticks;
 #endif
@@ -1339,6 +1339,9 @@ ble_ll_init(void)
     features |= BLE_LL_FEAT_LE_PING;
 #endif
 
+    /* CSA2 */
+    features |= BLE_LL_FEAT_CSA2;
+
     /* Initialize random number generation */
     ble_ll_rand_init();
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8e0cf0dc/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index 87a66ce..02024a2 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -1022,6 +1022,7 @@ ble_ll_ctrl_rx_feature_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
                            uint8_t *rspbuf, uint8_t opcode)
 {
     uint8_t rsp_opcode;
+    uint32_t remote_feat;
 
     /*
      * Only accept slave feature requests if we are a master and feature
@@ -1038,11 +1039,13 @@ ble_ll_ctrl_rx_feature_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
         }
     }
 
+    remote_feat = get_le32(dptr);
+
     /* Set common features and reply */
     rsp_opcode = BLE_LL_CTRL_FEATURE_RSP;
-    connsm->common_features = dptr[0] & ble_ll_read_supp_features();
+    connsm->common_features = remote_feat & ble_ll_read_supp_features();
     memset(rspbuf + 1, 0, 8);
-    rspbuf[1] = connsm->common_features;
+    put_le32(rspbuf + 1, connsm->common_features);
 
     return rsp_opcode;
 }
@@ -1283,7 +1286,8 @@ ble_ll_ctrl_proc_init(struct ble_ll_conn_sm *connsm, int ctrl_proc)
             } else {
                 opcode = BLE_LL_CTRL_SLAVE_FEATURE_REQ;
             }
-            ctrdata[0] = ble_ll_read_supp_features();
+
+            put_le32(ctrdata, ble_ll_read_supp_features());
             break;
         case BLE_LL_CTRL_PROC_VERSION_XCHG:
             opcode = BLE_LL_CTRL_VERSION_IND;
@@ -1511,8 +1515,8 @@ ble_ll_ctrl_chk_proc_start(struct ble_ll_conn_sm *connsm)
 int
 ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
 {
-    uint8_t features;
-    uint8_t feature;
+    uint32_t features;
+    uint32_t feature;
     uint8_t len;
     uint8_t opcode;
     uint8_t rsp_opcode;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8e0cf0dc/net/nimble/controller/src/ble_ll_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci.c b/net/nimble/controller/src/ble_ll_hci.c
index ca5996d..692c0c9 100644
--- a/net/nimble/controller/src/ble_ll_hci.c
+++ b/net/nimble/controller/src/ble_ll_hci.c
@@ -390,7 +390,8 @@ ble_ll_hci_le_read_local_features(uint8_t *rspbuf, uint8_t *rsplen)
 {
     /* Add list of supported features. */
     memset(rspbuf, 0, BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN);
-    rspbuf[0] = ble_ll_read_supp_features();
+    put_le32(rspbuf, ble_ll_read_supp_features());
+
     *rsplen = BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN;
     return BLE_ERR_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8e0cf0dc/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 c3e003a..e0803cd 100644
--- a/net/nimble/controller/src/ble_ll_hci_ev.c
+++ b/net/nimble/controller/src/ble_ll_hci_ev.c
@@ -198,7 +198,7 @@ ble_ll_hci_ev_rd_rem_used_feat(struct ble_ll_conn_sm *connsm, uint8_t status)
             evbuf[3] = status;
             put_le16(evbuf + 4, connsm->conn_handle);
             memset(evbuf + 6, 0, BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN);
-            evbuf[6] = connsm->common_features;
+            put_le32(evbuf + 6, connsm->common_features);
             ble_ll_hci_event_send(evbuf);
         }
     }


[03/14] incubator-mynewt-core git commit: nimble/controller: Send LE Channel Selection Algorithm Event

Posted by an...@apache.org.
nimble/controller: Send LE Channel Selection Algorithm Event

If connection is created and LE Channel Selection Algorithm Event is
unmasked send it immediately after LE (Enhanced) Connection Complete
event.

< HCI Command: LE Set Event Mask (0x08|0x0001) plen 8       25.731854
        Mask: 0x000000000008045f
          LE Connection Complete
          LE Advertising Report
          LE Connection Update Complete
          LE Read Remote Used Features Complete
          LE Long Term Key Request
          LE Data Length Change
          LE Direct Advertising Report
          LE Channel Selection Algorithm

....

> HCI Event: LE Meta Event (0x3e) plen 19                   44.589758
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 1
        Role: Master (0x00)
        Peer address type: Public (0x00)
        Peer address: 0A:0A:0A:0A:0A:0A (OUI 0A-0A-0A)
        Connection interval: 18.75 msec (0x000f)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 32000 msec (0x0c80)
        Master clock accuracy: 0x04
> HCI Event: LE Meta Event (0x3e) plen 4                    44.589780
      LE Channel Selection Algorithm (0x14)
        Handle: 1
        LE Channel Selection Algorithm #2 (0x01)


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

Branch: refs/heads/bluetooth5
Commit: a7d39f9295576faf9f04ce89f6ee223643dd4f87
Parents: 8e0cf0d
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Thu Apr 6 15:47:05 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Fri Apr 7 13:59:51 2017 +0200

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll_ctrl.h |  2 +-
 net/nimble/controller/src/ble_ll_adv.c          |  1 +
 net/nimble/controller/src/ble_ll_conn.c         |  1 +
 net/nimble/controller/src/ble_ll_hci_ev.c       | 23 ++++++++++++++++++++
 net/nimble/include/nimble/hci_common.h          |  3 +++
 5 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a7d39f92/net/nimble/controller/include/controller/ble_ll_ctrl.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_ctrl.h b/net/nimble/controller/include/controller/ble_ll_ctrl.h
index ab302e4..23da308 100644
--- a/net/nimble/controller/include/controller/ble_ll_ctrl.h
+++ b/net/nimble/controller/include/controller/ble_ll_ctrl.h
@@ -250,7 +250,7 @@ void ble_ll_hci_ev_encrypt_chg(struct ble_ll_conn_sm *connsm, uint8_t status);
 int ble_ll_hci_ev_ltk_req(struct ble_ll_conn_sm *connsm);
 int ble_ll_hci_ev_hw_err(uint8_t hw_err);
 void ble_ll_hci_ev_databuf_overflow(void);
-
+void ble_ll_hci_ev_le_csa(struct ble_ll_conn_sm *connsm);
 
 void ble_ll_calc_session_key(struct ble_ll_conn_sm *connsm);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a7d39f92/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 19a8a49..8ce9bf3 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -1724,6 +1724,7 @@ 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);
+    ble_ll_hci_ev_le_csa(connsm);
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a7d39f92/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 0e5a904..10b5cc7 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -2119,6 +2119,7 @@ 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);
+            ble_ll_hci_ev_le_csa(connsm);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a7d39f92/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 e0803cd..ac9398e 100644
--- a/net/nimble/controller/src/ble_ll_hci_ev.c
+++ b/net/nimble/controller/src/ble_ll_hci_ev.c
@@ -267,3 +267,26 @@ ble_ll_hci_ev_databuf_overflow(void)
         }
     }
 }
+
+/**
+ * Send a LE Channel Selection Algorithm event.
+ *
+ * @param connsm Pointer to connection state machine
+ */
+void
+ble_ll_hci_ev_le_csa(struct ble_ll_conn_sm *connsm)
+{
+    uint8_t *evbuf;
+
+    if (ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_CHAN_SEL_ALG)) {
+        evbuf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI);
+        if (evbuf) {
+            evbuf[0] = BLE_HCI_EVCODE_LE_META;
+            evbuf[1] = BLE_HCI_LE_SUBEV_CHAN_SEL_ALG_LEN;
+            evbuf[2] = BLE_HCI_LE_SUBEV_CHAN_SEL_ALG;
+            put_le16(evbuf + 3, connsm->conn_handle);
+            evbuf[5] = connsm->csmflags.cfbit.csa2_supp ? 0x01 : 0x00;
+            ble_ll_hci_event_send(evbuf);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a7d39f92/net/nimble/include/nimble/hci_common.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/hci_common.h b/net/nimble/include/nimble/hci_common.h
index e9b520b..7404627 100644
--- a/net/nimble/include/nimble/hci_common.h
+++ b/net/nimble/include/nimble/hci_common.h
@@ -662,6 +662,9 @@ extern "C" {
 /* LE data length change event (sub event 0x07) */
 #define BLE_HCI_LE_DATA_LEN_CHG_LEN         (11)
 
+/* LE Channel Selection Algorithm event (sub event 0x14) */
+#define BLE_HCI_LE_SUBEV_CHAN_SEL_ALG_LEN   (4)
+
 /* Bluetooth Assigned numbers for version information.*/
 #define BLE_HCI_VER_BCS_1_0b                (0)
 #define BLE_HCI_VER_BCS_1_1                 (1)


[07/14] incubator-mynewt-core git commit: nimble/controller: Add support for Channel Selection Algorithm #2

Posted by an...@apache.org.
nimble/controller: Add support for Channel Selection Algorithm #2

When both sides indicate support for CSA #2 (by setting ChSel bit in
respective PDUs) it is used for channels selection.


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

Branch: refs/heads/bluetooth5
Commit: 96797c92e9bb7d27119bf48020bd1bead117b1db
Parents: 9cf07fd
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Wed Apr 5 14:33:33 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Fri Apr 7 13:59:51 2017 +0200

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll.h      |  4 +++
 .../controller/include/controller/ble_ll_conn.h |  2 ++
 net/nimble/controller/src/ble_ll_adv.c          |  7 ++++
 net/nimble/controller/src/ble_ll_conn.c         | 38 ++++++++++++++------
 net/nimble/controller/src/ble_ll_conn_hci.c     |  4 +++
 5 files changed, 45 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/96797c92/net/nimble/controller/include/controller/ble_ll.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll.h b/net/nimble/controller/include/controller/ble_ll.h
index f55bc8e..0aa1f44 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -252,6 +252,7 @@ struct ble_dev_addr
  * -> Payload (max 37 bytes)
  */
 #define BLE_ADV_PDU_HDR_TYPE_MASK           (0x0F)
+#define BLE_ADV_PDU_HDR_CHSEL_MASK          (0x20)
 #define BLE_ADV_PDU_HDR_TXADD_MASK          (0x40)
 #define BLE_ADV_PDU_HDR_RXADD_MASK          (0x80)
 #define BLE_ADV_PDU_HDR_LEN_MASK            (0x3F)
@@ -265,6 +266,9 @@ struct ble_dev_addr
 #define BLE_ADV_PDU_TYPE_CONNECT_REQ        (5)
 #define BLE_ADV_PDU_TYPE_ADV_SCAN_IND       (6)
 
+/* If Channel Selection Algorithm #2 is supported */
+#define BLE_ADV_PDU_HDR_CHSEL               (0x20)
+
 /*
  * TxAdd and RxAdd bit definitions. A 0 is a public address; a 1 is a
  * random address.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/96797c92/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 6e6f6d8..ef33b96 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -115,6 +115,7 @@ union ble_ll_conn_sm_flags {
         uint32_t encrypted:1;
         uint32_t encrypt_chg_sent:1;
         uint32_t le_ping_supp:1;
+        uint32_t csa2_supp:1;
     } cfbit;
     uint32_t conn_flags;
 } __attribute__((packed));
@@ -272,6 +273,7 @@ struct ble_ll_conn_sm
 #define CONN_F_ENCRYPTED(csm)       ((csm)->csmflags.cfbit.encrypted)
 #define CONN_F_ENC_CHANGE_SENT(csm) ((csm)->csmflags.cfbit.encrypt_chg_sent)
 #define CONN_F_LE_PING_SUPP(csm)    ((csm)->csmflags.cfbit.le_ping_supp)
+#define CONN_F_CSA2_SUPP(csm)       ((csm)->csmflags.cfbit.csa2_supp)
 
 /* Role */
 #define CONN_IS_MASTER(csm)         (csm->conn_role == BLE_LL_CONN_ROLE_MASTER)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/96797c92/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 16455fd..19a8a49 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -243,6 +243,9 @@ ble_ll_adv_pdu_make(struct ble_ll_adv_sm *advsm, struct os_mbuf *m)
     switch (advsm->adv_type) {
     case BLE_HCI_ADV_TYPE_ADV_IND:
         pdu_type = BLE_ADV_PDU_TYPE_ADV_IND;
+
+        /* CSA #2 is supported */
+        pdu_type |= BLE_ADV_PDU_HDR_CHSEL;
         break;
 
     case BLE_HCI_ADV_TYPE_ADV_NONCONN_IND:
@@ -256,6 +259,10 @@ ble_ll_adv_pdu_make(struct ble_ll_adv_sm *advsm, struct os_mbuf *m)
     case BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD:
     case BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD:
         pdu_type = BLE_ADV_PDU_TYPE_ADV_DIRECT_IND;
+
+        /* CSA #2 is supported */
+        pdu_type |= BLE_ADV_PDU_HDR_CHSEL;
+
         adv_data_len = 0;
         pdulen = BLE_ADV_DIRECT_IND_LEN;
         if (advsm->adv_rxadd) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/96797c92/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 afe2e86..46b8d4d 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -1574,6 +1574,19 @@ ble_ll_conn_master_init(struct ble_ll_conn_sm *connsm,
     connsm->conn_sch.sched_cb = ble_ll_conn_event_start_cb;
 }
 
+static void
+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->data_chan_index = ble_ll_conn_calc_dci_csa2(connsm);
+    } else {
+        connsm->last_unmapped_chan = 0;
+        connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
+    }
+}
+
 /**
  * Create a new connection state machine. This is done once per
  * connection when the HCI command "create connection" is issued to the
@@ -1612,10 +1625,6 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm)
      */
     connsm->conn_param_req.handle = 0;
 
-    /* Calculate the next data channel */
-    connsm->last_unmapped_chan = 0;
-    connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
-
     /* Connection end event */
     connsm->conn_ev_end.ev_arg = connsm;
     connsm->conn_ev_end.ev_queued = 0;
@@ -1936,10 +1945,14 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
     }
 
     /* Calculate data channel index of next connection event */
-    while (latency > 0) {
-        connsm->last_unmapped_chan = connsm->unmapped_chan;
-        connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
-        --latency;
+    if (CONN_F_CSA2_SUPP(connsm)) {
+        connsm->data_chan_index = ble_ll_conn_calc_dci_csa2(connsm);
+    } else {
+        while (latency > 0) {
+            connsm->last_unmapped_chan = connsm->unmapped_chan;
+            connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
+            --latency;
+        }
     }
 
     /*
@@ -2269,9 +2282,11 @@ ble_ll_conn_req_pdu_update(struct os_mbuf *m, uint8_t *adva, uint8_t addr_type,
 
     assert(m != NULL);
 
-    /* Retain pdu type but clear txadd/rxadd bits */
+    /* clear txadd/rxadd bits only */
     ble_hdr = BLE_MBUF_HDR_PTR(m);
-    hdr = ble_hdr->txinfo.hdr_byte & BLE_ADV_PDU_HDR_TYPE_MASK;
+    hdr = ble_hdr->txinfo.hdr_byte &
+          ~(BLE_ADV_PDU_HDR_RXADD_MASK | BLE_ADV_PDU_HDR_TXADD_MASK);
+
     if (addr_type) {
         /* Set random address */
         hdr |= BLE_ADV_PDU_HDR_RXADD_MASK;
@@ -2487,6 +2502,8 @@ ble_ll_init_rx_pkt_in(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr)
         /* Connection has been created. Stop scanning */
         g_ble_ll_conn_create_sm = NULL;
         ble_ll_scan_sm_stop(0);
+
+        ble_ll_conn_set_csa(connsm, rxbuf[0] & BLE_ADV_PDU_HDR_CHSEL_MASK);
         ble_ll_conn_created(connsm, NULL);
     } else {
         ble_ll_scan_chk_resume();
@@ -3436,6 +3453,7 @@ ble_ll_conn_slave_start(uint8_t *rxbuf, uint8_t pat, struct ble_mbuf_hdr *rxhdr)
     /* Start the connection state machine */
     connsm->conn_role = BLE_LL_CONN_ROLE_SLAVE;
     ble_ll_conn_sm_new(connsm);
+    ble_ll_conn_set_csa(connsm, rxbuf[0] & BLE_ADV_PDU_HDR_CHSEL_MASK);
 
     /* Set initial schedule callback */
     connsm->conn_sch.sched_cb = ble_ll_conn_event_start_cb;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/96797c92/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 4239a66..84d1b53 100644
--- a/net/nimble/controller/src/ble_ll_conn_hci.c
+++ b/net/nimble/controller/src/ble_ll_conn_hci.c
@@ -126,6 +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 */
+    pdu_type |= BLE_ADV_PDU_HDR_CHSEL;
+
     /* Set BLE transmit header */
     ble_ll_mbuf_init(m, BLE_CONNECT_REQ_LEN, pdu_type);
 
@@ -500,6 +503,7 @@ ble_ll_conn_create(uint8_t *cmdbuf)
     /* Initialize state machine in master role and start state machine */
     ble_ll_conn_master_init(connsm, hcc);
     ble_ll_conn_sm_new(connsm);
+    /* CSA will be selected when advertising is received */
 
     /* Create the connection request */
     ble_ll_conn_req_pdu_make(connsm);


[11/14] incubator-mynewt-core git commit: nimble/controller: Move latency calculations to ble_ll_conn_calc_dci

Posted by an...@apache.org.
nimble/controller: Move latency calculations to ble_ll_conn_calc_dci

This is to localize CSA #2 related code in order for easier compile
time configuration.


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

Branch: refs/heads/bluetooth5
Commit: 3acdf385fa4bfc94081005d359073f0e114825b6
Parents: 6b57da9
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Tue Apr 11 13:39:39 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Tue Apr 11 13:39:39 2017 +0200

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll_conn.h |  3 +-
 net/nimble/controller/src/ble_ll_conn.c         | 62 +++++++++++---------
 .../controller/test/src/ble_ll_csa2_test.c      | 12 ++--
 3 files changed, 42 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3acdf385/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 3267cda..488b27c 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -152,7 +152,6 @@ struct ble_ll_conn_sm
     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;
     uint8_t last_unmapped_chan;
     uint8_t num_used_chans;
 
@@ -288,7 +287,7 @@ struct ble_ll_conn_sm
 struct ble_ll_conn_sm *ble_ll_conn_find_active_conn(uint16_t handle);
 
 /* required for unit testing */
-uint8_t ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn);
+uint8_t ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn, uint16_t latency);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3acdf385/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 6d3e5e5..9a86bbb 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -664,33 +664,21 @@ ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn)
     return ble_ll_conn_remapped_channel(remap_index, conn->chanmap);
 }
 
-/**
- * Determine data channel index to be used for the upcoming/current
- * connection event
- *
- * @param conn
- *
- * @return uint8_t
- */
-uint8_t
-ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn)
+static uint8_t
+ble_ll_conn_calc_dci_csa1(struct ble_ll_conn_sm *conn)
 {
     uint8_t curchan;
     uint8_t remap_index;
     uint8_t bitpos;
 
-    if (CONN_F_CSA2_SUPP(conn)) {
-        return ble_ll_conn_calc_dci_csa2(conn);
-    }
-
     /* Get next unmapped channel */
     curchan = conn->last_unmapped_chan + conn->hop_inc;
     if (curchan > BLE_PHY_NUM_DATA_CHANS) {
         curchan -= BLE_PHY_NUM_DATA_CHANS;
     }
 
-    /* Set the current unmapped channel */
-    conn->unmapped_chan = curchan;
+    /* Save unmapped channel */
+    conn->last_unmapped_chan = curchan;
 
     /* Is this a valid channel? */
     bitpos = 1 << (curchan & 0x07);
@@ -705,6 +693,34 @@ ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn)
 }
 
 /**
+ * Determine data channel index to be used for the upcoming/current
+ * connection event
+ *
+ * @param conn
+ * @param latency Used only for CSA #1
+ *
+ * @return uint8_t
+ */
+uint8_t
+ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn, uint16_t latency)
+{
+    uint8_t index;
+
+    if (CONN_F_CSA2_SUPP(conn)) {
+        return ble_ll_conn_calc_dci_csa2(conn);
+    }
+
+    index = conn->data_chan_index;
+
+    while (latency > 0) {
+        index = ble_ll_conn_calc_dci_csa1(conn);
+        latency--;
+    }
+
+    return index;
+}
+
+/**
  * Called when we are in the connection state and the wait for response timer
  * fires off.
  *
@@ -1583,12 +1599,12 @@ ble_ll_conn_set_csa(struct ble_ll_conn_sm *connsm, bool chsel)
         connsm->channel_id = ((connsm->access_addr & 0xffff0000) >> 16) ^
                               (connsm->access_addr & 0x0000ffff);
 
-        connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
+        connsm->data_chan_index = ble_ll_conn_calc_dci(connsm, 0);
         return;
     }
 
     connsm->last_unmapped_chan = 0;
-    connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
+    connsm->data_chan_index = ble_ll_conn_calc_dci(connsm, 1);
 }
 
 /**
@@ -1949,15 +1965,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
     }
 
     /* Calculate data channel index of next connection event */
-    if (CONN_F_CSA2_SUPP(connsm)) {
-        connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
-    } else {
-        while (latency > 0) {
-            connsm->last_unmapped_chan = connsm->unmapped_chan;
-            connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
-            --latency;
-        }
-    }
+    connsm->data_chan_index = ble_ll_conn_calc_dci(connsm, latency);
 
     /*
      * If we are trying to terminate connection, check if next wake time is

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3acdf385/net/nimble/controller/test/src/ble_ll_csa2_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/test/src/ble_ll_csa2_test.c b/net/nimble/controller/test/src/ble_ll_csa2_test.c
index 9ba882c..6d199ee 100644
--- a/net/nimble/controller/test/src/ble_ll_csa2_test.c
+++ b/net/nimble/controller/test/src/ble_ll_csa2_test.c
@@ -53,15 +53,15 @@ TEST_CASE(ble_ll_csa2_test_1)
     conn.chanmap[3] = 0x1f;
 
     conn.event_cntr = 1;
-    rc = ble_ll_conn_calc_dci(&conn);
+    rc = ble_ll_conn_calc_dci(&conn, 0);
     TEST_ASSERT(rc == 20);
 
     conn.event_cntr = 2;
-    rc = ble_ll_conn_calc_dci(&conn);
+    rc = ble_ll_conn_calc_dci(&conn, 0);
     TEST_ASSERT(rc == 6);
 
     conn.event_cntr = 3;
-    rc = ble_ll_conn_calc_dci(&conn);
+    rc = ble_ll_conn_calc_dci(&conn, 0);
     TEST_ASSERT(rc == 21);
 }
 
@@ -95,15 +95,15 @@ TEST_CASE(ble_ll_csa2_test_2)
     conn.chanmap[4] = 0x1e;
 
     conn.event_cntr = 6;
-    rc = ble_ll_conn_calc_dci(&conn);
+    rc = ble_ll_conn_calc_dci(&conn, 0);
     TEST_ASSERT(rc == 23);
 
     conn.event_cntr = 7;
-    rc = ble_ll_conn_calc_dci(&conn);
+    rc = ble_ll_conn_calc_dci(&conn, 0);
     TEST_ASSERT(rc == 9);
 
     conn.event_cntr = 8;
-    rc = ble_ll_conn_calc_dci(&conn);
+    rc = ble_ll_conn_calc_dci(&conn, 0);
     TEST_ASSERT(rc == 34);
 }
 


[10/14] incubator-mynewt-core git commit: nimble/controller: Use single function for DCI calculation

Posted by an...@apache.org.
nimble/controller: Use single function for DCI calculation

Select CSA #1 or #2 from within ble_ll_conn_calc_dci.


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

Branch: refs/heads/bluetooth5
Commit: 6b57da91fd474655a8a1e8342b05ae84b0b9e41a
Parents: 2227104
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Tue Apr 11 11:30:31 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Tue Apr 11 11:30:31 2017 +0200

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll_conn.h |  2 +-
 net/nimble/controller/src/ble_ll_conn.c         | 20 +++++++++++++-------
 .../controller/test/src/ble_ll_csa2_test.c      | 16 ++++++++++------
 3 files changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6b57da91/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 47b2e48..3267cda 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -288,7 +288,7 @@ struct ble_ll_conn_sm
 struct ble_ll_conn_sm *ble_ll_conn_find_active_conn(uint16_t handle);
 
 /* required for unit testing */
-uint8_t ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn);
+uint8_t ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6b57da91/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 b827182..6d3e5e5 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -637,7 +637,7 @@ ble_ll_conn_csa2_prng(uint16_t counter, uint16_t ch_id)
     return prn_e;
 }
 
-uint8_t
+static uint8_t
 ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn)
 {
     uint16_t channel_unmapped;
@@ -679,6 +679,10 @@ ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn)
     uint8_t remap_index;
     uint8_t bitpos;
 
+    if (CONN_F_CSA2_SUPP(conn)) {
+        return ble_ll_conn_calc_dci_csa2(conn);
+    }
+
     /* Get next unmapped channel */
     curchan = conn->last_unmapped_chan + conn->hop_inc;
     if (curchan > BLE_PHY_NUM_DATA_CHANS) {
@@ -1571,18 +1575,20 @@ 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 use_csa2)
+ble_ll_conn_set_csa(struct ble_ll_conn_sm *connsm, bool chsel)
 {
     /* calculate the next data channel */
-    if (use_csa2) {
+    if (chsel) {
         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;
+
         connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
+        return;
     }
+
+    connsm->last_unmapped_chan = 0;
+    connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
 }
 
 /**
@@ -1944,7 +1950,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
 
     /* Calculate data channel index of next connection event */
     if (CONN_F_CSA2_SUPP(connsm)) {
-        connsm->data_chan_index = ble_ll_conn_calc_dci_csa2(connsm);
+        connsm->data_chan_index = ble_ll_conn_calc_dci(connsm);
     } else {
         while (latency > 0) {
             connsm->last_unmapped_chan = connsm->unmapped_chan;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6b57da91/net/nimble/controller/test/src/ble_ll_csa2_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/test/src/ble_ll_csa2_test.c b/net/nimble/controller/test/src/ble_ll_csa2_test.c
index 3cf8101..9ba882c 100644
--- a/net/nimble/controller/test/src/ble_ll_csa2_test.c
+++ b/net/nimble/controller/test/src/ble_ll_csa2_test.c
@@ -36,6 +36,8 @@ TEST_CASE(ble_ll_csa2_test_1)
 
     memset(&conn, 0, sizeof(conn));
 
+    CONN_F_CSA2_SUPP(&conn) = 1;
+
     /*
      * based on sample data from CoreSpec 5.0 Vol 6 Part C 3.1
      * (all channels used)
@@ -51,15 +53,15 @@ TEST_CASE(ble_ll_csa2_test_1)
     conn.chanmap[3] = 0x1f;
 
     conn.event_cntr = 1;
-    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    rc = ble_ll_conn_calc_dci(&conn);
     TEST_ASSERT(rc == 20);
 
     conn.event_cntr = 2;
-    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    rc = ble_ll_conn_calc_dci(&conn);
     TEST_ASSERT(rc == 6);
 
     conn.event_cntr = 3;
-    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    rc = ble_ll_conn_calc_dci(&conn);
     TEST_ASSERT(rc == 21);
 }
 
@@ -76,6 +78,8 @@ TEST_CASE(ble_ll_csa2_test_2)
 
     memset(&conn, 0, sizeof(conn));
 
+    CONN_F_CSA2_SUPP(&conn) = 1;
+
     /*
      * based on sample data from CoreSpec 5.0 Vol 6 Part C 3.2
      * (9 channels used)
@@ -91,15 +95,15 @@ TEST_CASE(ble_ll_csa2_test_2)
     conn.chanmap[4] = 0x1e;
 
     conn.event_cntr = 6;
-    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    rc = ble_ll_conn_calc_dci(&conn);
     TEST_ASSERT(rc == 23);
 
     conn.event_cntr = 7;
-    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    rc = ble_ll_conn_calc_dci(&conn);
     TEST_ASSERT(rc == 9);
 
     conn.event_cntr = 8;
-    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    rc = ble_ll_conn_calc_dci(&conn);
     TEST_ASSERT(rc == 34);
 }
 


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

Posted by an...@apache.org.
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;


[04/14] incubator-mynewt-core git commit: nimble/controller: Add initial unit tests for controller

Posted by an...@apache.org.
nimble/controller: Add initial unit tests for controller

This adds unit tests boilerplate and initial unit tests for controller.
Currently only tests for Channel Selection Algorithm #2 are implemented.


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

Branch: refs/heads/bluetooth5
Commit: 9cf07fda600f04971bb894ff405d07ad80c588f3
Parents: 2566748
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Tue Apr 4 11:58:09 2017 +0200
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Fri Apr 7 13:59:51 2017 +0200

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll_conn.h |   3 +
 .../controller/include/controller/ble_ll_test.h |  35 ++++++
 net/nimble/controller/src/ble_ll_sched.c        |   1 +
 net/nimble/controller/src/ble_ll_xcvr.c         |   1 +
 net/nimble/controller/test/pkg.yml              |  33 +++++
 .../controller/test/src/ble_ll_csa2_test.c      | 119 +++++++++++++++++++
 net/nimble/controller/test/src/ble_ll_test.c    |  40 +++++++
 net/nimble/controller/test/syscfg.yml           |  21 ++++
 8 files changed, 253 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cf07fda/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 041504d..6e6f6d8 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -284,6 +284,9 @@ struct ble_ll_conn_sm
  */
 struct ble_ll_conn_sm *ble_ll_conn_find_active_conn(uint16_t handle);
 
+/* required for unit testing */
+uint8_t ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn);
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cf07fda/net/nimble/controller/include/controller/ble_ll_test.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_test.h b/net/nimble/controller/include/controller/ble_ll_test.h
new file mode 100644
index 0000000..32984c6
--- /dev/null
+++ b/net/nimble/controller/include/controller/ble_ll_test.h
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_LL_TEST_
+#define H_LL_TEST_
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int ble_ll_csa2_test_all(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cf07fda/net/nimble/controller/src/ble_ll_sched.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_sched.c b/net/nimble/controller/src/ble_ll_sched.c
index 4713f3d..7637ac9 100644
--- a/net/nimble/controller/src/ble_ll_sched.c
+++ b/net/nimble/controller/src/ble_ll_sched.c
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <assert.h>
 #include <string.h>
+#include "bsp/bsp.h"
 #include "os/os.h"
 #include "os/os_cputime.h"
 #include "ble/xcvr.h"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cf07fda/net/nimble/controller/src/ble_ll_xcvr.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_xcvr.c b/net/nimble/controller/src/ble_ll_xcvr.c
index 5718730..ca420e4 100644
--- a/net/nimble/controller/src/ble_ll_xcvr.c
+++ b/net/nimble/controller/src/ble_ll_xcvr.c
@@ -20,6 +20,7 @@
 #include <stdint.h>
 #include <stddef.h>
 #include <assert.h>
+#include <stddef.h>
 #include "syscfg/syscfg.h"
 #include "os/os_cputime.h"
 #include "controller/ble_phy.h"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cf07fda/net/nimble/controller/test/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/controller/test/pkg.yml b/net/nimble/controller/test/pkg.yml
new file mode 100644
index 0000000..11fe8ba
--- /dev/null
+++ b/net/nimble/controller/test/pkg.yml
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+pkg.name: net/nimble/controller/test
+pkg.type: unittest
+pkg.description: "NimBLE controller unit tests."
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.deps:
+    - test/testutil
+    - net/nimble/controller
+
+pkg.deps.SELFTEST:
+    - sys/console/stub
+    - sys/log/full
+    - sys/stats/stub
+    - net/nimble/transport/ram

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cf07fda/net/nimble/controller/test/src/ble_ll_csa2_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/test/src/ble_ll_csa2_test.c b/net/nimble/controller/test/src/ble_ll_csa2_test.c
new file mode 100644
index 0000000..3cf8101
--- /dev/null
+++ b/net/nimble/controller/test/src/ble_ll_csa2_test.c
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stddef.h>
+#include <string.h>
+#include "testutil/testutil.h"
+#include "controller/ble_ll_test.h"
+#include "controller/ble_ll_conn.h"
+
+TEST_CASE(ble_ll_csa2_test_1)
+{
+    struct ble_ll_conn_sm conn;
+    uint8_t rc;
+
+    /*
+     * Note: This test only verified mapped channel. Sample data also specifies
+     * prn_e and unmapped channel values but those would require extra access
+     * to internal state of algorithm which is not exposed.
+     */
+
+    memset(&conn, 0, sizeof(conn));
+
+    /*
+     * based on sample data from CoreSpec 5.0 Vol 6 Part C 3.1
+     * (all channels used)
+     */
+    conn.channel_id = ((0x8e89bed6 & 0xffff0000) >> 16) ^
+                       (0x8e89bed6 & 0x0000ffff);
+
+    conn.num_used_chans = 37;
+    conn.chanmap[0] = 0xff;
+    conn.chanmap[1] = 0xff;
+    conn.chanmap[2] = 0xff;
+    conn.chanmap[3] = 0xff;
+    conn.chanmap[3] = 0x1f;
+
+    conn.event_cntr = 1;
+    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    TEST_ASSERT(rc == 20);
+
+    conn.event_cntr = 2;
+    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    TEST_ASSERT(rc == 6);
+
+    conn.event_cntr = 3;
+    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    TEST_ASSERT(rc == 21);
+}
+
+TEST_CASE(ble_ll_csa2_test_2)
+{
+    struct ble_ll_conn_sm conn;
+    uint8_t rc;
+
+    /*
+     * Note: This test only verified mapped channel. Sample data also specifies
+     * prn_e and unmapped channel values but those would require extra access
+     * to internal state of algorithm which is not exposed.
+     */
+
+    memset(&conn, 0, sizeof(conn));
+
+    /*
+     * based on sample data from CoreSpec 5.0 Vol 6 Part C 3.2
+     * (9 channels used)
+     */
+    conn.channel_id = ((0x8e89bed6 & 0xffff0000) >> 16) ^
+                       (0x8e89bed6 & 0x0000ffff);
+
+    conn.num_used_chans = 9;
+    conn.chanmap[0] = 0x00;
+    conn.chanmap[1] = 0x06;
+    conn.chanmap[2] = 0xe0;
+    conn.chanmap[3] = 0x00;
+    conn.chanmap[4] = 0x1e;
+
+    conn.event_cntr = 6;
+    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    TEST_ASSERT(rc == 23);
+
+    conn.event_cntr = 7;
+    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    TEST_ASSERT(rc == 9);
+
+    conn.event_cntr = 8;
+    rc = ble_ll_conn_calc_dci_csa2(&conn);
+    TEST_ASSERT(rc == 34);
+}
+
+TEST_SUITE(ble_ll_csa2_test_suite)
+{
+    ble_ll_csa2_test_1();
+    ble_ll_csa2_test_2();
+}
+
+int
+ble_ll_csa2_test_all(void)
+{
+    ble_ll_csa2_test_1();
+    ble_ll_csa2_test_2();
+
+    return tu_any_failed;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cf07fda/net/nimble/controller/test/src/ble_ll_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/test/src/ble_ll_test.c b/net/nimble/controller/test/src/ble_ll_test.c
new file mode 100644
index 0000000..d18f26a
--- /dev/null
+++ b/net/nimble/controller/test/src/ble_ll_test.c
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "syscfg/syscfg.h"
+#include "controller/ble_ll_test.h"
+#include "os/os.h"
+#include "testutil/testutil.h"
+
+#if MYNEWT_VAL(SELFTEST)
+
+int
+main(int argc, char **argv)
+{
+    ts_config.ts_print_results = 1;
+    tu_parse_args(argc, argv);
+
+    tu_init();
+
+    ble_ll_csa2_test_all();
+
+    return tu_any_failed;
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cf07fda/net/nimble/controller/test/syscfg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/controller/test/syscfg.yml b/net/nimble/controller/test/syscfg.yml
new file mode 100644
index 0000000..47a61a2
--- /dev/null
+++ b/net/nimble/controller/test/syscfg.yml
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Package: net/nimble/controller/test
+
+syscfg.vals:


[14/14] incubator-mynewt-core git commit: This closes #226.

Posted by an...@apache.org.
This closes #226.

Merge branch 'bluetooth5' of https://github.com/rymanluk/incubator-mynewt-core into bluetooth5


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

Branch: refs/heads/bluetooth5
Commit: 6fba2048eab01271107eb1f5792a647358a7bbaf
Parents: ebd6189 07d7daa
Author: Andrzej Kaczmarek <an...@codecoup.pl>
Authored: Wed Apr 12 00:45:13 2017 +0200
Committer: Andrzej Kaczmarek <an...@codecoup.pl>
Committed: Wed Apr 12 00:45:13 2017 +0200

----------------------------------------------------------------------
 net/nimble/controller/src/ble_ll_adv.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6fba2048/net/nimble/controller/src/ble_ll_adv.c
----------------------------------------------------------------------