You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/09/22 02:12:34 UTC
[27/59] [abbrv] incubator-mynewt-core git commit: syscfg / sysinit
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/util/src/test/cbmem_test.c
----------------------------------------------------------------------
diff --git a/libs/util/src/test/cbmem_test.c b/libs/util/src/test/cbmem_test.c
deleted file mode 100644
index b486334..0000000
--- a/libs/util/src/test/cbmem_test.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * 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 <stdio.h>
-#include <string.h>
-
-#include "testutil/testutil.h"
-#include "util/cbmem.h"
-
-#define CBMEM1_BUF_SIZE (64 * 1024)
-
-struct cbmem cbmem1;
-uint8_t cbmem1_buf[CBMEM1_BUF_SIZE];
-uint8_t cbmem1_entry[1024];
-
-/*
- * Things to test.
- *
- * - Wrap of the circular buffer.
- * - Reading through all entries.
- */
-
-static void
-setup_cbmem1(void)
-{
- int i;
- int rc;
-
- rc = cbmem_init(&cbmem1, cbmem1_buf, CBMEM1_BUF_SIZE);
- TEST_ASSERT_FATAL(rc == 0, "cbmem_init() failed, non-zero RC = %d", rc);
-
- memset(cbmem1_entry, 0xff, sizeof(cbmem1_entry));
-
- /* Insert 65 1024 entries, and overflow buffer.
- * This should overflow two entries, because the buffer is sized for 64
- * entries, and then the headers themselves will eat into one of the entries,
- * so there should be a total of 63 entries.
- * Ensure no data corruption.
- */
- for (i = 0; i < 65; i++) {
- cbmem1_entry[0] = i;
- rc = cbmem_append(&cbmem1, cbmem1_entry, sizeof(cbmem1_entry));
- TEST_ASSERT_FATAL(rc == 0, "Could not append entry %d, rc = %d", i, rc);
- }
-}
-
-static int
-cbmem_test_case_1_walk(struct cbmem *cbmem, struct cbmem_entry_hdr *hdr,
- void *arg)
-{
- uint8_t expected;
- uint8_t actual;
- int rc;
-
- expected = *(uint8_t *) arg;
-
- rc = cbmem_read(cbmem, hdr, &actual, 0, sizeof(actual));
- TEST_ASSERT_FATAL(rc == 1, "Couldn't read 1 byte from cbmem");
- TEST_ASSERT_FATAL(actual == expected,
- "Actual doesn't equal expected (%d = %d)", actual, expected);
-
- *(uint8_t *) arg = ++expected;
-
- return (0);
-}
-
-TEST_CASE(cbmem_test_case_1)
-{
- int i;
- int rc;
-
- /* i starts at 2, for the 2 overwritten entries. */
- i = 2;
- rc = cbmem_walk(&cbmem1, cbmem_test_case_1_walk, &i);
- TEST_ASSERT_FATAL(rc == 0, "Could not walk cbmem tree! rc = %d", rc);
- TEST_ASSERT_FATAL(i == 65,
- "Did not go through every element of walk, %d processed", i - 2);
-
-}
-
-TEST_CASE(cbmem_test_case_2)
-{
- struct cbmem_entry_hdr *hdr;
- struct cbmem_iter iter;
- uint8_t i;
- uint8_t val;
- int rc;
-
- i = 2;
- cbmem_iter_start(&cbmem1, &iter);
- while (1) {
- hdr = cbmem_iter_next(&cbmem1, &iter);
- if (hdr == NULL) {
- break;
- }
-
- rc = cbmem_read(&cbmem1, hdr, &val, 0, sizeof(val));
- TEST_ASSERT_FATAL(rc == 1, "Couldn't read 1 byte from cbmem");
- TEST_ASSERT_FATAL(val == i, "Entry index does not match %d vs %d",
- val, i);
-
- i++;
- }
-
- /* i starts at 2, for the 2 overwritten entries */
- TEST_ASSERT_FATAL(i == 65,
- "Did not iterate through all 63 elements of CBMEM1, processed %d",
- i - 2);
-}
-
-TEST_CASE(cbmem_test_case_3)
-{
- struct cbmem_entry_hdr *hdr;
- struct cbmem_iter iter;
- uint16_t off;
- uint16_t len;
- uint8_t buf[128];
- int i;
- int rc;
-
- i = 0;
- cbmem_iter_start(&cbmem1, &iter);
- while (1) {
- hdr = cbmem_iter_next(&cbmem1, &iter);
- if (hdr == NULL) {
- break;
- }
-
- /* first ensure we can read the entire entry */
- off = 0;
- len = 0;
- while (1) {
- rc = cbmem_read(&cbmem1, hdr, buf, off, sizeof(buf));
- TEST_ASSERT_FATAL(rc >= 0,
- "Error reading from buffer rc=%d, off=%d,len=%d", rc, off,
- sizeof(buf));
- if (rc == 0) {
- break;
- }
- off += rc;
- len += rc;
- }
- TEST_ASSERT_FATAL(len == 1024,
- "Couldn't read full entry, expected %d got %d", 1024, len);
- i++;
-
- /* go apesh*t, and read data out of bounds, see what we get. */
- rc = cbmem_read(&cbmem1, hdr, buf, 2048, sizeof(buf));
- TEST_ASSERT_FATAL(rc < 0,
- "Reading invalid should return error, instead %d returned.",
- rc);
- }
-}
-
-TEST_SUITE(cbmem_test_suite)
-{
- setup_cbmem1();
- cbmem_test_case_1();
- cbmem_test_case_2();
- cbmem_test_case_3();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/util/src/test/util_test.c
----------------------------------------------------------------------
diff --git a/libs/util/src/test/util_test.c b/libs/util/src/test/util_test.c
deleted file mode 100644
index c236ab5..0000000
--- a/libs/util/src/test/util_test.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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 <assert.h>
-#include <stddef.h>
-#include "testutil/testutil.h"
-#include "util_test_priv.h"
-
-int
-util_test_all(void)
-{
- cbmem_test_suite();
- return tu_case_failed;
-}
-
-#ifdef MYNEWT_SELFTEST
-
-int
-main(int argc, char **argv)
-{
- tu_config.tc_print_results = 1;
- tu_init();
-
- util_test_all();
-
- return tu_any_failed;
-}
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/util/src/test/util_test_priv.h
----------------------------------------------------------------------
diff --git a/libs/util/src/test/util_test_priv.h b/libs/util/src/test/util_test_priv.h
deleted file mode 100644
index cc5533d..0000000
--- a/libs/util/src/test/util_test_priv.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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 __UTIL_TEST_PRIV_
-#define __UTIL_TEST_PRIV_
-
-int cbmem_test_suite(void);
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/util/test/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/util/test/pkg.yml b/libs/util/test/pkg.yml
new file mode 100644
index 0000000..3a8cf98
--- /dev/null
+++ b/libs/util/test/pkg.yml
@@ -0,0 +1,30 @@
+# 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: libs/util/test
+pkg.type: unittest
+pkg.description: "Util unit tests."
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.deps:
+ - libs/testutil
+ - libs/util
+
+pkg.deps.SELFTEST:
+ - libs/console/stub
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/util/test/src/cbmem_test.c
----------------------------------------------------------------------
diff --git a/libs/util/test/src/cbmem_test.c b/libs/util/test/src/cbmem_test.c
new file mode 100644
index 0000000..b486334
--- /dev/null
+++ b/libs/util/test/src/cbmem_test.c
@@ -0,0 +1,176 @@
+/**
+ * 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 <stdio.h>
+#include <string.h>
+
+#include "testutil/testutil.h"
+#include "util/cbmem.h"
+
+#define CBMEM1_BUF_SIZE (64 * 1024)
+
+struct cbmem cbmem1;
+uint8_t cbmem1_buf[CBMEM1_BUF_SIZE];
+uint8_t cbmem1_entry[1024];
+
+/*
+ * Things to test.
+ *
+ * - Wrap of the circular buffer.
+ * - Reading through all entries.
+ */
+
+static void
+setup_cbmem1(void)
+{
+ int i;
+ int rc;
+
+ rc = cbmem_init(&cbmem1, cbmem1_buf, CBMEM1_BUF_SIZE);
+ TEST_ASSERT_FATAL(rc == 0, "cbmem_init() failed, non-zero RC = %d", rc);
+
+ memset(cbmem1_entry, 0xff, sizeof(cbmem1_entry));
+
+ /* Insert 65 1024 entries, and overflow buffer.
+ * This should overflow two entries, because the buffer is sized for 64
+ * entries, and then the headers themselves will eat into one of the entries,
+ * so there should be a total of 63 entries.
+ * Ensure no data corruption.
+ */
+ for (i = 0; i < 65; i++) {
+ cbmem1_entry[0] = i;
+ rc = cbmem_append(&cbmem1, cbmem1_entry, sizeof(cbmem1_entry));
+ TEST_ASSERT_FATAL(rc == 0, "Could not append entry %d, rc = %d", i, rc);
+ }
+}
+
+static int
+cbmem_test_case_1_walk(struct cbmem *cbmem, struct cbmem_entry_hdr *hdr,
+ void *arg)
+{
+ uint8_t expected;
+ uint8_t actual;
+ int rc;
+
+ expected = *(uint8_t *) arg;
+
+ rc = cbmem_read(cbmem, hdr, &actual, 0, sizeof(actual));
+ TEST_ASSERT_FATAL(rc == 1, "Couldn't read 1 byte from cbmem");
+ TEST_ASSERT_FATAL(actual == expected,
+ "Actual doesn't equal expected (%d = %d)", actual, expected);
+
+ *(uint8_t *) arg = ++expected;
+
+ return (0);
+}
+
+TEST_CASE(cbmem_test_case_1)
+{
+ int i;
+ int rc;
+
+ /* i starts at 2, for the 2 overwritten entries. */
+ i = 2;
+ rc = cbmem_walk(&cbmem1, cbmem_test_case_1_walk, &i);
+ TEST_ASSERT_FATAL(rc == 0, "Could not walk cbmem tree! rc = %d", rc);
+ TEST_ASSERT_FATAL(i == 65,
+ "Did not go through every element of walk, %d processed", i - 2);
+
+}
+
+TEST_CASE(cbmem_test_case_2)
+{
+ struct cbmem_entry_hdr *hdr;
+ struct cbmem_iter iter;
+ uint8_t i;
+ uint8_t val;
+ int rc;
+
+ i = 2;
+ cbmem_iter_start(&cbmem1, &iter);
+ while (1) {
+ hdr = cbmem_iter_next(&cbmem1, &iter);
+ if (hdr == NULL) {
+ break;
+ }
+
+ rc = cbmem_read(&cbmem1, hdr, &val, 0, sizeof(val));
+ TEST_ASSERT_FATAL(rc == 1, "Couldn't read 1 byte from cbmem");
+ TEST_ASSERT_FATAL(val == i, "Entry index does not match %d vs %d",
+ val, i);
+
+ i++;
+ }
+
+ /* i starts at 2, for the 2 overwritten entries */
+ TEST_ASSERT_FATAL(i == 65,
+ "Did not iterate through all 63 elements of CBMEM1, processed %d",
+ i - 2);
+}
+
+TEST_CASE(cbmem_test_case_3)
+{
+ struct cbmem_entry_hdr *hdr;
+ struct cbmem_iter iter;
+ uint16_t off;
+ uint16_t len;
+ uint8_t buf[128];
+ int i;
+ int rc;
+
+ i = 0;
+ cbmem_iter_start(&cbmem1, &iter);
+ while (1) {
+ hdr = cbmem_iter_next(&cbmem1, &iter);
+ if (hdr == NULL) {
+ break;
+ }
+
+ /* first ensure we can read the entire entry */
+ off = 0;
+ len = 0;
+ while (1) {
+ rc = cbmem_read(&cbmem1, hdr, buf, off, sizeof(buf));
+ TEST_ASSERT_FATAL(rc >= 0,
+ "Error reading from buffer rc=%d, off=%d,len=%d", rc, off,
+ sizeof(buf));
+ if (rc == 0) {
+ break;
+ }
+ off += rc;
+ len += rc;
+ }
+ TEST_ASSERT_FATAL(len == 1024,
+ "Couldn't read full entry, expected %d got %d", 1024, len);
+ i++;
+
+ /* go apesh*t, and read data out of bounds, see what we get. */
+ rc = cbmem_read(&cbmem1, hdr, buf, 2048, sizeof(buf));
+ TEST_ASSERT_FATAL(rc < 0,
+ "Reading invalid should return error, instead %d returned.",
+ rc);
+ }
+}
+
+TEST_SUITE(cbmem_test_suite)
+{
+ setup_cbmem1();
+ cbmem_test_case_1();
+ cbmem_test_case_2();
+ cbmem_test_case_3();
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/util/test/src/util_test.c
----------------------------------------------------------------------
diff --git a/libs/util/test/src/util_test.c b/libs/util/test/src/util_test.c
new file mode 100644
index 0000000..d528568
--- /dev/null
+++ b/libs/util/test/src/util_test.c
@@ -0,0 +1,46 @@
+/**
+ * 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 <assert.h>
+#include <stddef.h>
+#include "syscfg/syscfg.h"
+#include "testutil/testutil.h"
+#include "util_test_priv.h"
+
+int
+util_test_all(void)
+{
+ cbmem_test_suite();
+ return tu_case_failed;
+}
+
+#if MYNEWT_VAL(SELFTEST)
+
+int
+main(int argc, char **argv)
+{
+ tu_config.tc_print_results = 1;
+ tu_init();
+
+ util_test_all();
+
+ return tu_any_failed;
+}
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/util/test/src/util_test_priv.h
----------------------------------------------------------------------
diff --git a/libs/util/test/src/util_test_priv.h b/libs/util/test/src/util_test_priv.h
new file mode 100644
index 0000000..cc5533d
--- /dev/null
+++ b/libs/util/test/src/util_test_priv.h
@@ -0,0 +1,25 @@
+/**
+ * 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 __UTIL_TEST_PRIV_
+#define __UTIL_TEST_PRIV_
+
+int cbmem_test_suite(void);
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/wifi_mgmt/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/wifi_mgmt/pkg.yml b/libs/wifi_mgmt/pkg.yml
index ebe582c..711dc75 100644
--- a/libs/wifi_mgmt/pkg.yml
+++ b/libs/wifi_mgmt/pkg.yml
@@ -25,11 +25,10 @@ pkg.keywords:
pkg.deps:
- "@apache-mynewt-core/libs/os"
- "@apache-mynewt-core/libs/util"
-pkg.reqs:
- - console
-pkg.cflags.SHELL:
- - -DSHELL_PRESENT
-
-pkg.deps.TEST:
- - libs/testutil
+pkg.deps.WIFI_MGMT_CLI:
+ - libs/shell
+pkg.syscfg_defs:
+ WIFI_MGMT_CLI:
+ description: 'TBD'
+ value: 'MYNEWT_PKG_LIBS_SHELL'
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/wifi_mgmt/src/wifi.c
----------------------------------------------------------------------
diff --git a/libs/wifi_mgmt/src/wifi.c b/libs/wifi_mgmt/src/wifi.c
index b5b6a72..b96a2ed 100644
--- a/libs/wifi_mgmt/src/wifi.c
+++ b/libs/wifi_mgmt/src/wifi.c
@@ -338,7 +338,7 @@ wifi_task(void *arg)
int
wifi_task_init(uint8_t prio, os_stack_t *stack, uint16_t stack_size)
{
-#ifdef SHELL_PRESENT
+#if MYNEWT_VAL(WIFI_MGMT_CLI)
shell_cmd_register(&wifi_cli_cmd);
#endif
os_eventq_init(&wifi_evq);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/wifi_mgmt/src/wifi_cli.c
----------------------------------------------------------------------
diff --git a/libs/wifi_mgmt/src/wifi_cli.c b/libs/wifi_mgmt/src/wifi_cli.c
index 4cd9552..350418f 100644
--- a/libs/wifi_mgmt/src/wifi_cli.c
+++ b/libs/wifi_mgmt/src/wifi_cli.c
@@ -16,7 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifdef SHELL_PRESENT
+
+#include "syscfg/syscfg.h"
+
+#if MYNEWT_VAL(WIFI_MGMT_CLI)
+
#include <stddef.h>
#include <string.h>
#include <assert.h>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/libs/wifi_mgmt/src/wifi_priv.h
----------------------------------------------------------------------
diff --git a/libs/wifi_mgmt/src/wifi_priv.h b/libs/wifi_mgmt/src/wifi_priv.h
index dfba81d..d7fbb1f 100644
--- a/libs/wifi_mgmt/src/wifi_priv.h
+++ b/libs/wifi_mgmt/src/wifi_priv.h
@@ -20,7 +20,9 @@
#ifndef __WIFI_PRIV_H__
#define __WIFI_PRIV_H__
-#ifdef SHELL_PRESENT
+#include "syscfg/syscfg.h"
+
+#if MYNEWT_VAL(WIFI_MGMT_CLI)
extern struct shell_cmd wifi_cli_cmd;
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/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 2be8425..6f48ac6 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -287,8 +287,7 @@ struct ble_dev_addr
/*--- External API ---*/
/* Initialize the Link Layer */
-int
-ble_ll_init(uint8_t ll_task_prio, uint8_t num_acl_pkts, uint16_t acl_pkt_size);
+void ble_ll_init(void);
/* Reset the Link Layer */
int ble_ll_reset(void);
@@ -390,7 +389,7 @@ void ble_ll_log(uint8_t id, uint8_t arg8, uint16_t arg16, uint32_t arg32);
#define ble_ll_log(m,n,o,p)
#endif
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/* LTK 0x4C68384139F574D836BCF34E9DFB01BF */
extern const uint8_t g_bletest_LTK[];
extern uint16_t g_bletest_EDIV;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/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 38a3a22..0b15d06 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -53,7 +53,7 @@
/* Definition for RSSI when the RSSI is unknown */
#define BLE_LL_CONN_UNKNOWN_RSSI (127)
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/*
* Encryption states for a connection
*
@@ -232,7 +232,7 @@ struct ble_ll_conn_sm
/* For scheduling connections */
struct ble_ll_sched_item conn_sch;
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
struct os_callout_func auth_pyld_timer;
#endif
@@ -244,7 +244,7 @@ struct ble_ll_conn_sm
* allocate these from a pool? Not sure what to do. For now, I just use
* a large chunk of memory per connection.
*/
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
struct ble_ll_conn_enc_data enc_data;
#endif
/*
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/controller/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/controller/pkg.yml b/net/nimble/controller/pkg.yml
index 8e52aba..19846bb 100644
--- a/net/nimble/controller/pkg.yml
+++ b/net/nimble/controller/pkg.yml
@@ -34,5 +34,171 @@ pkg.deps:
- sys/stats
- net/nimble
-pkg.features:
- - BLE_DEVICE
+pkg.init_function: ble_ll_init
+pkg.init_stage: 2
+
+pkg.syscfg_defs:
+ BLE_DEVICE:
+ description: 'TBD'
+ value: 1
+
+ BLE_LL_PRIO:
+ description: 'TBD'
+ type: 'task_priority'
+ value: 0
+
+ # Sleep clock accuracy (sca). This is the amount of drift in the system
+ # during when the device is sleeping (in parts per million).
+ #
+ # NOTE: 'the' master sca is an enumerated value based on the sca. Rather
+ # than have a piece of code calculate this value, the developer must set
+ # this value based on the value of the SCA using the following table:
+ #
+ # SCA between 251 and 500 ppm (inclusive); master sca = 0
+ # SCA between 151 and 250 ppm (inclusive); master sca = 1
+ # SCA between 101 and 150 ppm (inclusive); master sca = 2
+ # SCA between 76 and 100 ppm (inclusive); master sca = 3
+ # SCA between 51 and 75 ppm (inclusive); master sca = 4
+ # SCA between 31 and 50 ppm (inclusive); master sca = 5
+ # SCA between 21 and 30 ppm (inclusive); master sca = 6
+ # SCA between 0 and 20 ppm (inclusive); master sca = 7
+ #
+ # For example:
+ # if your clock drift is 101 ppm, your master should be set to 2.
+ # if your clock drift is 20, your master sca should be set to 7.
+ #
+ # The values provided below are merely meant to be an example and should
+ # be replaced by values appropriate for your platform.
+ BLE_LL_OUR_SCA:
+ description: 'TBD'
+ value: '60' # in ppm
+
+ BLE_LL_MASTER_SCA:
+ description: 'TBD'
+ value: '4'
+
+ BLE_LL_TX_PWR_DBM:
+ description: 'Transmit power level.'
+ value: '0'
+
+ BLE_NUM_COMP_PKT_RATE:
+ description: >
+ Determines the maximum rate at which the controller will send the
+ number of completed packets event to the host. Rate is in os time
+ ticks.
+ value: '((2000 * OS_TICKS_PER_SEC) / 1000)'
+
+ BLE_LL_MFRG_ID:
+ description: >
+ Manufacturer ID. Should be set to unique ID per manufacturer.
+ value: '0xFFFF'
+
+ # Configuration items for the number of duplicate advertisers and the
+ # number of advertisers from which we have heard a scan response.
+ BLE_LL_NUM_SCAN_DUP_ADVS:
+ description: 'TBD'
+ value: '8'
+ BLE_LL_NUM_SCAN_RSP_ADVS:
+ description: 'TBD'
+ value: '8'
+
+ BLE_LL_WHITELIST_SIZE:
+ description: 'Size of the LL whitelist.'
+ value: '8'
+
+ BLE_LL_RESOLV_LIST_SIZE:
+ description: 'Size of the resolving list.'
+ value: '4'
+
+ # Data length management definitions for connections. These define the
+ # maximum size of the PDU's that will be sent and/or received in a
+ # connection.
+ BLE_LL_MAX_PKT_SIZE:
+ description: 'TBD'
+ value: '251'
+ BLE_LL_SUPP_MAX_RX_BYTES:
+ description: 'TBD'
+ value: 'MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE'
+ BLE_LL_SUPP_MAX_TX_BYTES:
+ description: 'TBD'
+ value: 'MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE'
+ BLE_LL_CONN_INIT_MAX_TX_BYTES:
+ description: 'TBD'
+ value: '27'
+
+ # The number of slots that will be allocated to each connection
+ BLE_LL_CONN_INIT_SLOTS:
+ description: 'TBD'
+ value: '2'
+
+ # The number of random bytes to store
+ BLE_LL_RNG_BUFSIZE:
+ description: 'TBD'
+ value: '32'
+
+ # Configuration for LL supported features.
+ #
+ # There are a total 8 features that the LL can support. These can be found
+ # in v4.2, Vol 6 Part B Section 4.6.
+ #
+ # These feature definitions are used to inform a host or other controller
+ # about the LL features supported by the controller.
+ #
+ # NOTE: 'the' controller always supports extended reject indicate and thus
+ # is not listed here.
+
+
+ BLE_LL_CFG_FEAT_LE_ENCRYPTION:
+ description: >
+ This option enables/disables encryption support in the controller.
+ This option saves both both code and RAM.
+ value: '1'
+
+ BLE_LL_CFG_FEAT_CONN_PARAM_REQ:
+ description: >
+ This option enables/disables the connection parameter request
+ procedure. This is implemented in the controller but is disabled
+ by default.
+ value: '0'
+
+ BLE_LL_CFG_FEAT_SLAVE_INIT_FEAT_XCHG:
+ description: >
+ This option allows a slave to initiate the feature exchange
+ procedure. This feature is implemented but currently has no impact
+ on code or ram size
+ value: '1'
+
+ BLE_LL_CFG_FEAT_LE_PING:
+ description: >
+ This option allows a controller to send/receive LE pings.
+ Currently, this feature is not implemented by the controller so
+ turning it on or off has no effect.
+ value: '1'
+
+ BLE_LL_CFG_FEAT_DATA_LEN_EXT:
+ description: >
+ This option enables/disables the data length update procedure in
+ the controller. If enabled, the controller is allowed to change the
+ size of tx/rx pdu's used in a connection. This option has only
+ minor impact on code size and non on RAM.
+ value: '1'
+
+ BLE_LL_CFG_FEAT_LL_PRIVACY:
+ description: >
+ This option is used to enable/disable LL privacy. Currently, this
+ feature is not supported by the nimble controller.
+ value: '1'
+
+ BLE_LL_CFG_FEAT_EXT_SCAN_FILT:
+ description: >
+ This option is used to enable/disable the extended scanner filter
+ policy feature. Currently, this feature is not supported by the
+ nimble controller.
+ value: '0'
+
+ BLE_LL_ACL_PKT_COUNT:
+ description: 'TBD'
+ value: 12
+ BLE_LL_ACL_PKT_SIZE:
+ description: 'TBD'
+ value: 260
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/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 1a4f558..978497a 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -20,6 +20,8 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "sysinit/sysinit.h"
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "stats/stats.h"
#include "bsp/bsp.h"
@@ -186,6 +188,12 @@ os_stack_t g_ble_ll_stack[BLE_LL_STACK_SIZE];
struct os_mempool g_ble_ll_hci_ev_pool;
static void *ble_ll_hci_os_event_buf;
+/** Our global device address (public) */
+uint8_t g_dev_addr[BLE_DEV_ADDR_LEN];
+
+/** Our random address */
+uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
+
/* XXX: temporary logging until we transition to real logging */
#ifdef BLE_LL_LOG
struct ble_ll_log
@@ -872,7 +880,7 @@ ble_ll_task(void *arg)
ble_phy_init();
/* Set output power to 1mW (0 dBm) */
- ble_phy_txpwr_set(NIMBLE_OPT_LL_TX_PWR_DBM);
+ ble_phy_txpwr_set(MYNEWT_VAL(BLE_LL_TX_PWR_DBM));
/* Tell the host that we are ready to receive packets */
ble_ll_hci_send_noop();
@@ -1089,7 +1097,7 @@ ble_ll_reset(void)
ble_ll_whitelist_clear();
/* Reset resolving list */
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
ble_ll_resolv_list_reset();
#endif
@@ -1099,13 +1107,30 @@ ble_ll_reset(void)
return rc;
}
+static void
+ble_ll_seed_prng(void)
+{
+ uint32_t seed;
+ int i;
+
+ /* Seed random number generator with least significant bytes of device
+ * address.
+ */
+ seed = 0;
+ for (i = 0; i < 4; ++i) {
+ seed |= g_dev_addr[i];
+ seed <<= 8;
+ }
+ srand(seed);
+}
+
/**
* Initialize the Link Layer. Should be called only once
*
* @return int
*/
-int
-ble_ll_init(uint8_t ll_task_prio, uint8_t num_acl_pkts, uint16_t acl_pkt_size)
+void
+ble_ll_init(void)
{
int rc;
uint8_t features;
@@ -1115,8 +1140,8 @@ ble_ll_init(uint8_t ll_task_prio, uint8_t num_acl_pkts, uint16_t acl_pkt_size)
lldata = &g_ble_ll_data;
/* Set acl pkt size and number */
- lldata->ll_num_acl_pkts = num_acl_pkts;
- lldata->ll_acl_pkt_size = acl_pkt_size;
+ lldata->ll_num_acl_pkts = MYNEWT_VAL(BLE_LL_ACL_PKT_COUNT);
+ lldata->ll_acl_pkt_size = MYNEWT_VAL(BLE_LL_ACL_PKT_SIZE);
/* Initialize eventq */
os_eventq_init(&lldata->ll_evq);
@@ -1135,13 +1160,13 @@ ble_ll_init(uint8_t ll_task_prio, uint8_t num_acl_pkts, uint16_t acl_pkt_size)
ble_ll_hci_os_event_buf = malloc(
OS_MEMPOOL_BYTES(16, sizeof (struct os_event)));
- assert(ble_ll_hci_os_event_buf != NULL);
+ SYSINIT_PANIC_ASSERT(ble_ll_hci_os_event_buf != NULL);
/* Create memory pool of OS events */
rc = os_mempool_init(&g_ble_ll_hci_ev_pool, 16,
sizeof (struct os_event), ble_ll_hci_os_event_buf,
"g_ble_ll_hci_ev_pool");
- assert(rc == 0);
+ SYSINIT_PANIC_ASSERT(rc == 0);
/* Initialize LL HCI */
ble_ll_hci_init();
@@ -1161,45 +1186,50 @@ ble_ll_init(uint8_t ll_task_prio, uint8_t num_acl_pkts, uint16_t acl_pkt_size)
/* Set the supported features. NOTE: we always support extended reject. */
features = BLE_LL_FEAT_EXTENDED_REJ;
-#if (BLE_LL_CFG_FEAT_DATA_LEN_EXT == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_DATA_LEN_EXT) == 1)
features |= BLE_LL_FEAT_DATA_LEN_EXT;
#endif
-#if (BLE_LL_CFG_FEAT_CONN_PARAM_REQ == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_CONN_PARAM_REQ) == 1)
features |= BLE_LL_FEAT_CONN_PARM_REQ;
#endif
-#if (BLE_LL_CFG_FEAT_SLAVE_INIT_FEAT_XCHG == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_SLAVE_INIT_FEAT_XCHG) == 1)
features |= BLE_LL_FEAT_SLAVE_INIT;
#endif
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
features |= BLE_LL_FEAT_LE_ENCRYPTION;
#endif
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
features |= (BLE_LL_FEAT_LL_PRIVACY | BLE_LL_FEAT_EXT_SCAN_FILT);
ble_ll_resolv_init();
#endif
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
features |= BLE_LL_FEAT_LE_PING;
#endif
/* Initialize random number generation */
ble_ll_rand_init();
+ /* XXX: This really doesn't belong here, as the address probably has not
+ * been set yet.
+ */
+ ble_ll_seed_prng();
+
lldata->ll_supp_features = features;
/* Initialize the LL task */
- os_task_init(&g_ble_ll_task, "ble_ll", ble_ll_task, NULL, ll_task_prio,
- OS_WAIT_FOREVER, g_ble_ll_stack, BLE_LL_STACK_SIZE);
+ os_task_init(&g_ble_ll_task, "ble_ll", ble_ll_task, NULL,
+ MYNEWT_VAL(BLE_LL_PRIO), OS_WAIT_FOREVER, g_ble_ll_stack,
+ BLE_LL_STACK_SIZE);
rc = stats_init_and_reg(STATS_HDR(ble_ll_stats),
STATS_SIZE_INIT_PARMS(ble_ll_stats, STATS_SIZE_32),
STATS_NAME_INIT_PARMS(ble_ll_stats),
"ble_ll");
+ SYSINIT_PANIC_ASSERT(rc == 0);
- ble_hci_trans_cfg_ll(ble_ll_hci_cmd_rx, NULL,
- ble_ll_hci_acl_rx, NULL);
- return rc;
+ ble_hci_trans_cfg_ll(ble_ll_hci_cmd_rx, NULL, ble_ll_hci_acl_rx, NULL);
}
#ifdef BLE_LL_LOG
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/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 1f43a5d..01de299 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
#include <assert.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "bsp/bsp.h"
#include "ble/xcvr.h"
@@ -120,7 +121,7 @@ struct ble_ll_adv_sm g_ble_ll_adv_sm;
#define BLE_LL_ADV_DIRECT_SCHED_MAX_USECS (502)
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
void
ble_ll_adv_chk_rpa_timeout(struct ble_ll_adv_sm *advsm)
{
@@ -373,12 +374,12 @@ ble_ll_adv_tx_start_cb(struct ble_ll_sched_item *sch)
goto adv_tx_done;
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/* XXX: automatically do this in the phy based on channel? */
ble_phy_encrypt_disable();
#endif
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
advsm->adv_rpa_index = -1;
if (ble_ll_resolv_enabled()) {
ble_phy_resolv_list_enable();
@@ -578,7 +579,7 @@ ble_ll_adv_set_adv_params(uint8_t *cmd)
return BLE_ERR_INV_HCI_CMD_PARMS;
}
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (own_addr_type > BLE_HCI_ADV_OWN_ADDR_RANDOM) {
/* Copy peer address */
memcpy(advsm->peer_addr, cmd + 7, BLE_DEV_ADDR_LEN);
@@ -696,7 +697,7 @@ ble_ll_adv_sm_start(struct ble_ll_adv_sm *advsm)
}
/* This will generate an RPA for both initiator addr and adva */
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
ble_ll_adv_chk_rpa_timeout(advsm);
#endif
@@ -759,7 +760,7 @@ ble_ll_adv_scheduled(uint32_t sch_start)
int
ble_ll_adv_read_txpwr(uint8_t *rspbuf, uint8_t *rsplen)
{
- rspbuf[0] = NIMBLE_OPT_LL_TX_PWR_DBM;
+ rspbuf[0] = MYNEWT_VAL(BLE_LL_TX_PWR_DBM);
*rsplen = 1;
return BLE_ERR_SUCCESS;
}
@@ -909,7 +910,7 @@ ble_ll_adv_rx_req(uint8_t pdu_type, struct os_mbuf *rxpdu)
peer_addr_type = txadd;
resolved = 0;
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (ble_ll_is_rpa(peer, txadd) && ble_ll_resolv_enabled()) {
advsm->adv_rpa_index = ble_hw_resolv_list_match();
if (advsm->adv_rpa_index >= 0) {
@@ -1000,7 +1001,7 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
(advsm->adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD)) {
ident_addr = inita;
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (resolved) {
ident_addr = g_ble_ll_resolv_list[advsm->adv_rpa_index].rl_identity_addr;
addr_type = g_ble_ll_resolv_list[advsm->adv_rpa_index].rl_addr_type;
@@ -1014,7 +1015,7 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
}
if (valid) {
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (resolved) {
/* Retain the resolvable private address that we received. */
memcpy(advsm->adv_rpa, inita, BLE_DEV_ADDR_LEN);
@@ -1296,7 +1297,7 @@ ble_ll_adv_event_done(void *arg)
}
/* We need to regenerate our RPA's if we have passed timeout */
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
ble_ll_adv_chk_rpa_timeout(advsm);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/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 cb0f89b..8ec6bca 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
#include <assert.h>
+#include "syscfg/syscfg.h"
#include "bsp/bsp.h"
#include "os/os.h"
#include "nimble/ble.h"
@@ -124,7 +125,7 @@ struct ble_ll_empty_pdu
};
/* We cannot have more than 254 connections given our current implementation */
-#if (NIMBLE_OPT_MAX_CONNECTIONS >= 255)
+#if (MYNEWT_VAL(BLE_MAX_CONNECTIONS) >= 255)
#error "Maximum # of connections is 254"
#endif
@@ -144,7 +145,7 @@ struct ble_ll_conn_sm *g_ble_ll_conn_create_sm;
struct ble_ll_conn_sm *g_ble_ll_conn_cur_sm;
/* Connection state machine array */
-struct ble_ll_conn_sm g_ble_ll_conn_sm[NIMBLE_OPT_MAX_CONNECTIONS];
+struct ble_ll_conn_sm g_ble_ll_conn_sm[MYNEWT_VAL(BLE_MAX_CONNECTIONS)];
/* List of active connections */
struct ble_ll_conn_active_list g_ble_ll_conn_active_list;
@@ -211,7 +212,7 @@ STATS_NAME_START(ble_ll_conn_stats)
STATS_NAME(ble_ll_conn_stats, mic_failures)
STATS_NAME_END(ble_ll_conn_stats)
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/**
* Called to determine if the received PDU is an empty PDU or not.
*/
@@ -313,7 +314,7 @@ ble_ll_conn_find_active_conn(uint16_t handle)
struct ble_ll_conn_sm *connsm;
connsm = NULL;
- if ((handle != 0) && (handle <= NIMBLE_OPT_MAX_CONNECTIONS)) {
+ if ((handle != 0) && (handle <= MYNEWT_VAL(BLE_MAX_CONNECTIONS))) {
connsm = &g_ble_ll_conn_sm[handle - 1];
if (connsm->conn_state == BLE_LL_CONN_STATE_IDLE) {
connsm = NULL;
@@ -364,7 +365,7 @@ ble_ll_conn_calc_window_widening(struct ble_ll_conn_sm *connsm)
if (time_since_last_anchor > 0) {
delta_msec = cputime_ticks_to_usecs(time_since_last_anchor) / 1000;
total_sca_ppm = g_ble_sca_ppm_tbl[connsm->master_sca] +
- NIMBLE_OPT_LL_OUR_SCA;
+ MYNEWT_VAL(BLE_LL_OUR_SCA);
window_widening = (total_sca_ppm * delta_msec) / 1000;
}
@@ -598,7 +599,7 @@ ble_ll_conn_wait_txend(void *arg)
ble_ll_event_send(&connsm->conn_ev_end);
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
static void
ble_ll_conn_start_rx_encrypt(void *arg)
{
@@ -699,7 +700,7 @@ ble_ll_conn_chk_csm_flags(struct ble_ll_conn_sm *connsm)
{
uint8_t update_status;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (connsm->csmflags.cfbit.send_ltk_req) {
/*
* Send Long term key request event to host. If masked, we need to
@@ -789,7 +790,7 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm)
m = OS_MBUF_PKTHDR_TO_MBUF(pkthdr);
nextpkthdr = STAILQ_NEXT(pkthdr, omp_next);
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/*
* If we are encrypting, we are only allowed to send certain
* kinds of LL control PDU's. If none is enqueued, send empty pdu!
@@ -839,7 +840,7 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm)
if (cur_offset == 0) {
hdr_byte = ble_hdr->txinfo.hdr_byte & BLE_LL_DATA_HDR_LLID_MASK;
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (connsm->enc_data.enc_state > CONN_ENC_S_ENCRYPTED) {
/* We will allow a next packet if it itself is allowed */
pkthdr = OS_MBUF_PKTHDR(connsm->cur_tx_pdu);
@@ -854,7 +855,7 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm)
/* Empty PDU here. NOTE: header byte gets set later */
pktlen = 0;
cur_txlen = 0;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (connsm->enc_data.enc_state > CONN_ENC_S_ENCRYPTED) {
/* We will allow a next packet if it itself is allowed */
if (nextpkthdr && !ble_ll_ctrl_enc_allowed_pdu(nextpkthdr)) {
@@ -977,7 +978,7 @@ conn_tx_pdu:
txend_func = NULL;
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
int is_ctrl;
uint8_t llid;
uint8_t opcode;
@@ -1118,7 +1119,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
ble_phy_setchan(connsm->data_chan_index, connsm->access_addr,
connsm->crcinit);
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
ble_phy_resolv_list_disable();
#endif
@@ -1126,7 +1127,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
/* Set start time of transmission */
rc = ble_phy_tx_set_start_time(sch->start_time + XCVR_PROC_DELAY_USECS);
if (!rc) {
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (CONN_F_ENCRYPTED(connsm)) {
ble_phy_encrypt_enable(connsm->enc_data.tx_pkt_cntr,
connsm->enc_data.iv,
@@ -1148,7 +1149,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
rc = BLE_LL_SCHED_STATE_DONE;
}
} else {
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (CONN_F_ENCRYPTED(connsm)) {
ble_phy_encrypt_enable(connsm->enc_data.rx_pkt_cntr,
connsm->enc_data.iv,
@@ -1263,7 +1264,7 @@ ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime)
return rc;
}
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
/**
* Callback for the Authenticated payload timer. This function is called
* when the authenticated payload timer expires. When the authenticated
@@ -1337,7 +1338,7 @@ ble_ll_conn_master_init(struct ble_ll_conn_sm *connsm,
/* Set default ce parameters */
connsm->tx_win_size = BLE_LL_CONN_TX_WIN_MIN;
connsm->tx_win_off = 0;
- connsm->master_sca = NIMBLE_OPT_LL_MASTER_SCA;
+ connsm->master_sca = MYNEWT_VAL(BLE_LL_MASTER_SCA);
/* Hop increment is a random value between 5 and 16. */
connsm->hop_inc = (rand() % 12) + 5;
@@ -1465,12 +1466,12 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm)
connsm->eff_max_rx_octets = BLE_LL_CONN_SUPP_BYTES_MIN;
/* Reset encryption data */
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
memset(&connsm->enc_data, 0, sizeof(struct ble_ll_conn_enc_data));
connsm->enc_data.enc_state = CONN_ENC_S_UNENCRYPTED;
#endif
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
connsm->auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO;
CONN_F_LE_PING_SUPP(connsm) = 1;
os_callout_func_init(&connsm->auth_pyld_timer,
@@ -1558,7 +1559,7 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
/* Stop any control procedures that might be running */
os_callout_stop(&connsm->ctrl_proc_rsp_timer.cf_c);
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
os_callout_stop(&connsm->auth_pyld_timer.cf_c);
#endif
@@ -1738,7 +1739,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
* Calculate ce end time. For a slave, we need to add window widening and
* the transmit window if we still have one.
*/
- itvl = NIMBLE_OPT_LL_CONN_INIT_SLOTS * BLE_LL_SCHED_USECS_PER_SLOT;
+ itvl = MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS) * BLE_LL_SCHED_USECS_PER_SLOT;
if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
cur_ww = ble_ll_conn_calc_window_widening(connsm);
max_ww = (connsm->conn_itvl * (BLE_LL_CONN_ITVL_USECS/2)) - BLE_LL_IFS;
@@ -1803,7 +1804,7 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, uint32_t endtime)
usecs = 1250 + (connsm->tx_win_off * BLE_LL_CONN_TX_WIN_USECS);
connsm->anchor_point = endtime + cputime_usecs_to_ticks(usecs);
usecs = connsm->slave_cur_tx_win_usecs +
- (NIMBLE_OPT_LL_CONN_INIT_SLOTS * BLE_LL_SCHED_USECS_PER_SLOT);
+ (MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS) * BLE_LL_SCHED_USECS_PER_SLOT);
connsm->ce_end_time = connsm->anchor_point +
cputime_usecs_to_ticks(usecs);
connsm->slave_cur_window_widening = 0;
@@ -1891,7 +1892,7 @@ ble_ll_conn_event_end(void *arg)
connsm->slave_cur_tx_win_usecs = 0;
}
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
/*
* If we are encrypted and have passed the authenticated payload timeout
* we need to send an event to tell the host. Unfortunately, I think we
@@ -2290,7 +2291,7 @@ ble_ll_init_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
resolved = 0;
chk_wl = ble_ll_scan_whitelist_enabled();
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (ble_ll_is_rpa(adv_addr, addr_type) && ble_ll_resolv_enabled()) {
index = ble_hw_resolv_list_match();
if (index >= 0) {
@@ -2335,7 +2336,7 @@ ble_ll_init_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
/* Attempt to schedule new connection. Possible that this might fail */
endtime = ble_hdr->beg_cputime + BLE_TX_DUR_USECS_M(pyld_len);
if (!ble_ll_sched_master_new(connsm, endtime,
- NIMBLE_OPT_LL_CONN_INIT_SLOTS)) {
+ MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS))) {
/* Setup to transmit the connect request */
rc = ble_ll_conn_request_send(addr_type, adv_addr,
connsm->tx_win_off, index);
@@ -2497,7 +2498,7 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
goto conn_rx_data_pdu_end;
}
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
/*
* Reset authenticated payload timeout if valid MIC. NOTE: we dont
* check the MIC failure bit as that would have terminated the
@@ -2536,7 +2537,7 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
goto conn_rx_data_pdu_end;
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/*
* XXX: should we check to see if we are in a state where we
* might expect to get an encrypted PDU?
@@ -2682,14 +2683,14 @@ ble_ll_conn_rx_isr_end(struct os_mbuf *rxpdu)
conn_nesn = connsm->next_exp_seqnum;
if ((hdr_sn && conn_nesn) || (!hdr_sn && !conn_nesn)) {
connsm->next_exp_seqnum ^= 1;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (CONN_F_ENCRYPTED(connsm) && !ble_ll_conn_is_empty_pdu(rxpdu)) {
++connsm->enc_data.rx_pkt_cntr;
}
#endif
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
ble_ll_log(BLE_LL_LOG_ID_CONN_RX,
hdr_byte,
(uint16_t)connsm->tx_seqnum << 8 | conn_nesn,
@@ -2727,7 +2728,7 @@ ble_ll_conn_rx_isr_end(struct os_mbuf *rxpdu)
*/
txpdu = connsm->cur_tx_pdu;
if (txpdu) {
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (connsm->enc_data.tx_encrypted) {
++connsm->enc_data.tx_pkt_cntr;
}
@@ -2789,7 +2790,7 @@ chk_rx_terminate_ind:
} else {
/* A slave always replies */
reply = 1;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (is_ctrl && (opcode == BLE_LL_CTRL_PAUSE_ENC_RSP)) {
connsm->enc_data.enc_state = CONN_ENC_S_UNENCRYPTED;
}
@@ -2851,7 +2852,7 @@ ble_ll_conn_enqueue_pkt(struct ble_ll_conn_sm *connsm, struct os_mbuf *om,
}
lifo = 0;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (connsm->enc_data.enc_state > CONN_ENC_S_ENCRYPTED) {
uint8_t llid;
@@ -3125,17 +3126,17 @@ ble_ll_conn_module_reset(void)
conn_params = &g_ble_ll_conn_params;
max_phy_pyld = ble_phy_max_data_pdu_pyld();
- maxbytes = min(NIMBLE_OPT_LL_SUPP_MAX_RX_BYTES, max_phy_pyld);
+ maxbytes = min(MYNEWT_VAL(BLE_LL_SUPP_MAX_RX_BYTES), max_phy_pyld);
conn_params->supp_max_rx_octets = maxbytes;
conn_params->supp_max_rx_time =
BLE_TX_DUR_USECS_M(maxbytes + BLE_LL_DATA_MIC_LEN);
- maxbytes = min(NIMBLE_OPT_LL_SUPP_MAX_TX_BYTES, max_phy_pyld);
+ maxbytes = min(MYNEWT_VAL(BLE_LL_SUPP_MAX_TX_BYTES), max_phy_pyld);
conn_params->supp_max_tx_octets = maxbytes;
conn_params->supp_max_tx_time =
BLE_TX_DUR_USECS_M(maxbytes + BLE_LL_DATA_MIC_LEN);
- maxbytes = min(NIMBLE_OPT_LL_CONN_INIT_MAX_TX_BYTES, max_phy_pyld);
+ maxbytes = min(MYNEWT_VAL(BLE_LL_CONN_INIT_MAX_TX_BYTES), max_phy_pyld);
conn_params->conn_init_max_tx_octets = maxbytes;
conn_params->conn_init_max_tx_time =
BLE_TX_DUR_USECS_M(maxbytes + BLE_LL_DATA_MIC_LEN);
@@ -3171,7 +3172,7 @@ ble_ll_conn_module_init(void)
* the specification allows a handle of zero; we just avoid using it.
*/
connsm = &g_ble_ll_conn_sm[0];
- for (i = 0; i < NIMBLE_OPT_MAX_CONNECTIONS; ++i) {
+ for (i = 0; i < MYNEWT_VAL(BLE_MAX_CONNECTIONS); ++i) {
memset(connsm, 0, sizeof(struct ble_ll_conn_sm));
connsm->conn_handle = i + 1;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/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 f653ca6..3f3b77c 100644
--- a/net/nimble/controller/src/ble_ll_conn_hci.c
+++ b/net/nimble/controller/src/ble_ll_conn_hci.c
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
#include <assert.h>
+#include "syscfg/syscfg.h"
#include "bsp/bsp.h"
#include "os/os.h"
#include "nimble/ble.h"
@@ -228,7 +229,7 @@ ble_ll_conn_num_comp_pkts_event_send(void)
/* Check rate limit */
if ((uint32_t)(g_ble_ll_next_num_comp_pkt_evt - os_time_get()) <
- NIMBLE_OPT_NUM_COMP_PKT_RATE) {
+ MYNEWT_VAL(BLE_NUM_COMP_PKT_RATE)) {
return;
}
@@ -295,11 +296,11 @@ ble_ll_conn_num_comp_pkts_event_send(void)
if (event_sent) {
g_ble_ll_next_num_comp_pkt_evt = os_time_get() +
- NIMBLE_OPT_NUM_COMP_PKT_RATE;
+ MYNEWT_VAL(BLE_NUM_COMP_PKT_RATE);
}
}
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
/**
* Send a authenticated payload timeout event
*
@@ -928,7 +929,7 @@ ble_ll_conn_hci_set_chan_class(uint8_t *cmdbuf)
return rc;
}
-#if (BLE_LL_CFG_FEAT_DATA_LEN_EXT == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_DATA_LEN_EXT) == 1)
int
ble_ll_conn_hci_set_data_len(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
{
@@ -969,7 +970,7 @@ ble_ll_conn_hci_set_data_len(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
}
#endif
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/**
* LE start encrypt command
*
@@ -1062,7 +1063,7 @@ ltk_key_cmd_complete:
}
#endif
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
/**
* Read authenticated payload timeout (OGF=3, OCF==0x007B)
*
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/controller/src/ble_ll_conn_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_priv.h b/net/nimble/controller/src/ble_ll_conn_priv.h
index b855b22..17a5edd 100644
--- a/net/nimble/controller/src/ble_ll_conn_priv.h
+++ b/net/nimble/controller/src/ble_ll_conn_priv.h
@@ -148,7 +148,7 @@ int ble_ll_conn_hci_wr_auth_pyld_tmo(uint8_t *cmdbuf, uint8_t *rsp,
uint8_t *rsplen);
int ble_ll_conn_hci_rd_auth_pyld_tmo(uint8_t *cmdbuf, uint8_t *rsp,
uint8_t *rsplen);
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
void ble_ll_conn_auth_pyld_timer_start(struct ble_ll_conn_sm *connsm);
#else
#define ble_ll_conn_auth_pyld_timer_start(x)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/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 3ba69af..1d98ed3 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "syscfg/syscfg.h"
#include "nimble/ble.h"
#include "nimble/nimble_opt.h"
#include "nimble/hci_common.h"
@@ -306,7 +307,7 @@ ble_ll_ctrl_proc_unk_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
break;
case BLE_LL_CTRL_PING_REQ:
CONN_F_LE_PING_SUPP(connsm) = 0;
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
os_callout_stop(&connsm->auth_pyld_timer.cf_c);
#endif
ctrl_proc = BLE_LL_CTRL_PROC_LE_PING;
@@ -346,7 +347,7 @@ ble_ll_ctrl_datalen_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
htole16(dptr + 7, connsm->max_tx_time);
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
void
ble_ll_calc_session_key(struct ble_ll_conn_sm *connsm)
{
@@ -697,7 +698,7 @@ ble_ll_ctrl_rx_start_enc_rsp(struct ble_ll_conn_sm *connsm)
/* We are encrypted */
connsm->enc_data.enc_state = CONN_ENC_S_ENCRYPTED;
ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_ENCRYPT);
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
ble_ll_conn_auth_pyld_timer_start(connsm);
#endif
rc = BLE_ERR_MAX;
@@ -777,7 +778,7 @@ ble_ll_ctrl_version_ind_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
/* Fill out response */
pyld[0] = BLE_HCI_VER_BCS_4_2;
- htole16(pyld + 1, NIMBLE_OPT_LL_MFRG_ID);
+ htole16(pyld + 1, MYNEWT_VAL(BLE_LL_MFRG_ID));
htole16(pyld + 3, BLE_LL_SUB_VERS_NR);
}
@@ -946,7 +947,7 @@ ble_ll_ctrl_rx_reject_ind(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
ble_ll_hci_ev_conn_update(connsm, ble_error);
}
break;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
case BLE_LL_CTRL_PROC_ENCRYPT:
ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_ENCRYPT);
ble_ll_hci_ev_encrypt_chg(connsm, ble_error);
@@ -1302,7 +1303,7 @@ ble_ll_ctrl_proc_init(struct ble_ll_conn_sm *connsm, int ctrl_proc)
opcode = BLE_LL_CTRL_LENGTH_REQ;
ble_ll_ctrl_datalen_upd_make(connsm, dptr);
break;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/* XXX: deal with already encrypted connection.*/
case BLE_LL_CTRL_PROC_ENCRYPT:
/* If we are already encrypted we do pause procedure */
@@ -1517,7 +1518,7 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
uint8_t *dptr;
uint8_t *rspbuf;
uint8_t *rspdata;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
int restart_encryption;
#endif
@@ -1562,7 +1563,7 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
goto rx_malformed_ctrl;
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
restart_encryption = 0;
#endif
@@ -1673,7 +1674,7 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
case BLE_LL_CTRL_SLAVE_FEATURE_REQ:
rsp_opcode = ble_ll_ctrl_rx_feature_req(connsm, dptr, rspbuf, opcode);
break;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
case BLE_LL_CTRL_ENC_REQ:
rsp_opcode = ble_ll_ctrl_rx_enc_req(connsm, dptr, rspdata);
break;
@@ -1733,7 +1734,7 @@ ll_ctrl_send_rsp:
}
len = g_ble_ll_ctrl_pkt_lengths[rsp_opcode] + 1;
ble_ll_conn_enqueue_pkt(connsm, om, BLE_LL_LLID_CTRL, len);
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (restart_encryption) {
/* XXX: what happens if this fails? Meaning we cant allocate
mbuf? */
@@ -1822,18 +1823,18 @@ ble_ll_ctrl_tx_done(struct os_mbuf *txpdu, struct ble_ll_conn_sm *connsm)
connsm->reject_reason = txpdu->om_data[2];
connsm->csmflags.cfbit.host_expects_upd_event = 1;
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (connsm->enc_data.enc_state > CONN_ENC_S_ENCRYPTED) {
connsm->enc_data.enc_state = CONN_ENC_S_UNENCRYPTED;
}
#endif
break;
case BLE_LL_CTRL_REJECT_IND:
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
connsm->enc_data.enc_state = CONN_ENC_S_UNENCRYPTED;
#endif
break;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
case BLE_LL_CTRL_PAUSE_ENC_REQ:
/* note: fall-through intentional */
case BLE_LL_CTRL_ENC_REQ:
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/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 352dda2..401aacc 100644
--- a/net/nimble/controller/src/ble_ll_hci.c
+++ b/net/nimble/controller/src/ble_ll_hci.c
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "nimble/ble.h"
#include "nimble/nimble_opt.h"
@@ -103,7 +104,7 @@ ble_ll_hci_send_noop(void)
return rc;
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/**
* LE encrypt command
*
@@ -171,7 +172,7 @@ ble_ll_hci_rd_local_version(uint8_t *rspbuf, uint8_t *rsplen)
hci_rev = 0;
lmp_subver = 0;
- mfrg = NIMBLE_OPT_LL_MFRG_ID;
+ mfrg = MYNEWT_VAL(BLE_LL_MFRG_ID);
/* Place the data packet length and number of packets in the buffer */
rspbuf[0] = BLE_HCI_VER_BCS_4_2;
@@ -281,7 +282,7 @@ ble_ll_hci_le_read_bufsize(uint8_t *rspbuf, uint8_t *rsplen)
return BLE_ERR_SUCCESS;
}
-#if (BLE_LL_CFG_FEAT_DATA_LEN_EXT == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_DATA_LEN_EXT) == 1)
/**
* HCI write suggested default data length command.
*
@@ -615,7 +616,7 @@ ble_ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
case BLE_HCI_OCF_LE_RD_REM_FEAT:
rc = ble_ll_conn_hci_read_rem_features(cmdbuf);
break;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
case BLE_HCI_OCF_LE_ENCRYPT:
rc = ble_ll_hci_le_encrypt(cmdbuf, rspbuf, rsplen);
break;
@@ -623,7 +624,7 @@ ble_ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
case BLE_HCI_OCF_LE_RAND:
rc = ble_ll_hci_le_rand(rspbuf, rsplen);
break;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
case BLE_HCI_OCF_LE_START_ENCRYPT:
rc = ble_ll_conn_hci_le_start_encrypt(cmdbuf);
break;
@@ -642,7 +643,7 @@ ble_ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
case BLE_HCI_OCF_LE_REM_CONN_PARAM_RR:
rc = ble_ll_conn_hci_param_reply(cmdbuf, 1);
break;
-#if (BLE_LL_CFG_FEAT_DATA_LEN_EXT == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_DATA_LEN_EXT) == 1)
case BLE_HCI_OCF_LE_SET_DATA_LEN:
rc = ble_ll_conn_hci_set_data_len(cmdbuf, rspbuf, rsplen);
break;
@@ -653,7 +654,7 @@ ble_ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
rc = ble_ll_hci_le_wr_sugg_data_len(cmdbuf);
break;
#endif
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
case BLE_HCI_OCF_LE_ADD_RESOLV_LIST :
rc = ble_ll_resolv_list_add(cmdbuf);
break;
@@ -759,7 +760,7 @@ ble_ll_hci_ctlr_bb_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
{
int rc;
uint8_t len;
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
uint8_t *rspbuf;
#endif
@@ -771,7 +772,7 @@ ble_ll_hci_ctlr_bb_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
/* Move past HCI command header */
cmdbuf += BLE_HCI_CMD_HDR_LEN;
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
rspbuf = cmdbuf + BLE_HCI_EVENT_CMD_COMPLETE_MIN_LEN;
#endif
@@ -793,7 +794,7 @@ ble_ll_hci_ctlr_bb_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
rc = BLE_ERR_SUCCESS;
}
break;
-#if (BLE_LL_CFG_FEAT_LE_PING == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
case BLE_HCI_OCF_CB_RD_AUTH_PYLD_TMO:
rc = ble_ll_conn_hci_wr_auth_pyld_tmo(cmdbuf, rspbuf, rsplen);
break;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/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 2548bdc..9b8e315 100644
--- a/net/nimble/controller/src/ble_ll_hci_ev.c
+++ b/net/nimble/controller/src/ble_ll_hci_ev.c
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "syscfg/syscfg.h"
#include "nimble/ble.h"
#include "nimble/hci_common.h"
#include "nimble/ble_hci_trans.h"
@@ -111,7 +112,7 @@ ble_ll_hci_ev_conn_update(struct ble_ll_conn_sm *connsm, uint8_t status)
}
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
void
ble_ll_hci_ev_encrypt_chg(struct ble_ll_conn_sm *connsm, uint8_t status)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/controller/src/ble_ll_rand.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_rand.c b/net/nimble/controller/src/ble_ll_rand.c
index 8d26f8d..1306138 100644
--- a/net/nimble/controller/src/ble_ll_rand.c
+++ b/net/nimble/controller/src/ble_ll_rand.c
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "nimble/ble.h"
#include "nimble/nimble_opt.h"
@@ -35,10 +36,10 @@ struct ble_ll_rnum_data
};
struct ble_ll_rnum_data g_ble_ll_rnum_data;
-uint8_t g_ble_ll_rnum_buf[NIMBLE_OPT_LL_RNG_BUFSIZE];
+uint8_t g_ble_ll_rnum_buf[MYNEWT_VAL(BLE_LL_RNG_BUFSIZE)];
#define IS_RNUM_BUF_END(x) \
- (x == &g_ble_ll_rnum_buf[NIMBLE_OPT_LL_RNG_BUFSIZE - 1])
+ (x == &g_ble_ll_rnum_buf[MYNEWT_VAL(BLE_LL_RNG_BUFSIZE) - 1])
void
ble_ll_rand_sample(uint8_t rnum)
@@ -46,7 +47,7 @@ ble_ll_rand_sample(uint8_t rnum)
os_sr_t sr;
OS_ENTER_CRITICAL(sr);
- if (g_ble_ll_rnum_data.rnd_size < NIMBLE_OPT_LL_RNG_BUFSIZE) {
+ if (g_ble_ll_rnum_data.rnd_size < MYNEWT_VAL(BLE_LL_RNG_BUFSIZE)) {
++g_ble_ll_rnum_data.rnd_size;
g_ble_ll_rnum_data.rnd_in[0] = rnum;
if (IS_RNUM_BUF_END(g_ble_ll_rnum_data.rnd_in)) {
@@ -94,7 +95,7 @@ ble_ll_rand_data_get(uint8_t *buf, uint8_t len)
/* Wait till bytes are in buffer. */
if (len) {
while ((g_ble_ll_rnum_data.rnd_size < len) &&
- (g_ble_ll_rnum_data.rnd_size < NIMBLE_OPT_LL_RNG_BUFSIZE)) {
+ (g_ble_ll_rnum_data.rnd_size < MYNEWT_VAL(BLE_LL_RNG_BUFSIZE))) {
/* Spin here */
}
}
@@ -138,7 +139,7 @@ int
ble_ll_rand_start(void)
{
/* Start the generation of numbers if we are not full */
- if (g_ble_ll_rnum_data.rnd_size < NIMBLE_OPT_LL_RNG_BUFSIZE) {
+ if (g_ble_ll_rnum_data.rnd_size < MYNEWT_VAL(BLE_LL_RNG_BUFSIZE)) {
ble_hw_rng_start();
}
return 0;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/controller/src/ble_ll_resolv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_resolv.c b/net/nimble/controller/src/ble_ll_resolv.c
index 4d91685..608da8c 100644
--- a/net/nimble/controller/src/ble_ll_resolv.c
+++ b/net/nimble/controller/src/ble_ll_resolv.c
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "nimble/ble.h"
#include "nimble/nimble_opt.h"
@@ -30,7 +31,7 @@
#include "controller/ble_hw.h"
#include "ble_ll_conn_priv.h"
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
/* Flag denoting whether or not address translation is enabled. */
uint8_t g_ble_ll_addr_res_enabled;
@@ -38,7 +39,7 @@ uint8_t g_ble_ll_resolv_list_size;
uint8_t g_ble_ll_resolv_list_cnt;
uint32_t g_ble_ll_resolv_rpa_tmo;
-struct ble_ll_resolv_entry g_ble_ll_resolv_list[NIMBLE_OPT_LL_RESOLV_LIST_SIZE];
+struct ble_ll_resolv_entry g_ble_ll_resolv_list[MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE)];
/**
* Called to determine if a change is allowed to the resolving list at this
@@ -457,12 +458,12 @@ ble_ll_resolv_init(void)
g_ble_ll_resolv_rpa_tmo = 15 * 60 * OS_TICKS_PER_SEC;
hw_size = ble_hw_resolv_list_size();
- if (hw_size > NIMBLE_OPT_LL_RESOLV_LIST_SIZE) {
- hw_size = NIMBLE_OPT_LL_RESOLV_LIST_SIZE;
+ if (hw_size > MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE)) {
+ hw_size = MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE);
}
g_ble_ll_resolv_list_size = hw_size;
}
-#endif /* if BLE_LL_CFG_FEAT_LL_PRIVACY == 1 */
+#endif /* if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1 */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/controller/src/ble_ll_rng.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_rng.c b/net/nimble/controller/src/ble_ll_rng.c
index d93c420..5f5728b 100644
--- a/net/nimble/controller/src/ble_ll_rng.c
+++ b/net/nimble/controller/src/ble_ll_rng.c
@@ -34,7 +34,7 @@ struct ble_ll_rnum_data
uint8_t _pad;
};
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
int
ble_ll_rng_init(void)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index 64c3990..fb73ddd 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
#include <assert.h>
+#include "syscfg/syscfg.h"
#include "bsp/bsp.h"
#include "os/os.h"
#include "nimble/ble.h"
@@ -50,10 +51,10 @@
*/
/* Dont allow more than 255 of these entries */
-#if NIMBLE_OPT_LL_NUM_SCAN_DUP_ADVS > 255
+#if MYNEWT_VAL(BLE_LL_NUM_SCAN_DUP_ADVS) > 255
#error "Cannot have more than 255 duplicate entries!"
#endif
-#if NIMBLE_OPT_LL_NUM_SCAN_RSP_ADVS > 255
+#if MYNEWT_VAL(BLE_LL_NUM_SCAN_RSP_ADVS) > 255
#error "Cannot have more than 255 scan response entries!"
#endif
@@ -79,12 +80,12 @@ struct ble_ll_scan_advertisers
/* Contains list of advertisers that we have heard scan responses from */
static uint8_t g_ble_ll_scan_num_rsp_advs;
struct ble_ll_scan_advertisers
-g_ble_ll_scan_rsp_advs[NIMBLE_OPT_LL_NUM_SCAN_RSP_ADVS];
+g_ble_ll_scan_rsp_advs[MYNEWT_VAL(BLE_LL_NUM_SCAN_RSP_ADVS)];
/* Used to filter duplicate advertising events to host */
static uint8_t g_ble_ll_scan_num_dup_advs;
struct ble_ll_scan_advertisers
-g_ble_ll_scan_dup_advs[NIMBLE_OPT_LL_NUM_SCAN_DUP_ADVS];
+g_ble_ll_scan_dup_advs[MYNEWT_VAL(BLE_LL_NUM_SCAN_DUP_ADVS)];
/* See Vol 6 Part B Section 4.4.3.2. Active scanning backoff */
static void
@@ -136,7 +137,7 @@ ble_ll_scan_req_pdu_make(struct ble_ll_scan_sm *scansm, uint8_t *adv_addr,
uint8_t pdu_type;
uint8_t *scana;
struct os_mbuf *m;
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
uint8_t rpa[BLE_DEV_ADDR_LEN];
struct ble_ll_resolv_entry *rl;
#endif
@@ -159,7 +160,7 @@ ble_ll_scan_req_pdu_make(struct ble_ll_scan_sm *scansm, uint8_t *adv_addr,
scana = g_random_addr;
}
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (scansm->own_addr_type > BLE_HCI_ADV_OWN_ADDR_RANDOM) {
rl = NULL;
if (ble_ll_is_rpa(adv_addr, adv_addr_type)) {
@@ -280,7 +281,7 @@ ble_ll_scan_add_dup_adv(uint8_t *addr, uint8_t txadd, uint8_t subev)
if (!adv) {
/* XXX: for now, if we dont have room, just leave */
num_advs = g_ble_ll_scan_num_dup_advs;
- if (num_advs == NIMBLE_OPT_LL_NUM_SCAN_DUP_ADVS) {
+ if (num_advs == MYNEWT_VAL(BLE_LL_NUM_SCAN_DUP_ADVS)) {
return;
}
@@ -347,7 +348,7 @@ ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t txadd)
/* XXX: for now, if we dont have room, just leave */
num_advs = g_ble_ll_scan_num_rsp_advs;
- if (num_advs == NIMBLE_OPT_LL_NUM_SCAN_RSP_ADVS) {
+ if (num_advs == MYNEWT_VAL(BLE_LL_NUM_SCAN_RSP_ADVS)) {
return;
}
@@ -569,11 +570,11 @@ ble_ll_scan_start(struct ble_ll_scan_sm *scansm, uint8_t chan)
*/
ble_phy_set_txend_cb(NULL, NULL);
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
ble_phy_encrypt_disable();
#endif
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (ble_ll_resolv_enabled()) {
ble_phy_resolv_list_enable();
} else {
@@ -972,7 +973,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
resolved = 0;
index = -1;
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (ble_ll_is_rpa(peer, peer_addr_type) && ble_ll_resolv_enabled()) {
index = ble_hw_resolv_list_match();
if (index >= 0) {
@@ -1133,7 +1134,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
ident_addr_type = txadd;
scansm = &g_ble_ll_scan_sm;
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
index = scansm->scan_rpa_index;
if (index >= 0) {
ident_addr = g_ble_ll_resolv_list[index].rl_identity_addr;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/controller/src/ble_ll_supp_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_supp_cmd.c b/net/nimble/controller/src/ble_ll_supp_cmd.c
index 738ee9c..3344f8e 100644
--- a/net/nimble/controller/src/ble_ll_supp_cmd.c
+++ b/net/nimble/controller/src/ble_ll_supp_cmd.c
@@ -106,7 +106,7 @@
#define BLE_SUPP_CMD_LE_SET_HOST_CHAN_CLASS (1 << 3)
#define BLE_SUPP_CMD_LE_RD_CHAN_MAP (1 << 4)
#define BLE_SUPP_CMD_LE_RD_REM_USED_FEAT (1 << 5)
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
#define BLE_SUPP_CMD_LE_ENCRYPT (1 << 6)
#else
#define BLE_SUPP_CMD_LE_ENCRYPT (0 << 6)
@@ -126,7 +126,7 @@
)
/* Octet 28 */
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
#define BLE_SUPP_CMD_LE_START_ENCRYPT (1 << 0)
#else
#define BLE_SUPP_CMD_LE_START_ENCRYPT (0 << 0)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/controller/src/ble_ll_whitelist.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_whitelist.c b/net/nimble/controller/src/ble_ll_whitelist.c
index f3af569..b92b157 100644
--- a/net/nimble/controller/src/ble_ll_whitelist.c
+++ b/net/nimble/controller/src/ble_ll_whitelist.c
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "nimble/ble.h"
#include "nimble/nimble_opt.h"
@@ -30,8 +31,8 @@
#include "controller/ble_hw.h"
#include "hal/hal_cputime.h"
-#if (NIMBLE_OPT_LL_WHITELIST_SIZE < BLE_HW_WHITE_LIST_SIZE)
-#define BLE_LL_WHITELIST_SIZE NIMBLE_OPT_LL_WHITELIST_SIZE
+#if (MYNEWT_VAL(BLE_LL_WHITELIST_SIZE) < BLE_HW_WHITE_LIST_SIZE)
+#define BLE_LL_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE)
#else
#define BLE_LL_WHITELIST_SIZE BLE_HW_WHITE_LIST_SIZE
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/drivers/native/src/ble_hw.c
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/native/src/ble_hw.c b/net/nimble/drivers/native/src/ble_hw.c
index bb30c53..214ad51 100644
--- a/net/nimble/drivers/native/src/ble_hw.c
+++ b/net/nimble/drivers/native/src/ble_hw.c
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "nimble/ble.h"
#include "nimble/nimble_opt.h"
@@ -164,7 +165,7 @@ ble_hw_rng_read(void)
return 0;
}
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
/**
* Clear the resolving list
*
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/drivers/native/src/ble_phy.c
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/native/src/ble_phy.c b/net/nimble/drivers/native/src/ble_phy.c
index e2c9f25..d19e54b 100644
--- a/net/nimble/drivers/native/src/ble_phy.c
+++ b/net/nimble/drivers/native/src/ble_phy.c
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <assert.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "nimble/ble.h" /* XXX: needed for ble mbuf header.*/
#include "controller/ble_phy.h"
@@ -249,7 +250,7 @@ ble_phy_rx(void)
return 0;
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/**
* Called to enable encryption at the PHY. Note that this state will persist
* in the PHY; in other words, if you call this function you have to call
@@ -510,7 +511,7 @@ ble_phy_max_data_pdu_pyld(void)
return BLE_LL_DATA_PDU_MAX_PYLD;
}
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
void
ble_phy_resolv_list_enable(void)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/drivers/nrf51/src/ble_hw.c
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/nrf51/src/ble_hw.c b/net/nimble/drivers/nrf51/src/ble_hw.c
index afeda82..259bd05 100644
--- a/net/nimble/drivers/nrf51/src/ble_hw.c
+++ b/net/nimble/drivers/nrf51/src/ble_hw.c
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "ble/xcvr.h"
#include "nimble/ble.h"
@@ -38,11 +39,11 @@ static uint8_t g_ble_hw_whitelist_mask;
ble_rng_isr_cb_t g_ble_rng_isr_cb;
/* If LL privacy is enabled, allocate memory for AAR */
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
/* The NRF51 supports up to 16 IRK entries */
-#if (NIMBLE_OPT_LL_RESOLV_LIST_SIZE < 16)
-#define NRF_IRK_LIST_ENTRIES (NIMBLE_OPT_LL_RESOLV_LIST_SIZE)
+#if (MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE) < 16)
+#define NRF_IRK_LIST_ENTRIES (MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE))
#else
#define NRF_IRK_LIST_ENTRIES (16)
#endif
@@ -339,7 +340,7 @@ ble_hw_rng_read(void)
return rnum;
}
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY))
/**
* Clear the resolving list
*
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/drivers/nrf51/src/ble_phy.c
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/nrf51/src/ble_phy.c b/net/nimble/drivers/nrf51/src/ble_phy.c
index 5b588bf..db6618f 100644
--- a/net/nimble/drivers/nrf51/src/ble_phy.c
+++ b/net/nimble/drivers/nrf51/src/ble_phy.c
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
#include <assert.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "bsp/cmsis_nvic.h"
#include "nimble/ble.h"
@@ -94,7 +95,7 @@ struct ble_phy_obj g_ble_phy_data;
/* Global transmit/receive buffer */
static uint32_t g_ble_phy_txrx_buf[(BLE_PHY_MAX_PDU_LEN + 3) / 4];
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/* Make sure word-aligned for faster copies */
static uint32_t g_ble_phy_enc_buf[(NRF_ENC_BUF_SIZE + 3) / 4];
#endif
@@ -164,10 +165,10 @@ STATS_NAME_END(ble_phy_stats)
* bit in the NVIC just to be sure when we disable the PHY.
*/
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/* XXX: test this. only needs 43 bytes. Should just not use the macro for this*/
/* Per nordic, the number of bytes needed for scratch is 16 + MAX_PKT_SIZE */
-#define NRF_ENC_SCRATCH_WORDS (((NIMBLE_OPT_LL_MAX_PKT_SIZE + 16) + 3) / 4)
+#define NRF_ENC_SCRATCH_WORDS (((MYNEWT_VAL(BLE_LL_MAX_PKT_SIZE) + 16) + 3) / 4)
uint32_t g_nrf_encrypt_scratchpad[NRF_ENC_SCRATCH_WORDS];
@@ -241,7 +242,7 @@ nrf_wait_disabled(void)
static void
ble_phy_rx_xcvr_setup(void)
{
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (g_ble_phy_data.phy_encrypted) {
NRF_RADIO->PACKETPTR = (uint32_t)&g_ble_phy_enc_buf[0];
NRF_CCM->INPTR = (uint32_t)&g_ble_phy_enc_buf[0];
@@ -260,7 +261,7 @@ ble_phy_rx_xcvr_setup(void)
NRF_RADIO->PACKETPTR = (uint32_t)g_ble_phy_data.rxpdu->om_data;
#endif
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (g_ble_phy_data.phy_privacy) {
NRF_RADIO->PCNF0 = (6 << RADIO_PCNF0_LFLEN_Pos) |
(2 << RADIO_PCNF0_S1LEN_Pos) |
@@ -330,7 +331,7 @@ ble_phy_tx_end_isr(void)
NRF_RADIO->EVENTS_END = 0;
wfr_time = NRF_RADIO->SHORTS;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/*
* XXX: not sure what to do. We had a HW error during transmission.
* For now I just count a stat but continue on like all is good.
@@ -382,7 +383,7 @@ static void
ble_phy_rx_end_isr(void)
{
int rc;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
uint8_t *dptr;
#endif
uint8_t crcok;
@@ -400,7 +401,7 @@ ble_phy_rx_end_isr(void)
ble_hdr = BLE_MBUF_HDR_PTR(g_ble_phy_data.rxpdu);
assert(NRF_RADIO->EVENTS_RSSIEND != 0);
ble_hdr->rxinfo.rssi = -1 * NRF_RADIO->RSSISAMPLE;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
dptr = g_ble_phy_data.rxpdu->om_data;
#endif
/* Count PHY crc errors and valid packets */
@@ -410,7 +411,7 @@ ble_phy_rx_end_isr(void)
} else {
STATS_INC(ble_phy_stats, rx_valid);
ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_CRC_OK;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (g_ble_phy_data.phy_encrypted) {
/* Only set MIC failure flag if frame is not zero length */
if ((dptr[1] != 0) && (NRF_CCM->MICSTATUS == 0)) {
@@ -445,7 +446,7 @@ ble_phy_rx_end_isr(void)
rxpdu = g_ble_phy_data.rxpdu;
g_ble_phy_data.rxpdu = NULL;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1) || (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) || (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
if (g_ble_phy_data.phy_encrypted || g_ble_phy_data.phy_privacy) {
/*
* XXX: This is a horrible ugly hack to deal with the RAM S1 byte.
@@ -509,7 +510,7 @@ ble_phy_rx_start_isr(void)
g_ble_phy_data.phy_rx_started = 1;
NRF_RADIO->INTENSET = RADIO_INTENSET_END_Msk;
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
/* Must start aar if we need to */
if (g_ble_phy_data.phy_privacy) {
NRF_RADIO->EVENTS_BCMATCH = 0;
@@ -619,14 +620,14 @@ ble_phy_init(void)
/* Captures tx/rx start in timer0 capture 1 */
NRF_PPI->CHENSET = PPI_CHEN_CH26_Msk;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
NRF_CCM->INTENCLR = 0xffffffff;
NRF_CCM->SHORTS = CCM_SHORTS_ENDKSGEN_CRYPT_Msk;
NRF_CCM->EVENTS_ERROR = 0;
memset(g_nrf_encrypt_scratchpad, 0, sizeof(g_nrf_encrypt_scratchpad));
#endif
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
g_ble_phy_data.phy_aar_scratch = 0;
NRF_AAR->IRKPTR = (uint32_t)&g_nrf_irk_list[0];
NRF_AAR->INTENCLR = 0xffffffff;
@@ -697,7 +698,7 @@ ble_phy_rx(void)
return 0;
}
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
/**
* Called to enable encryption at the PHY. Note that this state will persist
* in the PHY; in other words, if you call this function you have to call
@@ -844,7 +845,7 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t end_trans)
ble_hdr = BLE_MBUF_HDR_PTR(txpdu);
payload_len = ble_hdr->txinfo.pyld_len;
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
if (g_ble_phy_data.phy_encrypted) {
/* RAM representation has S0, LENGTH and S1 fields. (3 bytes) */
dptr = (uint8_t *)&g_ble_phy_enc_buf[0];
@@ -864,7 +865,7 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t end_trans)
NRF_PPI->CHENSET = PPI_CHEN_CH24_Msk;
} else {
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
/* Reconfigure PCNF0 */
NRF_RADIO->PCNF0 = (NRF_LFLEN_BITS << RADIO_PCNF0_LFLEN_Pos) |
(NRF_S0_LEN << RADIO_PCNF0_S0LEN_Pos);
@@ -879,7 +880,7 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t end_trans)
}
#else
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
/* Reconfigure PCNF0 */
NRF_RADIO->PCNF0 = (NRF_LFLEN_BITS << RADIO_PCNF0_LFLEN_Pos) |
(NRF_S0_LEN << RADIO_PCNF0_S0LEN_Pos);
@@ -1139,14 +1140,14 @@ ble_phy_xcvr_state_get(void)
uint8_t
ble_phy_max_data_pdu_pyld(void)
{
-#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
return NRF_MAX_ENCRYPTED_PYLD_LEN;
#else
return BLE_LL_DATA_PDU_MAX_PYLD;
#endif
}
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
void
ble_phy_resolv_list_enable(void)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d98ddc1c/net/nimble/drivers/nrf52/src/ble_hw.c
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/nrf52/src/ble_hw.c b/net/nimble/drivers/nrf52/src/ble_hw.c
index 66efb08..569596c 100644
--- a/net/nimble/drivers/nrf52/src/ble_hw.c
+++ b/net/nimble/drivers/nrf52/src/ble_hw.c
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <assert.h>
#include <string.h>
+#include "syscfg/syscfg.h"
#include "os/os.h"
#include "ble/xcvr.h"
#include "nimble/ble.h"
@@ -28,6 +29,8 @@
#include "controller/ble_hw.h"
#include "bsp/cmsis_nvic.h"
+#include "nrf52_bitfields.h"
+
/* Total number of resolving list elements */
#define BLE_HW_RESOLV_LIST_SIZE (16)
@@ -38,11 +41,11 @@ static uint8_t g_ble_hw_whitelist_mask;
ble_rng_isr_cb_t g_ble_rng_isr_cb;
/* If LL privacy is enabled, allocate memory for AAR */
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
/* The NRF51 supports up to 16 IRK entries */
-#if (NIMBLE_OPT_LL_RESOLV_LIST_SIZE < 16)
-#define NRF_IRK_LIST_ENTRIES (NIMBLE_OPT_LL_RESOLV_LIST_SIZE)
+#if (MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE) < 16)
+#define NRF_IRK_LIST_ENTRIES (MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE))
#else
#define NRF_IRK_LIST_ENTRIES (16)
#endif
@@ -339,7 +342,7 @@ ble_hw_rng_read(void)
return rnum;
}
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY)
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY))
/**
* Clear the resolving list
*