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

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

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);
         }
     }