summaryrefslogtreecommitdiff
path: root/src/libs/mynewt-nimble/porting
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2021-02-04 17:34:28 +0100
committerGitHub <noreply@github.com>2021-02-04 17:34:28 +0100
commit6259b816287f8f74dadf50334a445cd9fe16d415 (patch)
tree712cf7ca15f0d17b54909bbf45a4cc759c579392 /src/libs/mynewt-nimble/porting
parent16ce5bbb7563f0af9394d4da0dae303aa9eda2fd (diff)
parentd90b7274fa8bbfa09f79660b45b550d91f7b0125 (diff)
Merge pull request #198 from JF002/update-nimble-1_3-master
Update to nimble 1.3 master branch
Diffstat (limited to 'src/libs/mynewt-nimble/porting')
-rw-r--r--src/libs/mynewt-nimble/porting/examples/linux/include/logcfg/logcfg.h2
-rw-r--r--src/libs/mynewt-nimble/porting/examples/linux/include/syscfg/syscfg.h22
-rw-r--r--src/libs/mynewt-nimble/porting/examples/linux/include/sysflash/sysflash.h2
-rw-r--r--src/libs/mynewt-nimble/porting/examples/linux_blemesh/ble.c24
-rw-r--r--src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/logcfg/logcfg.h30
-rw-r--r--src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/syscfg/syscfg.h165
-rw-r--r--src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/sysflash/sysflash.h2
-rw-r--r--src/libs/mynewt-nimble/porting/examples/nuttx/Make.defs58
-rw-r--r--src/libs/mynewt-nimble/porting/examples/nuttx/ble.c118
-rw-r--r--src/libs/mynewt-nimble/porting/examples/nuttx/include/logcfg/logcfg.h32
-rw-r--r--src/libs/mynewt-nimble/porting/examples/nuttx/include/syscfg/syscfg.h1074
-rw-r--r--src/libs/mynewt-nimble/porting/examples/nuttx/include/sysflash/sysflash.h24
-rw-r--r--src/libs/mynewt-nimble/porting/examples/nuttx/main.c124
-rw-r--r--src/libs/mynewt-nimble/porting/nimble/Makefile.defs2
-rw-r--r--src/libs/mynewt-nimble/porting/nimble/include/log/log.h4
-rw-r--r--src/libs/mynewt-nimble/porting/nimble/include/log_common/log_common.h105
-rw-r--r--src/libs/mynewt-nimble/porting/nimble/include/logcfg/logcfg.h14
-rw-r--r--src/libs/mynewt-nimble/porting/nimble/include/modlog/modlog.h1
-rw-r--r--src/libs/mynewt-nimble/porting/nimble/include/syscfg/syscfg.h20
-rw-r--r--src/libs/mynewt-nimble/porting/nimble/include/sysflash/sysflash.h2
-rw-r--r--src/libs/mynewt-nimble/porting/nimble/src/nimble_port.c18
-rw-r--r--src/libs/mynewt-nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h2
-rw-r--r--src/libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c4
-rw-r--r--src/libs/mynewt-nimble/porting/npl/freertos/src/npl_os_freertos.c6
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/include/console/console.h36
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/include/modlog/modlog.h68
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/nimble_npl_os.h71
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/os_types.h90
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/src/os_atomic.c39
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/src/os_callout.c166
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/src/os_eventq.c177
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/src/os_mutex.c82
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/src/os_sem.c100
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/src/os_task.c117
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/src/os_time.c85
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/src/wqueue.h104
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/test/Make.defs58
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_callout.c116
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_eventq.c131
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_mempool.c111
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_sem.c155
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_task.c98
-rw-r--r--src/libs/mynewt-nimble/porting/npl/nuttx/test/test_util.h56
-rw-r--r--src/libs/mynewt-nimble/porting/npl/riot/include/logcfg/logcfg.h2
-rw-r--r--src/libs/mynewt-nimble/porting/npl/riot/include/syscfg/syscfg.h93
-rw-r--r--src/libs/mynewt-nimble/porting/npl/riot/include/sysflash/sysflash.h2
-rw-r--r--src/libs/mynewt-nimble/porting/targets/linux/pkg.yml2
-rw-r--r--src/libs/mynewt-nimble/porting/targets/linux_blemesh/pkg.yml2
-rw-r--r--src/libs/mynewt-nimble/porting/targets/nuttx/pkg.yml40
-rw-r--r--src/libs/mynewt-nimble/porting/targets/nuttx/syscfg.yml28
-rw-r--r--src/libs/mynewt-nimble/porting/targets/nuttx/target.yml20
-rw-r--r--src/libs/mynewt-nimble/porting/targets/porting_default/pkg.yml2
-rw-r--r--src/libs/mynewt-nimble/porting/targets/riot/pkg.yml2
-rw-r--r--src/libs/mynewt-nimble/porting/targets/riot/syscfg.yml2
-rwxr-xr-xsrc/libs/mynewt-nimble/porting/update_generated_files.sh10
55 files changed, 3780 insertions, 140 deletions
diff --git a/src/libs/mynewt-nimble/porting/examples/linux/include/logcfg/logcfg.h b/src/libs/mynewt-nimble/porting/examples/linux/include/logcfg/logcfg.h
index e21a3ae5..837cdeac 100644
--- a/src/libs/mynewt-nimble/porting/examples/linux/include/logcfg/logcfg.h
+++ b/src/libs/mynewt-nimble/porting/examples/linux/include/logcfg/logcfg.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_LOGCFG_
diff --git a/src/libs/mynewt-nimble/porting/examples/linux/include/syscfg/syscfg.h b/src/libs/mynewt-nimble/porting/examples/linux/include/syscfg/syscfg.h
index 7e9bfcac..99939f2b 100644
--- a/src/libs/mynewt-nimble/porting/examples/linux/include/syscfg/syscfg.h
+++ b/src/libs/mynewt-nimble/porting/examples/linux/include/syscfg/syscfg.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_SYSCFG_
@@ -15,8 +15,6 @@
#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name
#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val
-
-
/*** @apache-mynewt-core/crypto/tinycrypt */
#ifndef MYNEWT_VAL_TINYCRYPT_SYSINIT_STAGE
#define MYNEWT_VAL_TINYCRYPT_SYSINIT_STAGE (200)
@@ -297,7 +295,7 @@
#define MYNEWT_VAL_LOG_FCB_SLOT1 (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux (defined by @apache-mynewt-core/sys/log/stub) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux (defined by @apache-mynewt-core/sys/log/stub) */
#ifndef MYNEWT_VAL_LOG_LEVEL
#define MYNEWT_VAL_LOG_LEVEL (0)
#endif
@@ -368,6 +366,14 @@
#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31)
#endif
+#ifndef MYNEWT_VAL_BLE_ISO
+#define MYNEWT_VAL_BLE_ISO (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ISO_TEST
+#define MYNEWT_VAL_BLE_ISO_TEST (0)
+#endif
+
#ifndef MYNEWT_VAL_BLE_MAX_CONNECTIONS
#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (1)
#endif
@@ -945,12 +951,12 @@
#define MYNEWT_VAL_BLE_SOCK_LINUX_DEV (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux (defined by @apache-mynewt-nimble/nimble/transport/socket) */
#ifndef MYNEWT_VAL_BLE_SOCK_STACK_SIZE
#define MYNEWT_VAL_BLE_SOCK_STACK_SIZE (1028)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux (defined by @apache-mynewt-nimble/nimble/transport/socket) */
#ifndef MYNEWT_VAL_BLE_SOCK_TASK_PRIO
#define MYNEWT_VAL_BLE_SOCK_TASK_PRIO (3)
#endif
@@ -959,12 +965,12 @@
#define MYNEWT_VAL_BLE_SOCK_TCP_PORT (14433)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux (defined by @apache-mynewt-nimble/nimble/transport/socket) */
#ifndef MYNEWT_VAL_BLE_SOCK_USE_LINUX_BLUE
#define MYNEWT_VAL_BLE_SOCK_USE_LINUX_BLUE (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux (defined by @apache-mynewt-nimble/nimble/transport/socket) */
#ifndef MYNEWT_VAL_BLE_SOCK_USE_TCP
#define MYNEWT_VAL_BLE_SOCK_USE_TCP (0)
#endif
diff --git a/src/libs/mynewt-nimble/porting/examples/linux/include/sysflash/sysflash.h b/src/libs/mynewt-nimble/porting/examples/linux/include/sysflash/sysflash.h
index 413cb267..ab1341b2 100644
--- a/src/libs/mynewt-nimble/porting/examples/linux/include/sysflash/sysflash.h
+++ b/src/libs/mynewt-nimble/porting/examples/linux/include/sysflash/sysflash.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_SYSFLASH_
diff --git a/src/libs/mynewt-nimble/porting/examples/linux_blemesh/ble.c b/src/libs/mynewt-nimble/porting/examples/linux_blemesh/ble.c
index 22a9e71d..deaef5a4 100644
--- a/src/libs/mynewt-nimble/porting/examples/linux_blemesh/ble.c
+++ b/src/libs/mynewt-nimble/porting/examples/linux_blemesh/ble.c
@@ -40,26 +40,6 @@ static int recent_test_id = STANDARD_TEST_ID;
static bool has_reg_fault = true;
-static struct bt_mesh_cfg_srv cfg_srv = {
- .relay = BT_MESH_RELAY_ENABLED,
- .beacon = BT_MESH_BEACON_ENABLED,
-#if MYNEWT_VAL(BLE_MESH_FRIEND)
- .frnd = BT_MESH_FRIEND_ENABLED,
-#else
- .frnd = BT_MESH_FRIEND_NOT_SUPPORTED ,
-#endif
-#if MYNEWT_VAL(BLE_MESH_GATT_PROXY)
- .gatt_proxy = BT_MESH_GATT_PROXY_ENABLED,
-#else
- .gatt_proxy = BT_MESH_GATT_PROXY_NOT_SUPPORTED,
-#endif
- .default_ttl = 7,
-
- /* 3 transmissions with 20ms interval */
- .net_transmit = BT_MESH_TRANSMIT(2, 20),
- .relay_retransmit = BT_MESH_TRANSMIT(2, 20),
-};
-
static int
fault_get_cur(struct bt_mesh_model *model,
uint8_t *test_id,
@@ -323,7 +303,7 @@ static const struct bt_mesh_model_op gen_level_op[] = {
};
static struct bt_mesh_model root_models[] = {
- BT_MESH_MODEL_CFG_SRV(&cfg_srv),
+ BT_MESH_MODEL_CFG_SRV,
BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_ONOFF_SRV, gen_onoff_op,
&gen_onoff_pub, NULL),
@@ -381,7 +361,7 @@ static int output_number(bt_mesh_output_action_t action, uint32_t number)
return 0;
}
-static void prov_complete(u16_t net_idx, u16_t addr)
+static void prov_complete(uint16_t net_idx, uint16_t addr)
{
console_printf("Local node provisioned, primary address 0x%04x\n", addr);
}
diff --git a/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/logcfg/logcfg.h b/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/logcfg/logcfg.h
index 7404dbb4..798418da 100644
--- a/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/logcfg/logcfg.h
+++ b/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/logcfg/logcfg.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_LOGCFG_
@@ -106,6 +106,34 @@
#define BLE_MESH_TRANS_LOG_CRITICAL(...) MODLOG_CRITICAL(21, __VA_ARGS__)
#define BLE_MESH_TRANS_LOG_DISABLED(...) MODLOG_DISABLED(21, __VA_ARGS__)
+#define BLE_MESH_RPL_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
+#define BLE_MESH_RPL_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__)
+#define BLE_MESH_RPL_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__)
+#define BLE_MESH_RPL_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__)
+#define BLE_MESH_RPL_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__)
+#define BLE_MESH_RPL_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__)
+
+#define BLE_MESH_NET_KEYS_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
+#define BLE_MESH_NET_KEYS_LOG_INFO(...) MODLOG_INFO(23, __VA_ARGS__)
+#define BLE_MESH_NET_KEYS_LOG_WARN(...) MODLOG_WARN(23, __VA_ARGS__)
+#define BLE_MESH_NET_KEYS_LOG_ERROR(...) MODLOG_ERROR(23, __VA_ARGS__)
+#define BLE_MESH_NET_KEYS_LOG_CRITICAL(...) MODLOG_CRITICAL(23, __VA_ARGS__)
+#define BLE_MESH_NET_KEYS_LOG_DISABLED(...) MODLOG_DISABLED(23, __VA_ARGS__)
+
+#define BLE_MESH_PROV_DEVICE_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
+#define BLE_MESH_PROV_DEVICE_LOG_INFO(...) MODLOG_INFO(24, __VA_ARGS__)
+#define BLE_MESH_PROV_DEVICE_LOG_WARN(...) MODLOG_WARN(24, __VA_ARGS__)
+#define BLE_MESH_PROV_DEVICE_LOG_ERROR(...) MODLOG_ERROR(24, __VA_ARGS__)
+#define BLE_MESH_PROV_DEVICE_LOG_CRITICAL(...) MODLOG_CRITICAL(24, __VA_ARGS__)
+#define BLE_MESH_PROV_DEVICE_LOG_DISABLED(...) MODLOG_DISABLED(24, __VA_ARGS__)
+
+#define BLE_MESH_HEARTBEAT_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
+#define BLE_MESH_HEARTBEAT_LOG_INFO(...) MODLOG_INFO(25, __VA_ARGS__)
+#define BLE_MESH_HEARTBEAT_LOG_WARN(...) MODLOG_WARN(25, __VA_ARGS__)
+#define BLE_MESH_HEARTBEAT_LOG_ERROR(...) MODLOG_ERROR(25, __VA_ARGS__)
+#define BLE_MESH_HEARTBEAT_LOG_CRITICAL(...) MODLOG_CRITICAL(25, __VA_ARGS__)
+#define BLE_MESH_HEARTBEAT_LOG_DISABLED(...) MODLOG_DISABLED(25, __VA_ARGS__)
+
#define DFLT_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
#define DFLT_LOG_INFO(...) MODLOG_INFO(0, __VA_ARGS__)
#define DFLT_LOG_WARN(...) MODLOG_WARN(0, __VA_ARGS__)
diff --git a/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/syscfg/syscfg.h b/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/syscfg/syscfg.h
index 24ad0c58..9aac1068 100644
--- a/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/syscfg/syscfg.h
+++ b/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/syscfg/syscfg.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_SYSCFG_
@@ -15,8 +15,6 @@
#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name
#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val
-
-
/*** @apache-mynewt-core/crypto/tinycrypt */
#ifndef MYNEWT_VAL_TINYCRYPT_SYSINIT_STAGE
#define MYNEWT_VAL_TINYCRYPT_SYSINIT_STAGE (200)
@@ -56,7 +54,7 @@
#define MYNEWT_VAL_FLOAT_USER (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-core/kernel/os) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-core/kernel/os) */
#ifndef MYNEWT_VAL_MSYS_1_BLOCK_COUNT
#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT (80)
#endif
@@ -298,7 +296,7 @@
#define MYNEWT_VAL_LOG_FCB_SLOT1 (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-core/sys/log/stub) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-core/sys/log/stub) */
#ifndef MYNEWT_VAL_LOG_LEVEL
#define MYNEWT_VAL_LOG_LEVEL (0)
#endif
@@ -369,6 +367,14 @@
#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31)
#endif
+#ifndef MYNEWT_VAL_BLE_ISO
+#define MYNEWT_VAL_BLE_ISO (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ISO_TEST
+#define MYNEWT_VAL_BLE_ISO_TEST (0)
+#endif
+
#ifndef MYNEWT_VAL_BLE_MAX_CONNECTIONS
#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (1)
#endif
@@ -650,7 +656,7 @@
#define MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host) */
#ifndef MYNEWT_VAL_BLE_MESH
#define MYNEWT_VAL_BLE_MESH (1)
#endif
@@ -757,7 +763,7 @@
#define MYNEWT_VAL_BLE_MESH_ACCESS_LOG_MOD (10)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_ADV_BUF_COUNT
#define MYNEWT_VAL_BLE_MESH_ADV_BUF_COUNT (20)
#endif
@@ -774,7 +780,7 @@
#define MYNEWT_VAL_BLE_MESH_ADV_TASK_PRIO (9)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_APP_KEY_COUNT
#define MYNEWT_VAL_BLE_MESH_APP_KEY_COUNT (4)
#endif
@@ -787,7 +793,7 @@
#define MYNEWT_VAL_BLE_MESH_BEACON_LOG_MOD (12)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_CFG_CLI
#define MYNEWT_VAL_BLE_MESH_CFG_CLI (1)
#endif
@@ -812,7 +818,7 @@
#define MYNEWT_VAL_BLE_MESH_DEV_UUID (((uint8_t[16]){0x11, 0x22, 0}))
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_FRIEND
#define MYNEWT_VAL_BLE_MESH_FRIEND (1)
#endif
@@ -845,7 +851,7 @@
#define MYNEWT_VAL_BLE_MESH_FRIEND_SUB_LIST_SIZE (3)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_GATT_PROXY
#define MYNEWT_VAL_BLE_MESH_GATT_PROXY (1)
#endif
@@ -858,12 +864,12 @@
#define MYNEWT_VAL_BLE_MESH_IVU_DIVIDER (4)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_IV_UPDATE_TEST
#define MYNEWT_VAL_BLE_MESH_IV_UPDATE_TEST (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_LABEL_COUNT
#define MYNEWT_VAL_BLE_MESH_LABEL_COUNT (2)
#endif
@@ -876,7 +882,7 @@
#define MYNEWT_VAL_BLE_MESH_LOG_MOD (9)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_LOW_POWER
#define MYNEWT_VAL_BLE_MESH_LOW_POWER (1)
#endif
@@ -889,7 +895,7 @@
#define MYNEWT_VAL_BLE_MESH_LOW_POWER_LOG_MOD (15)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_LPN_AUTO
#define MYNEWT_VAL_BLE_MESH_LPN_AUTO (0)
#endif
@@ -906,6 +912,10 @@
#define MYNEWT_VAL_BLE_MESH_LPN_GROUPS (10)
#endif
+#ifndef MYNEWT_VAL_BLE_MESH_LPN_SUB_ALL_NODES_ADDR
+#define MYNEWT_VAL_BLE_MESH_LPN_SUB_ALL_NODES_ADDR (1)
+#endif
+
#ifndef MYNEWT_VAL_BLE_MESH_LPN_INIT_POLL_TIMEOUT
#define MYNEWT_VAL_BLE_MESH_LPN_INIT_POLL_TIMEOUT (MYNEWT_VAL_BLE_MESH_LPN_POLL_TIMEOUT)
#endif
@@ -942,7 +952,7 @@
#define MYNEWT_VAL_BLE_MESH_MODEL_EXTENSIONS (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_MODEL_GROUP_COUNT
#define MYNEWT_VAL_BLE_MESH_MODEL_GROUP_COUNT (2)
#endif
@@ -995,17 +1005,17 @@
#define MYNEWT_VAL_BLE_MESH_OOB_OUTPUT_SIZE (4)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_PB_ADV
#define MYNEWT_VAL_BLE_MESH_PB_ADV (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_PB_GATT
#define MYNEWT_VAL_BLE_MESH_PB_GATT (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_PROV
#define MYNEWT_VAL_BLE_MESH_PROV (1)
#endif
@@ -1014,6 +1024,22 @@
#define MYNEWT_VAL_BLE_MESH_PROVISIONER (0)
#endif
+#ifndef MYNEWT_VAL_BLE_MESH_CDB
+#define MYNEWT_VAL_BLE_MESH_CDB (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_CDB_SUBNET_COUNT
+#define MYNEWT_VAL_BLE_MESH_CDB_SUBNET_COUNT (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_CDB_NODE_COUNT
+#define MYNEWT_VAL_BLE_MESH_CDB_NODE_COUNT (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_CDB_APP_KEY_COUNT
+#define MYNEWT_VAL_BLE_MESH_CDB_APP_KEY_COUNT (1)
+#endif
+
#ifndef MYNEWT_VAL_BLE_MESH_PROV_LOG_LVL
#define MYNEWT_VAL_BLE_MESH_PROV_LOG_LVL (1)
#endif
@@ -1039,7 +1065,7 @@
#define MYNEWT_VAL_BLE_MESH_PROXY_LOG_MOD (19)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_RELAY
#define MYNEWT_VAL_BLE_MESH_RELAY (1)
#endif
@@ -1048,8 +1074,12 @@
#define MYNEWT_VAL_BLE_MESH_RPL_STORE_TIMEOUT (5)
#endif
-#ifndef MYNEWT_VAL_BLE_MESH_RX_SDU_MAX
-#define MYNEWT_VAL_BLE_MESH_RX_SDU_MAX (72)
+#ifndef MYNEWT_VAL_BLE_MESH_SEG_BUFS
+#define MYNEWT_VAL_BLE_MESH_SEG_BUFS (72)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_RX_SEG_MAX
+#define MYNEWT_VAL_BLE_MESH_RX_SEG_MAX (3)
#endif
#ifndef MYNEWT_VAL_BLE_MESH_RX_SEG_MSG_COUNT
@@ -1064,7 +1094,7 @@
#define MYNEWT_VAL_BLE_MESH_SEQ_STORE_RATE (128)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_SETTINGS
#define MYNEWT_VAL_BLE_MESH_SETTINGS (0)
#endif
@@ -1077,7 +1107,7 @@
#define MYNEWT_VAL_BLE_MESH_SETTINGS_LOG_MOD (20)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_SHELL
#define MYNEWT_VAL_BLE_MESH_SHELL (0)
#endif
@@ -1090,7 +1120,7 @@
#define MYNEWT_VAL_BLE_MESH_STORE_TIMEOUT (2)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_SUBNET_COUNT
#define MYNEWT_VAL_BLE_MESH_SUBNET_COUNT (2)
#endif
@@ -1103,7 +1133,7 @@
#define MYNEWT_VAL_BLE_MESH_SYSINIT_STAGE_SHELL (1000)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_TESTING
#define MYNEWT_VAL_BLE_MESH_TESTING (1)
#endif
@@ -1116,15 +1146,88 @@
#define MYNEWT_VAL_BLE_MESH_TRANS_LOG_MOD (21)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
+#ifndef MYNEWT_VAL_BLE_MESH_RPL_LOG_LVL
+#define MYNEWT_VAL_BLE_MESH_RPL_LOG_LVL (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_RPL_LOG_MOD
+#define MYNEWT_VAL_BLE_MESH_RPL_LOG_MOD (22)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_MAX
#define MYNEWT_VAL_BLE_MESH_TX_SEG_MAX (6)
#endif
+#ifndef MYNEWT_VAL_BLE_MESH_RX_SEG_MSG_COUNT
+#define MYNEWT_VAL_BLE_MESH_RX_SEG_MSG_COUNT (3)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_UNPROV_BEACON_INT
+#define MYNEWT_VAL_BLE_MESH_UNPROV_BEACON_INT (5)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_PB_ADV_RETRANS_TIMEOUT
+#define MYNEWT_VAL_BLE_MESH_PB_ADV_RETRANS_TIMEOUT (500)
+#endif
+
#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_MSG_COUNT
#define MYNEWT_VAL_BLE_MESH_TX_SEG_MSG_COUNT (4)
#endif
+#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_COUNT
+#define MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_COUNT (4)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_TIMEOUT_UNICAST
+#define MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_TIMEOUT_UNICAST (400)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_TIMEOUT_GROUP
+#define MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_TIMEOUT_GROUP (50)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_LOOPBACK_BUFS
+#define MYNEWT_VAL_BLE_MESH_LOOPBACK_BUFS (3)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_DEFAULT_TTL
+#define MYNEWT_VAL_BLE_MESH_DEFAULT_TTL (7)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_NETWORK_TRANSMIT_COUNT
+#define MYNEWT_VAL_BLE_MESH_NETWORK_TRANSMIT_COUNT (2)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_NETWORK_TRANSMIT_INTERVAL
+#define MYNEWT_VAL_BLE_MESH_NETWORK_TRANSMIT_INTERVAL (20)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_COUNT
+#define MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_COUNT (2)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_BEACON_ENABLED
+#define MYNEWT_VAL_BLE_MESH_BEACON_ENABLED (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_GATT_PROXY_ENABLED
+#define MYNEWT_VAL_BLE_MESH_GATT_PROXY_ENABLED (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_FRIEND_ENABLED
+#define MYNEWT_VAL_BLE_MESH_FRIEND_ENABLED (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_RELAY_ENABLED
+#define MYNEWT_VAL_BLE_MESH_RELAY_ENABLED (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_INTERVAL
+#define MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_INTERVAL (20)
+#endif
+
/*** @apache-mynewt-nimble/nimble/host/services/ans */
#ifndef MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT
#define MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT (0)
@@ -1325,12 +1428,12 @@
#define MYNEWT_VAL_BLE_SOCK_LINUX_DEV (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/transport/socket) */
#ifndef MYNEWT_VAL_BLE_SOCK_STACK_SIZE
#define MYNEWT_VAL_BLE_SOCK_STACK_SIZE (1028)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/transport/socket) */
#ifndef MYNEWT_VAL_BLE_SOCK_TASK_PRIO
#define MYNEWT_VAL_BLE_SOCK_TASK_PRIO (3)
#endif
@@ -1339,12 +1442,12 @@
#define MYNEWT_VAL_BLE_SOCK_TCP_PORT (14433)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/transport/socket) */
#ifndef MYNEWT_VAL_BLE_SOCK_USE_LINUX_BLUE
#define MYNEWT_VAL_BLE_SOCK_USE_LINUX_BLUE (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/linux_blemesh (defined by @apache-mynewt-nimble/nimble/transport/socket) */
#ifndef MYNEWT_VAL_BLE_SOCK_USE_TCP
#define MYNEWT_VAL_BLE_SOCK_USE_TCP (0)
#endif
diff --git a/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/sysflash/sysflash.h b/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/sysflash/sysflash.h
index 413cb267..ab1341b2 100644
--- a/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/sysflash/sysflash.h
+++ b/src/libs/mynewt-nimble/porting/examples/linux_blemesh/include/sysflash/sysflash.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_SYSFLASH_
diff --git a/src/libs/mynewt-nimble/porting/examples/nuttx/Make.defs b/src/libs/mynewt-nimble/porting/examples/nuttx/Make.defs
new file mode 100644
index 00000000..f35d428e
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/examples/nuttx/Make.defs
@@ -0,0 +1,58 @@
+#
+# 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.
+#
+
+# Configure NimBLE variables
+NIMBLE_CFG_TINYCRYPT := 1
+
+# Skip files that don't build for this port
+NIMBLE_IGNORE := $(NIMBLE_ROOT)/porting/nimble/src/hal_timer.c \
+ $(NIMBLE_ROOT)/porting/nimble/src/os_cputime.c \
+ $(NIMBLE_ROOT)/porting/nimble/src/os_cputime_pwr2.c
+
+include $(NIMBLE_ROOT)/porting/nimble/Makefile.defs
+
+CSRCS := $(NIMBLE_SRC)
+
+# Source files for NPL OSAL
+CSRCS += \
+ $(wildcard $(NIMBLE_ROOT)/porting/npl/nuttx/src/*.c) \
+ $(wildcard $(NIMBLE_ROOT)/nimble/transport/socket/src/*.c) \
+ $(TINYCRYPT_SRC)
+
+# Source files for demo app
+CSRCS += $(NIMBLE_ROOT)/porting/examples/nuttx/ble.c
+
+MAINSRC = $(NIMBLE_ROOT)/porting/examples/nuttx/main.c
+
+# Add NPL and all NimBLE directories to include paths
+INC = \
+ $(wildcard $(NIMBLE_ROOT)/porting/examples/nuttx/include) \
+ $(NIMBLE_ROOT)/porting/npl/nuttx/include \
+ $(NIMBLE_ROOT)/nimble/transport/socket/include \
+ $(NIMBLE_INCLUDE) \
+ $(TINYCRYPT_INCLUDE)
+
+INCLUDES := $(addprefix -I, $(INC))
+
+CFLAGS += \
+ $(NIMBLE_CFLAGS) \
+ $(INCLUDES) \
+ $(TINYCRYPT_CFLAGS) \
+ -DNIMBLE_CFG_CONTROLLER=0 -DOS_CFG_ALIGN_4=4 -DOS_CFG_ALIGNMENT=4 \
+ -Ddefault_RNG_defined=0
+
+PROGNAME=nimble
diff --git a/src/libs/mynewt-nimble/porting/examples/nuttx/ble.c b/src/libs/mynewt-nimble/porting/examples/nuttx/ble.c
new file mode 100644
index 00000000..da7bdecc
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/examples/nuttx/ble.c
@@ -0,0 +1,118 @@
+/*
+ * 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 <stdbool.h>
+#include <stdint.h>
+
+#include "nimble/nimble_port.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "services/gap/ble_svc_gap.h"
+
+static const char gap_name[] = "nimble";
+
+static uint8_t own_addr_type;
+
+static void start_advertise(void);
+
+static void
+put_ad(uint8_t ad_type, uint8_t ad_len, const void *ad, uint8_t *buf,
+ uint8_t *len)
+{
+ buf[(*len)++] = ad_len + 1;
+ buf[(*len)++] = ad_type;
+
+ memcpy(&buf[*len], ad, ad_len);
+
+ *len += ad_len;
+}
+
+static void
+update_ad(void)
+{
+ uint8_t ad[BLE_HS_ADV_MAX_SZ];
+ uint8_t ad_len = 0;
+ uint8_t ad_flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP;
+
+ put_ad(BLE_HS_ADV_TYPE_FLAGS, 1, &ad_flags, ad, &ad_len);
+ put_ad(BLE_HS_ADV_TYPE_COMP_NAME, sizeof(gap_name), gap_name, ad, &ad_len);
+
+ ble_gap_adv_set_data(ad, ad_len);
+}
+
+static int
+gap_event_cb(struct ble_gap_event *event, void *arg)
+{
+ switch (event->type) {
+ case BLE_GAP_EVENT_CONNECT:
+ if (event->connect.status) {
+ start_advertise();
+ }
+ break;
+
+ case BLE_GAP_EVENT_DISCONNECT:
+ start_advertise();
+ break;
+ }
+
+ return 0;
+}
+
+static void
+start_advertise(void)
+{
+ struct ble_gap_adv_params advp;
+ int rc;
+
+ printf("advertise\n");
+
+ update_ad();
+
+ memset(&advp, 0, sizeof advp);
+ advp.conn_mode = BLE_GAP_CONN_MODE_UND;
+ advp.disc_mode = BLE_GAP_DISC_MODE_GEN;
+ rc = ble_gap_adv_start(own_addr_type, NULL, BLE_HS_FOREVER,
+ &advp, gap_event_cb, NULL);
+ assert(rc == 0);
+}
+
+static void
+app_ble_sync_cb(void)
+{
+ int rc;
+
+ rc = ble_hs_util_ensure_addr(0);
+ assert(rc == 0);
+
+ rc = ble_hs_id_infer_auto(0, &own_addr_type);
+ assert(rc == 0);
+
+ start_advertise();
+}
+
+void
+nimble_host_task(void *param)
+{
+ ble_hs_cfg.sync_cb = app_ble_sync_cb;
+
+ ble_svc_gap_device_name_set(gap_name);
+
+ nimble_port_run();
+}
diff --git a/src/libs/mynewt-nimble/porting/examples/nuttx/include/logcfg/logcfg.h b/src/libs/mynewt-nimble/porting/examples/nuttx/include/logcfg/logcfg.h
new file mode 100644
index 00000000..837cdeac
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/examples/nuttx/include/logcfg/logcfg.h
@@ -0,0 +1,32 @@
+/**
+ * This file was generated by Apache newt version: 1.9.0-dev
+ */
+
+#ifndef H_MYNEWT_LOGCFG_
+#define H_MYNEWT_LOGCFG_
+
+#include "modlog/modlog.h"
+#include "log_common/log_common.h"
+
+#define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
+#define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__)
+#define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__)
+#define BLE_HS_LOG_ERROR(...) MODLOG_ERROR(4, __VA_ARGS__)
+#define BLE_HS_LOG_CRITICAL(...) MODLOG_CRITICAL(4, __VA_ARGS__)
+#define BLE_HS_LOG_DISABLED(...) MODLOG_DISABLED(4, __VA_ARGS__)
+
+#define DFLT_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
+#define DFLT_LOG_INFO(...) MODLOG_INFO(0, __VA_ARGS__)
+#define DFLT_LOG_WARN(...) MODLOG_WARN(0, __VA_ARGS__)
+#define DFLT_LOG_ERROR(...) MODLOG_ERROR(0, __VA_ARGS__)
+#define DFLT_LOG_CRITICAL(...) MODLOG_CRITICAL(0, __VA_ARGS__)
+#define DFLT_LOG_DISABLED(...) MODLOG_DISABLED(0, __VA_ARGS__)
+
+#define MFG_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
+#define MFG_LOG_INFO(...) IGNORE(__VA_ARGS__)
+#define MFG_LOG_WARN(...) IGNORE(__VA_ARGS__)
+#define MFG_LOG_ERROR(...) IGNORE(__VA_ARGS__)
+#define MFG_LOG_CRITICAL(...) IGNORE(__VA_ARGS__)
+#define MFG_LOG_DISABLED(...) MODLOG_DISABLED(128, __VA_ARGS__)
+
+#endif
diff --git a/src/libs/mynewt-nimble/porting/examples/nuttx/include/syscfg/syscfg.h b/src/libs/mynewt-nimble/porting/examples/nuttx/include/syscfg/syscfg.h
new file mode 100644
index 00000000..ff73312e
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/examples/nuttx/include/syscfg/syscfg.h
@@ -0,0 +1,1074 @@
+/**
+ * This file was generated by Apache newt version: 1.9.0-dev
+ */
+
+#ifndef H_MYNEWT_SYSCFG_
+#define H_MYNEWT_SYSCFG_
+
+/**
+ * This macro exists to ensure code includes this header when needed. If code
+ * checks the existence of a setting directly via ifdef without including this
+ * header, the setting macro will silently evaluate to 0. In contrast, an
+ * attempt to use these macros without including this header will result in a
+ * compiler error.
+ */
+#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name
+#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val
+
+
+/*** Repository @apache-mynewt-core info */
+#ifndef MYNEWT_VAL_REPO_HASH_APACHE_MYNEWT_CORE
+#define MYNEWT_VAL_REPO_HASH_APACHE_MYNEWT_CORE ("4d75fc41bd7ead84638ebbfad4841d5effb296dd")
+#endif
+
+#ifndef MYNEWT_VAL_REPO_VERSION_APACHE_MYNEWT_CORE
+#define MYNEWT_VAL_REPO_VERSION_APACHE_MYNEWT_CORE ("0.0.1")
+#endif
+
+/*** Repository @apache-mynewt-mcumgr info */
+#ifndef MYNEWT_VAL_REPO_HASH_APACHE_MYNEWT_MCUMGR
+#define MYNEWT_VAL_REPO_HASH_APACHE_MYNEWT_MCUMGR ("8d087a7e0e5485394419d10051606c92d68d2111")
+#endif
+
+#ifndef MYNEWT_VAL_REPO_VERSION_APACHE_MYNEWT_MCUMGR
+#define MYNEWT_VAL_REPO_VERSION_APACHE_MYNEWT_MCUMGR ("0.0.0")
+#endif
+
+/*** Repository @apache-mynewt-nimble info */
+#ifndef MYNEWT_VAL_REPO_HASH_APACHE_MYNEWT_NIMBLE
+#define MYNEWT_VAL_REPO_HASH_APACHE_MYNEWT_NIMBLE ("37dceb35df57ff41a6c31f79290512df2fde7064")
+#endif
+
+#ifndef MYNEWT_VAL_REPO_VERSION_APACHE_MYNEWT_NIMBLE
+#define MYNEWT_VAL_REPO_VERSION_APACHE_MYNEWT_NIMBLE ("0.0.0")
+#endif
+
+/*** Repository @mcuboot info */
+#ifndef MYNEWT_VAL_REPO_HASH_MCUBOOT
+#define MYNEWT_VAL_REPO_HASH_MCUBOOT ("03d96ad1f6dd77d47ffca72ade9377acb8559115-dirty")
+#endif
+
+#ifndef MYNEWT_VAL_REPO_VERSION_MCUBOOT
+#define MYNEWT_VAL_REPO_VERSION_MCUBOOT ("0.0.0")
+#endif
+
+/*** Repository @my_project info */
+#ifndef MYNEWT_VAL_REPO_HASH_MY_PROJECT
+#define MYNEWT_VAL_REPO_HASH_MY_PROJECT ("37dceb35df57ff41a6c31f79290512df2fde7064")
+#endif
+
+#ifndef MYNEWT_VAL_REPO_VERSION_MY_PROJECT
+#define MYNEWT_VAL_REPO_VERSION_MY_PROJECT ("0.0.0")
+#endif
+
+
+
+/*** @apache-mynewt-core/crypto/tinycrypt */
+#ifndef MYNEWT_VAL_TINYCRYPT_SYSINIT_STAGE
+#define MYNEWT_VAL_TINYCRYPT_SYSINIT_STAGE (200)
+#endif
+
+#ifndef MYNEWT_VAL_TINYCRYPT_UECC_RNG_TRNG_DEV_NAME
+#define MYNEWT_VAL_TINYCRYPT_UECC_RNG_TRNG_DEV_NAME ("trng")
+#endif
+
+#ifndef MYNEWT_VAL_TINYCRYPT_UECC_RNG_USE_TRNG
+#define MYNEWT_VAL_TINYCRYPT_UECC_RNG_USE_TRNG (0)
+#endif
+
+/*** @apache-mynewt-core/hw/hal */
+#ifndef MYNEWT_VAL_HAL_ENABLE_SOFTWARE_BREAKPOINTS
+#define MYNEWT_VAL_HAL_ENABLE_SOFTWARE_BREAKPOINTS (1)
+#endif
+
+#ifndef MYNEWT_VAL_HAL_FLASH_VERIFY_BUF_SZ
+#define MYNEWT_VAL_HAL_FLASH_VERIFY_BUF_SZ (16)
+#endif
+
+#ifndef MYNEWT_VAL_HAL_FLASH_VERIFY_ERASES
+#define MYNEWT_VAL_HAL_FLASH_VERIFY_ERASES (0)
+#endif
+
+#ifndef MYNEWT_VAL_HAL_FLASH_VERIFY_WRITES
+#define MYNEWT_VAL_HAL_FLASH_VERIFY_WRITES (0)
+#endif
+
+#ifndef MYNEWT_VAL_HAL_SYSTEM_RESET_CB
+#define MYNEWT_VAL_HAL_SYSTEM_RESET_CB (0)
+#endif
+
+/*** @apache-mynewt-core/kernel/os */
+#ifndef MYNEWT_VAL_FLOAT_USER
+#define MYNEWT_VAL_FLOAT_USER (0)
+#endif
+
+#ifndef MYNEWT_VAL_MSYS_1_BLOCK_COUNT
+#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT (12)
+#endif
+
+#ifndef MYNEWT_VAL_MSYS_1_BLOCK_SIZE
+#define MYNEWT_VAL_MSYS_1_BLOCK_SIZE (292)
+#endif
+
+#ifndef MYNEWT_VAL_MSYS_1_SANITY_MIN_COUNT
+#define MYNEWT_VAL_MSYS_1_SANITY_MIN_COUNT (0)
+#endif
+
+#ifndef MYNEWT_VAL_MSYS_2_BLOCK_COUNT
+#define MYNEWT_VAL_MSYS_2_BLOCK_COUNT (0)
+#endif
+
+#ifndef MYNEWT_VAL_MSYS_2_BLOCK_SIZE
+#define MYNEWT_VAL_MSYS_2_BLOCK_SIZE (0)
+#endif
+
+#ifndef MYNEWT_VAL_MSYS_2_SANITY_MIN_COUNT
+#define MYNEWT_VAL_MSYS_2_SANITY_MIN_COUNT (0)
+#endif
+
+#ifndef MYNEWT_VAL_MSYS_SANITY_TIMEOUT
+#define MYNEWT_VAL_MSYS_SANITY_TIMEOUT (60000)
+#endif
+
+#ifndef MYNEWT_VAL_OS_ASSERT_CB
+#define MYNEWT_VAL_OS_ASSERT_CB (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_CLI
+#define MYNEWT_VAL_OS_CLI (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_COREDUMP
+#define MYNEWT_VAL_OS_COREDUMP (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_CPUTIME_FREQ
+#define MYNEWT_VAL_OS_CPUTIME_FREQ (1000000)
+#endif
+
+#ifndef MYNEWT_VAL_OS_CPUTIME_TIMER_NUM
+#define MYNEWT_VAL_OS_CPUTIME_TIMER_NUM (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_CRASH_FILE_LINE
+#define MYNEWT_VAL_OS_CRASH_FILE_LINE (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_CRASH_LOG
+#define MYNEWT_VAL_OS_CRASH_LOG (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_CRASH_RESTORE_REGS
+#define MYNEWT_VAL_OS_CRASH_RESTORE_REGS (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_CRASH_STACKTRACE
+#define MYNEWT_VAL_OS_CRASH_STACKTRACE (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_CTX_SW_STACK_CHECK
+#define MYNEWT_VAL_OS_CTX_SW_STACK_CHECK (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_CTX_SW_STACK_GUARD
+#define MYNEWT_VAL_OS_CTX_SW_STACK_GUARD (4)
+#endif
+
+#ifndef MYNEWT_VAL_OS_DEBUG_MODE
+#define MYNEWT_VAL_OS_DEBUG_MODE (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_EVENTQ_DEBUG
+#define MYNEWT_VAL_OS_EVENTQ_DEBUG (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_EVENTQ_MONITOR
+#define MYNEWT_VAL_OS_EVENTQ_MONITOR (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_IDLE_TICKLESS_MS_MAX
+#define MYNEWT_VAL_OS_IDLE_TICKLESS_MS_MAX (600000)
+#endif
+
+#ifndef MYNEWT_VAL_OS_IDLE_TICKLESS_MS_MIN
+#define MYNEWT_VAL_OS_IDLE_TICKLESS_MS_MIN (100)
+#endif
+
+#ifndef MYNEWT_VAL_OS_MAIN_STACK_SIZE
+#define MYNEWT_VAL_OS_MAIN_STACK_SIZE (1024)
+#endif
+
+#ifndef MYNEWT_VAL_OS_MAIN_TASK_PRIO
+#define MYNEWT_VAL_OS_MAIN_TASK_PRIO (127)
+#endif
+
+#ifndef MYNEWT_VAL_OS_MAIN_TASK_SANITY_ITVL_MS
+#define MYNEWT_VAL_OS_MAIN_TASK_SANITY_ITVL_MS (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_MEMPOOL_CHECK
+#define MYNEWT_VAL_OS_MEMPOOL_CHECK (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_MEMPOOL_GUARD
+#define MYNEWT_VAL_OS_MEMPOOL_GUARD (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_MEMPOOL_POISON
+#define MYNEWT_VAL_OS_MEMPOOL_POISON (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_SCHEDULING
+#define MYNEWT_VAL_OS_SCHEDULING (1)
+#endif
+
+#ifndef MYNEWT_VAL_OS_SYSINIT_STAGE
+#define MYNEWT_VAL_OS_SYSINIT_STAGE (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_SYSVIEW
+#define MYNEWT_VAL_OS_SYSVIEW (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_SYSVIEW_TRACE_CALLOUT
+#define MYNEWT_VAL_OS_SYSVIEW_TRACE_CALLOUT (1)
+#endif
+
+#ifndef MYNEWT_VAL_OS_SYSVIEW_TRACE_EVENTQ
+#define MYNEWT_VAL_OS_SYSVIEW_TRACE_EVENTQ (1)
+#endif
+
+#ifndef MYNEWT_VAL_OS_SYSVIEW_TRACE_MBUF
+#define MYNEWT_VAL_OS_SYSVIEW_TRACE_MBUF (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_SYSVIEW_TRACE_MEMPOOL
+#define MYNEWT_VAL_OS_SYSVIEW_TRACE_MEMPOOL (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_SYSVIEW_TRACE_MUTEX
+#define MYNEWT_VAL_OS_SYSVIEW_TRACE_MUTEX (1)
+#endif
+
+#ifndef MYNEWT_VAL_OS_SYSVIEW_TRACE_SEM
+#define MYNEWT_VAL_OS_SYSVIEW_TRACE_SEM (1)
+#endif
+
+#ifndef MYNEWT_VAL_OS_TASK_RUN_TIME_CPUTIME
+#define MYNEWT_VAL_OS_TASK_RUN_TIME_CPUTIME (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_TIME_DEBUG
+#define MYNEWT_VAL_OS_TIME_DEBUG (0)
+#endif
+
+#ifndef MYNEWT_VAL_OS_WATCHDOG_MONITOR
+#define MYNEWT_VAL_OS_WATCHDOG_MONITOR (0)
+#endif
+
+#ifndef MYNEWT_VAL_SANITY_INTERVAL
+#define MYNEWT_VAL_SANITY_INTERVAL (15000)
+#endif
+
+#ifndef MYNEWT_VAL_WATCHDOG_INTERVAL
+#define MYNEWT_VAL_WATCHDOG_INTERVAL (30000)
+#endif
+
+/*** @apache-mynewt-core/sys/console/stub */
+#ifndef MYNEWT_VAL_CONSOLE_UART_BAUD
+#define MYNEWT_VAL_CONSOLE_UART_BAUD (115200)
+#endif
+
+#ifndef MYNEWT_VAL_CONSOLE_UART_DEV
+#define MYNEWT_VAL_CONSOLE_UART_DEV ("uart0")
+#endif
+
+#ifndef MYNEWT_VAL_CONSOLE_UART_FLOW_CONTROL
+#define MYNEWT_VAL_CONSOLE_UART_FLOW_CONTROL (UART_FLOW_CTL_NONE)
+#endif
+
+/*** @apache-mynewt-core/sys/flash_map */
+#ifndef MYNEWT_VAL_FLASH_MAP_MAX_AREAS
+#define MYNEWT_VAL_FLASH_MAP_MAX_AREAS (10)
+#endif
+
+#ifndef MYNEWT_VAL_FLASH_MAP_SYSINIT_STAGE
+#define MYNEWT_VAL_FLASH_MAP_SYSINIT_STAGE (2)
+#endif
+
+/*** @apache-mynewt-core/sys/log/common */
+#ifndef MYNEWT_VAL_DFLT_LOG_LVL
+#define MYNEWT_VAL_DFLT_LOG_LVL (1)
+#endif
+
+#ifndef MYNEWT_VAL_DFLT_LOG_MOD
+#define MYNEWT_VAL_DFLT_LOG_MOD (0)
+#endif
+
+#ifndef MYNEWT_VAL_LOG_GLOBAL_IDX
+#define MYNEWT_VAL_LOG_GLOBAL_IDX (1)
+#endif
+
+/*** @apache-mynewt-core/sys/log/modlog */
+#ifndef MYNEWT_VAL_MODLOG_CONSOLE_DFLT
+#define MYNEWT_VAL_MODLOG_CONSOLE_DFLT (1)
+#endif
+
+#ifndef MYNEWT_VAL_MODLOG_LOG_MACROS
+#define MYNEWT_VAL_MODLOG_LOG_MACROS (0)
+#endif
+
+#ifndef MYNEWT_VAL_MODLOG_MAX_MAPPINGS
+#define MYNEWT_VAL_MODLOG_MAX_MAPPINGS (16)
+#endif
+
+#ifndef MYNEWT_VAL_MODLOG_MAX_PRINTF_LEN
+#define MYNEWT_VAL_MODLOG_MAX_PRINTF_LEN (128)
+#endif
+
+#ifndef MYNEWT_VAL_MODLOG_SYSINIT_STAGE
+#define MYNEWT_VAL_MODLOG_SYSINIT_STAGE (100)
+#endif
+
+/*** @apache-mynewt-core/sys/log/stub */
+#ifndef MYNEWT_VAL_LOG_CONSOLE
+#define MYNEWT_VAL_LOG_CONSOLE (1)
+#endif
+
+#ifndef MYNEWT_VAL_LOG_FCB
+#define MYNEWT_VAL_LOG_FCB (0)
+#endif
+
+#ifndef MYNEWT_VAL_LOG_FCB_SLOT1
+#define MYNEWT_VAL_LOG_FCB_SLOT1 (0)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/nuttx (defined by @apache-mynewt-core/sys/log/stub) */
+#ifndef MYNEWT_VAL_LOG_LEVEL
+#define MYNEWT_VAL_LOG_LEVEL (2)
+#endif
+
+/*** @apache-mynewt-core/sys/mfg */
+#ifndef MYNEWT_VAL_MFG_LOG_LVL
+#define MYNEWT_VAL_MFG_LOG_LVL (15)
+#endif
+
+#ifndef MYNEWT_VAL_MFG_LOG_MODULE
+#define MYNEWT_VAL_MFG_LOG_MODULE (128)
+#endif
+
+#ifndef MYNEWT_VAL_MFG_MAX_MMRS
+#define MYNEWT_VAL_MFG_MAX_MMRS (2)
+#endif
+
+#ifndef MYNEWT_VAL_MFG_SYSINIT_STAGE
+#define MYNEWT_VAL_MFG_SYSINIT_STAGE (100)
+#endif
+
+/*** @apache-mynewt-core/sys/sys */
+#ifndef MYNEWT_VAL_DEBUG_PANIC_ENABLED
+#define MYNEWT_VAL_DEBUG_PANIC_ENABLED (1)
+#endif
+
+/*** @apache-mynewt-core/sys/sysdown */
+#ifndef MYNEWT_VAL_SYSDOWN_CONSTRAIN_DOWN
+#define MYNEWT_VAL_SYSDOWN_CONSTRAIN_DOWN (1)
+#endif
+
+#ifndef MYNEWT_VAL_SYSDOWN_PANIC_FILE_LINE
+#define MYNEWT_VAL_SYSDOWN_PANIC_FILE_LINE (0)
+#endif
+
+#ifndef MYNEWT_VAL_SYSDOWN_PANIC_MESSAGE
+#define MYNEWT_VAL_SYSDOWN_PANIC_MESSAGE (0)
+#endif
+
+#ifndef MYNEWT_VAL_SYSDOWN_TIMEOUT_MS
+#define MYNEWT_VAL_SYSDOWN_TIMEOUT_MS (10000)
+#endif
+
+/*** @apache-mynewt-core/sys/sysinit */
+#ifndef MYNEWT_VAL_SYSINIT_CONSTRAIN_INIT
+#define MYNEWT_VAL_SYSINIT_CONSTRAIN_INIT (1)
+#endif
+
+#ifndef MYNEWT_VAL_SYSINIT_PANIC_FILE_LINE
+#define MYNEWT_VAL_SYSINIT_PANIC_FILE_LINE (0)
+#endif
+
+#ifndef MYNEWT_VAL_SYSINIT_PANIC_MESSAGE
+#define MYNEWT_VAL_SYSINIT_PANIC_MESSAGE (0)
+#endif
+
+/*** @apache-mynewt-core/util/rwlock */
+#ifndef MYNEWT_VAL_RWLOCK_DEBUG
+#define MYNEWT_VAL_RWLOCK_DEBUG (0)
+#endif
+
+/*** @apache-mynewt-nimble/nimble */
+#ifndef MYNEWT_VAL_BLE_EXT_ADV
+#define MYNEWT_VAL_BLE_EXT_ADV (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE
+#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ISO
+#define MYNEWT_VAL_BLE_ISO (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ISO_TEST
+#define MYNEWT_VAL_BLE_ISO_TEST (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MAX_CONNECTIONS
+#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS
+#define MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES
+#define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_PERIODIC_ADV
+#define MYNEWT_VAL_BLE_PERIODIC_ADV (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_PERIODIC_ADV_SYNC_TRANSFER
+#define MYNEWT_VAL_BLE_PERIODIC_ADV_SYNC_TRANSFER (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ROLE_BROADCASTER
+#define MYNEWT_VAL_BLE_ROLE_BROADCASTER (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ROLE_CENTRAL
+#define MYNEWT_VAL_BLE_ROLE_CENTRAL (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ROLE_OBSERVER
+#define MYNEWT_VAL_BLE_ROLE_OBSERVER (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ROLE_PERIPHERAL
+#define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_VERSION
+#define MYNEWT_VAL_BLE_VERSION (50)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_WHITELIST
+#define MYNEWT_VAL_BLE_WHITELIST (1)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host */
+#ifndef MYNEWT_VAL_BLE_ATT_PREFERRED_MTU
+#define MYNEWT_VAL_BLE_ATT_PREFERRED_MTU (256)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_FIND_INFO
+#define MYNEWT_VAL_BLE_ATT_SVR_FIND_INFO (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_FIND_TYPE
+#define MYNEWT_VAL_BLE_ATT_SVR_FIND_TYPE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_INDICATE
+#define MYNEWT_VAL_BLE_ATT_SVR_INDICATE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_MAX_PREP_ENTRIES
+#define MYNEWT_VAL_BLE_ATT_SVR_MAX_PREP_ENTRIES (64)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_NOTIFY
+#define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE
+#define MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE_TMO
+#define MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE_TMO (30000)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ
+#define MYNEWT_VAL_BLE_ATT_SVR_READ (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_BLOB
+#define MYNEWT_VAL_BLE_ATT_SVR_READ_BLOB (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_GROUP_TYPE
+#define MYNEWT_VAL_BLE_ATT_SVR_READ_GROUP_TYPE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_MULT
+#define MYNEWT_VAL_BLE_ATT_SVR_READ_MULT (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_TYPE
+#define MYNEWT_VAL_BLE_ATT_SVR_READ_TYPE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_SIGNED_WRITE
+#define MYNEWT_VAL_BLE_ATT_SVR_SIGNED_WRITE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_WRITE
+#define MYNEWT_VAL_BLE_ATT_SVR_WRITE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ATT_SVR_WRITE_NO_RSP
+#define MYNEWT_VAL_BLE_ATT_SVR_WRITE_NO_RSP (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE
+#define MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_DISC_ALL_CHRS
+#define MYNEWT_VAL_BLE_GATT_DISC_ALL_CHRS (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_DISC_ALL_DSCS
+#define MYNEWT_VAL_BLE_GATT_DISC_ALL_DSCS (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_DISC_ALL_SVCS
+#define MYNEWT_VAL_BLE_GATT_DISC_ALL_SVCS (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_DISC_CHR_UUID
+#define MYNEWT_VAL_BLE_GATT_DISC_CHR_UUID (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_DISC_SVC_UUID
+#define MYNEWT_VAL_BLE_GATT_DISC_SVC_UUID (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_FIND_INC_SVCS
+#define MYNEWT_VAL_BLE_GATT_FIND_INC_SVCS (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_INDICATE
+#define MYNEWT_VAL_BLE_GATT_INDICATE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_MAX_PROCS
+#define MYNEWT_VAL_BLE_GATT_MAX_PROCS (4)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_NOTIFY
+#define MYNEWT_VAL_BLE_GATT_NOTIFY (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_READ
+#define MYNEWT_VAL_BLE_GATT_READ (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_READ_LONG
+#define MYNEWT_VAL_BLE_GATT_READ_LONG (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_READ_MAX_ATTRS
+#define MYNEWT_VAL_BLE_GATT_READ_MAX_ATTRS (8)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_READ_MULT
+#define MYNEWT_VAL_BLE_GATT_READ_MULT (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_READ_UUID
+#define MYNEWT_VAL_BLE_GATT_READ_UUID (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_RESUME_RATE
+#define MYNEWT_VAL_BLE_GATT_RESUME_RATE (1000)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_SIGNED_WRITE
+#define MYNEWT_VAL_BLE_GATT_SIGNED_WRITE (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_WRITE
+#define MYNEWT_VAL_BLE_GATT_WRITE (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_WRITE_LONG
+#define MYNEWT_VAL_BLE_GATT_WRITE_LONG (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_WRITE_MAX_ATTRS
+#define MYNEWT_VAL_BLE_GATT_WRITE_MAX_ATTRS (4)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_WRITE_NO_RSP
+#define MYNEWT_VAL_BLE_GATT_WRITE_NO_RSP (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE
+#define MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE (MYNEWT_VAL_BLE_ROLE_CENTRAL)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HOST
+#define MYNEWT_VAL_BLE_HOST (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_AUTO_START
+#define MYNEWT_VAL_BLE_HS_AUTO_START (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_DEBUG
+#define MYNEWT_VAL_BLE_HS_DEBUG (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL
+#define MYNEWT_VAL_BLE_HS_FLOW_CTRL (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL
+#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL (1000)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH
+#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH (2)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_TX_ON_DISCONNECT
+#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_TX_ON_DISCONNECT (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_LOG_LVL
+#define MYNEWT_VAL_BLE_HS_LOG_LVL (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_LOG_MOD
+#define MYNEWT_VAL_BLE_HS_LOG_MOD (4)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_PHONY_HCI_ACKS
+#define MYNEWT_VAL_BLE_HS_PHONY_HCI_ACKS (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_REQUIRE_OS
+#define MYNEWT_VAL_BLE_HS_REQUIRE_OS (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_STOP_ON_SHUTDOWN
+#define MYNEWT_VAL_BLE_HS_STOP_ON_SHUTDOWN (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_STOP_ON_SHUTDOWN_TIMEOUT
+#define MYNEWT_VAL_BLE_HS_STOP_ON_SHUTDOWN_TIMEOUT (2000)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HS_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_HS_SYSINIT_STAGE (200)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM
+#define MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_L2CAP_COC_MPS
+#define MYNEWT_VAL_BLE_L2CAP_COC_MPS (MYNEWT_VAL_MSYS_1_BLOCK_SIZE-8)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_L2CAP_ENHANCED_COC
+#define MYNEWT_VAL_BLE_L2CAP_ENHANCED_COC (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_L2CAP_JOIN_RX_FRAGS
+#define MYNEWT_VAL_BLE_L2CAP_JOIN_RX_FRAGS (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_L2CAP_MAX_CHANS
+#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*MYNEWT_VAL_BLE_MAX_CONNECTIONS)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_L2CAP_RX_FRAG_TIMEOUT
+#define MYNEWT_VAL_BLE_L2CAP_RX_FRAG_TIMEOUT (30000)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS
+#define MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MESH
+#define MYNEWT_VAL_BLE_MESH (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MONITOR_CONSOLE_BUFFER_SIZE
+#define MYNEWT_VAL_BLE_MONITOR_CONSOLE_BUFFER_SIZE (128)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MONITOR_RTT
+#define MYNEWT_VAL_BLE_MONITOR_RTT (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MONITOR_RTT_BUFFERED
+#define MYNEWT_VAL_BLE_MONITOR_RTT_BUFFERED (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MONITOR_RTT_BUFFER_NAME
+#define MYNEWT_VAL_BLE_MONITOR_RTT_BUFFER_NAME ("btmonitor")
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MONITOR_RTT_BUFFER_SIZE
+#define MYNEWT_VAL_BLE_MONITOR_RTT_BUFFER_SIZE (256)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MONITOR_UART
+#define MYNEWT_VAL_BLE_MONITOR_UART (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MONITOR_UART_BAUDRATE
+#define MYNEWT_VAL_BLE_MONITOR_UART_BAUDRATE (1000000)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MONITOR_UART_BUFFER_SIZE
+#define MYNEWT_VAL_BLE_MONITOR_UART_BUFFER_SIZE (64)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_MONITOR_UART_DEV
+#define MYNEWT_VAL_BLE_MONITOR_UART_DEV ("uart0")
+#endif
+
+#ifndef MYNEWT_VAL_BLE_RPA_TIMEOUT
+#define MYNEWT_VAL_BLE_RPA_TIMEOUT (300)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SM_BONDING
+#define MYNEWT_VAL_BLE_SM_BONDING (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SM_IO_CAP
+#define MYNEWT_VAL_BLE_SM_IO_CAP (BLE_HS_IO_NO_INPUT_OUTPUT)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SM_KEYPRESS
+#define MYNEWT_VAL_BLE_SM_KEYPRESS (0)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/nuttx (defined by @apache-mynewt-nimble/nimble/host) */
+#ifndef MYNEWT_VAL_BLE_SM_LEGACY
+#define MYNEWT_VAL_BLE_SM_LEGACY (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SM_MAX_PROCS
+#define MYNEWT_VAL_BLE_SM_MAX_PROCS (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SM_MITM
+#define MYNEWT_VAL_BLE_SM_MITM (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SM_OOB_DATA_FLAG
+#define MYNEWT_VAL_BLE_SM_OOB_DATA_FLAG (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SM_OUR_KEY_DIST
+#define MYNEWT_VAL_BLE_SM_OUR_KEY_DIST (0)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/nuttx (defined by @apache-mynewt-nimble/nimble/host) */
+#ifndef MYNEWT_VAL_BLE_SM_SC
+#define MYNEWT_VAL_BLE_SM_SC (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS
+#define MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST
+#define MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_STORE_MAX_BONDS
+#define MYNEWT_VAL_BLE_STORE_MAX_BONDS (3)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_STORE_MAX_CCCDS
+#define MYNEWT_VAL_BLE_STORE_MAX_CCCDS (8)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host/services/ans */
+#ifndef MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT
+#define MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_ANS_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SVC_ANS_SYSINIT_STAGE (303)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_ANS_UNR_ALERT_CAT
+#define MYNEWT_VAL_BLE_SVC_ANS_UNR_ALERT_CAT (0)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host/services/bas */
+#ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE
+#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE (1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_READ_PERM
+#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_READ_PERM (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_BAS_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SVC_BAS_SYSINIT_STAGE (303)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host/services/dis */
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_DEFAULT_READ_PERM
+#define MYNEWT_VAL_BLE_SVC_DIS_DEFAULT_READ_PERM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_DEFAULT
+#define MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_DEFAULT (NULL)
+#endif
+
+/* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_READ_PERM
+#define MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_READ_PERM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_DEFAULT
+#define MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_DEFAULT (NULL)
+#endif
+
+/* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_READ_PERM
+#define MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_READ_PERM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_DEFAULT
+#define MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_DEFAULT (NULL)
+#endif
+
+/* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_READ_PERM
+#define MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_READ_PERM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_MODEL_NUMBER_DEFAULT
+#define MYNEWT_VAL_BLE_SVC_DIS_MODEL_NUMBER_DEFAULT ("Apache Mynewt NimBLE")
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_MODEL_NUMBER_READ_PERM
+#define MYNEWT_VAL_BLE_SVC_DIS_MODEL_NUMBER_READ_PERM (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_DEFAULT
+#define MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_DEFAULT (NULL)
+#endif
+
+/* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_READ_PERM
+#define MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_READ_PERM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_DEFAULT
+#define MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_DEFAULT (NULL)
+#endif
+
+/* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_READ_PERM
+#define MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_READ_PERM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SVC_DIS_SYSINIT_STAGE (303)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_DEFAULT
+#define MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_DEFAULT (NULL)
+#endif
+
+/* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */
+#ifndef MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_READ_PERM
+#define MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_READ_PERM (-1)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host/services/gap */
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE
+#define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE_WRITE_PERM
+#define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE_WRITE_PERM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION
+#define MYNEWT_VAL_BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME
+#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME ("nimble")
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH
+#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH (31)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_WRITE_PERM
+#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_WRITE_PERM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL
+#define MYNEWT_VAL_BLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_PPCP_MIN_CONN_INTERVAL
+#define MYNEWT_VAL_BLE_SVC_GAP_PPCP_MIN_CONN_INTERVAL (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_PPCP_SLAVE_LATENCY
+#define MYNEWT_VAL_BLE_SVC_GAP_PPCP_SLAVE_LATENCY (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_PPCP_SUPERVISION_TMO
+#define MYNEWT_VAL_BLE_SVC_GAP_PPCP_SUPERVISION_TMO (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SVC_GAP_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SVC_GAP_SYSINIT_STAGE (301)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host/services/gatt */
+#ifndef MYNEWT_VAL_BLE_SVC_GATT_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SVC_GATT_SYSINIT_STAGE (302)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host/services/ias */
+#ifndef MYNEWT_VAL_BLE_SVC_IAS_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SVC_IAS_SYSINIT_STAGE (303)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host/services/ipss */
+#ifndef MYNEWT_VAL_BLE_SVC_IPSS_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SVC_IPSS_SYSINIT_STAGE (303)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host/services/lls */
+#ifndef MYNEWT_VAL_BLE_SVC_LLS_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SVC_LLS_SYSINIT_STAGE (303)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/host/services/tps */
+#ifndef MYNEWT_VAL_BLE_SVC_TPS_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SVC_TPS_SYSINIT_STAGE (303)
+#endif
+
+/*** @apache-mynewt-nimble/nimble/transport/socket */
+#ifndef MYNEWT_VAL_BLE_ACL_BUF_COUNT
+#define MYNEWT_VAL_BLE_ACL_BUF_COUNT (24)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ACL_BUF_SIZE
+#define MYNEWT_VAL_BLE_ACL_BUF_SIZE (255)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HCI_ACL_OUT_COUNT
+#define MYNEWT_VAL_BLE_HCI_ACL_OUT_COUNT (12)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HCI_EVT_BUF_SIZE
+#define MYNEWT_VAL_BLE_HCI_EVT_BUF_SIZE (70)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HCI_EVT_HI_BUF_COUNT
+#define MYNEWT_VAL_BLE_HCI_EVT_HI_BUF_COUNT (8)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_HCI_EVT_LO_BUF_COUNT
+#define MYNEWT_VAL_BLE_HCI_EVT_LO_BUF_COUNT (8)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SOCK_CLI_SYSINIT_STAGE
+#define MYNEWT_VAL_BLE_SOCK_CLI_SYSINIT_STAGE (500)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SOCK_LINUX_DEV
+#define MYNEWT_VAL_BLE_SOCK_LINUX_DEV (0)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/nuttx (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+#ifndef MYNEWT_VAL_BLE_SOCK_STACK_SIZE
+#define MYNEWT_VAL_BLE_SOCK_STACK_SIZE (1028)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/nuttx (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+#ifndef MYNEWT_VAL_BLE_SOCK_TASK_PRIO
+#define MYNEWT_VAL_BLE_SOCK_TASK_PRIO (3)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_SOCK_TCP_PORT
+#define MYNEWT_VAL_BLE_SOCK_TCP_PORT (14433)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/nuttx (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+#ifndef MYNEWT_VAL_BLE_SOCK_USE_LINUX_BLUE
+#define MYNEWT_VAL_BLE_SOCK_USE_LINUX_BLUE (0)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/nuttx (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+#ifndef MYNEWT_VAL_BLE_SOCK_USE_NUTTX
+#define MYNEWT_VAL_BLE_SOCK_USE_NUTTX (1)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/nuttx (defined by @apache-mynewt-nimble/nimble/transport/socket) */
+#ifndef MYNEWT_VAL_BLE_SOCK_USE_TCP
+#define MYNEWT_VAL_BLE_SOCK_USE_TCP (0)
+#endif
+
+/*** newt */
+#ifndef MYNEWT_VAL_APP_NAME
+#define MYNEWT_VAL_APP_NAME ("dummy_app")
+#endif
+
+#ifndef MYNEWT_VAL_APP_dummy_app
+#define MYNEWT_VAL_APP_dummy_app (1)
+#endif
+
+#ifndef MYNEWT_VAL_ARCH_NAME
+#define MYNEWT_VAL_ARCH_NAME ("dummy")
+#endif
+
+#ifndef MYNEWT_VAL_ARCH_dummy
+#define MYNEWT_VAL_ARCH_dummy (1)
+#endif
+
+#ifndef MYNEWT_VAL_BSP_NAME
+#define MYNEWT_VAL_BSP_NAME ("dummy_bsp")
+#endif
+
+#ifndef MYNEWT_VAL_BSP_dummy_bsp
+#define MYNEWT_VAL_BSP_dummy_bsp (1)
+#endif
+
+#ifndef MYNEWT_VAL_NEWT_FEATURE_LOGCFG
+#define MYNEWT_VAL_NEWT_FEATURE_LOGCFG (1)
+#endif
+
+#ifndef MYNEWT_VAL_NEWT_FEATURE_SYSDOWN
+#define MYNEWT_VAL_NEWT_FEATURE_SYSDOWN (1)
+#endif
+
+#ifndef MYNEWT_VAL_TARGET_NAME
+#define MYNEWT_VAL_TARGET_NAME ("nuttx")
+#endif
+
+#ifndef MYNEWT_VAL_TARGET_nuttx
+#define MYNEWT_VAL_TARGET_nuttx (1)
+#endif
+
+#endif
diff --git a/src/libs/mynewt-nimble/porting/examples/nuttx/include/sysflash/sysflash.h b/src/libs/mynewt-nimble/porting/examples/nuttx/include/sysflash/sysflash.h
new file mode 100644
index 00000000..ab1341b2
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/examples/nuttx/include/sysflash/sysflash.h
@@ -0,0 +1,24 @@
+/**
+ * This file was generated by Apache newt version: 1.9.0-dev
+ */
+
+#ifndef H_MYNEWT_SYSFLASH_
+#define H_MYNEWT_SYSFLASH_
+
+#include "flash_map/flash_map.h"
+
+/**
+ * This flash map definition is used for two purposes:
+ * 1. To locate the meta area, which contains the true flash map definition.
+ * 2. As a fallback in case the meta area cannot be read from flash.
+ */
+extern const struct flash_area sysflash_map_dflt[6];
+
+#define FLASH_AREA_BOOTLOADER 0
+#define FLASH_AREA_IMAGE_0 1
+#define FLASH_AREA_IMAGE_1 2
+#define FLASH_AREA_IMAGE_SCRATCH 3
+#define FLASH_AREA_REBOOT_LOG 16
+#define FLASH_AREA_NFFS 17
+
+#endif
diff --git a/src/libs/mynewt-nimble/porting/examples/nuttx/main.c b/src/libs/mynewt-nimble/porting/examples/nuttx/main.c
new file mode 100644
index 00000000..acfc9fcd
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/examples/nuttx/main.c
@@ -0,0 +1,124 @@
+/*
+ * 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 <nuttx/config.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+#include <pthread.h>
+#include "nimble/nimble_npl.h"
+#include "nimble/nimble_port.h"
+
+#include "services/gap/ble_svc_gap.h"
+#include "services/gatt/ble_svc_gatt.h"
+#include "services/ans/ble_svc_ans.h"
+#include "services/ias/ble_svc_ias.h"
+#include "services/lls/ble_svc_lls.h"
+#include "services/tps/ble_svc_tps.h"
+
+static struct ble_npl_task s_task_host;
+static struct ble_npl_task s_task_hci;
+
+void nimble_host_task(void *param);
+void ble_hci_sock_ack_handler(void *param);
+void ble_hci_sock_init(void);
+void ble_hci_sock_set_device(int dev);
+void ble_store_ram_init(void);
+
+#define TASK_DEFAULT_PRIORITY 1
+#define TASK_DEFAULT_STACK NULL
+#define TASK_DEFAULT_STACK_SIZE 400
+
+void *ble_hci_sock_task(void *param)
+{
+ printf("hci sock task\n");
+ ble_hci_sock_ack_handler(param);
+ return NULL;
+}
+
+void *ble_host_task(void *param)
+{
+ printf("host task\n");
+ nimble_host_task(param);
+ return NULL;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+
+ /* allow to specify custom hci */
+ if (argc > 1) {
+ ble_hci_sock_set_device(atoi(argv[1]));
+ }
+
+ printf("hci init\n");
+ ble_hci_sock_init();
+ printf("port init\n");
+ nimble_port_init();
+
+ /* This example provides GATT Alert service */
+ printf("gap init\n");
+ ble_svc_gap_init();
+ printf("gatt init\n");
+ ble_svc_gatt_init();
+ printf("ans init\n");
+ ble_svc_ans_init();
+ printf("ias init\n");
+ ble_svc_ias_init();
+ printf("lls init\n");
+ ble_svc_lls_init();
+ printf("tps init\n");
+ ble_svc_tps_init();
+
+ /* XXX Need to have template for store */
+ ble_store_ram_init();
+
+ printf("hci_sock task init\n");
+ ret = ble_npl_task_init(&s_task_hci, "hci_sock", ble_hci_sock_task,
+ NULL, TASK_DEFAULT_PRIORITY, BLE_NPL_TIME_FOREVER,
+ TASK_DEFAULT_STACK, TASK_DEFAULT_STACK_SIZE);
+
+ if (ret != 0)
+ {
+ fprintf(stderr, "error starting hci task: %i\n", ret);
+ }
+
+ /* Create task which handles default event queue for host stack. */
+ printf("ble_host task init\n");
+ ret = ble_npl_task_init(&s_task_host, "ble_host", ble_host_task,
+ NULL, TASK_DEFAULT_PRIORITY, BLE_NPL_TIME_FOREVER,
+ TASK_DEFAULT_STACK, TASK_DEFAULT_STACK_SIZE);
+
+
+ if (ret != 0)
+ {
+ fprintf(stderr, "error starting ble task: %i\n", ret);
+ }
+
+ while (true)
+ {
+ usleep(100);
+ //pause();
+ }
+ return 0;
+}
diff --git a/src/libs/mynewt-nimble/porting/nimble/Makefile.defs b/src/libs/mynewt-nimble/porting/nimble/Makefile.defs
index ffb531fb..5bab893f 100644
--- a/src/libs/mynewt-nimble/porting/nimble/Makefile.defs
+++ b/src/libs/mynewt-nimble/porting/nimble/Makefile.defs
@@ -30,6 +30,7 @@ NIMBLE_INCLUDE := \
$(NIMBLE_ROOT)/nimble/host/services/gap/include \
$(NIMBLE_ROOT)/nimble/host/services/gatt/include \
$(NIMBLE_ROOT)/nimble/host/services/ias/include \
+ $(NIMBLE_ROOT)/nimble/host/services/dis/include \
$(NIMBLE_ROOT)/nimble/host/services/lls/include \
$(NIMBLE_ROOT)/nimble/host/services/tps/include \
$(NIMBLE_ROOT)/nimble/host/store/ram/include \
@@ -46,6 +47,7 @@ NIMBLE_SRC := \
$(filter-out $(NIMBLE_IGNORE), $(wildcard $(NIMBLE_ROOT)/nimble/host/services/bas/src/*.c)) \
$(filter-out $(NIMBLE_IGNORE), $(wildcard $(NIMBLE_ROOT)/nimble/host/services/gap/src/*.c)) \
$(filter-out $(NIMBLE_IGNORE), $(wildcard $(NIMBLE_ROOT)/nimble/host/services/gatt/src/*.c)) \
+ $(filter-out $(NIMBLE_IGNORE), $(wildcard $(NIMBLE_ROOT)/nimble/host/services/dis/src/*.c)) \
$(filter-out $(NIMBLE_IGNORE), $(wildcard $(NIMBLE_ROOT)/nimble/host/services/ias/src/*.c)) \
$(filter-out $(NIMBLE_IGNORE), $(wildcard $(NIMBLE_ROOT)/nimble/host/services/lls/src/*.c)) \
$(filter-out $(NIMBLE_IGNORE), $(wildcard $(NIMBLE_ROOT)/nimble/host/services/tps/src/*.c)) \
diff --git a/src/libs/mynewt-nimble/porting/nimble/include/log/log.h b/src/libs/mynewt-nimble/porting/nimble/include/log/log.h
index 004667cc..b50c5b17 100644
--- a/src/libs/mynewt-nimble/porting/nimble/include/log/log.h
+++ b/src/libs/mynewt-nimble/porting/nimble/include/log/log.h
@@ -30,11 +30,13 @@ log_dummy(void *log, ...)
(void)log;
}
-#define LOG_DEBUG(_log, _mod, ...) NRF_LOG_DEBUG(## __VA_ARGS__)
+#if MYNEWT
+#define LOG_DEBUG(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__)
#define LOG_INFO(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__)
#define LOG_WARN(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__)
#define LOG_ERROR(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__)
#define LOG_CRITICAL(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__)
+#endif
struct log {
};
diff --git a/src/libs/mynewt-nimble/porting/nimble/include/log_common/log_common.h b/src/libs/mynewt-nimble/porting/nimble/include/log_common/log_common.h
index 106d02d7..ed590b6b 100644
--- a/src/libs/mynewt-nimble/porting/nimble/include/log_common/log_common.h
+++ b/src/libs/mynewt-nimble/porting/nimble/include/log_common/log_common.h
@@ -20,20 +20,123 @@
#ifndef H_LOG_COMMON_
#define H_LOG_COMMON_
+#include <stdint.h>
#include "log_common/ignore.h"
#ifdef __cplusplus
extern "C" {
#endif
+struct log;
+
+#define LOG_VERSION_V3 3
+
+#define LOG_TYPE_STREAM (0)
+#define LOG_TYPE_MEMORY (1)
+#define LOG_TYPE_STORAGE (2)
+
#define LOG_LEVEL_DEBUG (0)
#define LOG_LEVEL_INFO (1)
#define LOG_LEVEL_WARN (2)
#define LOG_LEVEL_ERROR (3)
#define LOG_LEVEL_CRITICAL (4)
-/* Up to 7 custom log levels. */
+/* Up to 10 custom log levels. */
#define LOG_LEVEL_MAX (15)
+#define LOG_LEVEL_STR(level) \
+ (LOG_LEVEL_DEBUG == level ? "DEBUG" :\
+ (LOG_LEVEL_INFO == level ? "INFO" :\
+ (LOG_LEVEL_WARN == level ? "WARN" :\
+ (LOG_LEVEL_ERROR == level ? "ERROR" :\
+ (LOG_LEVEL_CRITICAL == level ? "CRITICAL" :\
+ "UNKNOWN")))))
+
+/* XXX: These module IDs are defined for backwards compatibility. Application
+ * code should use the syscfg settings directly. These defines will be removed
+ * in a future release.
+ */
+#define LOG_MODULE_DEFAULT 0
+#define LOG_MODULE_OS 1
+#define LOG_MODULE_NEWTMGR 2
+#define LOG_MODULE_NIMBLE_CTLR 3
+#define LOG_MODULE_NIMBLE_HOST 4
+#define LOG_MODULE_NFFS 5
+#define LOG_MODULE_REBOOT 6
+#define LOG_MODULE_IOTIVITY 7
+#define LOG_MODULE_TEST 8
+
+#define LOG_MODULE_PERUSER 64
+#define LOG_MODULE_MAX (255)
+
+#define LOG_ETYPE_STRING (0)
+#define LOG_ETYPE_CBOR (1)
+#define LOG_ETYPE_BINARY (2)
+
+/* UTC Timestamp for Jan 2016 00:00:00 */
+#define UTC01_01_2016 1451606400
+
+#define LOG_NAME_MAX_LEN (64)
+
+#ifndef MYNEWT_VAL_LOG_LEVEL
+#define LOG_SYSLEVEL ((uint8_t)LOG_LEVEL_MAX)
+#else
+#define LOG_SYSLEVEL ((uint8_t)MYNEWT_VAL_LOG_LEVEL)
+#endif
+
+/**
+ * @brief Determines if a log module will accept an entry with a given level.
+ *
+ * A log entry is only accepted if its level is less than or equal to both:
+ * o Global log level setting (LOG_LEVEL), and
+ * o The specified module log level
+ *
+ * @param mod_level The module's minimum log level.
+ * @param entry_level The level of the entry to be logged.
+ *
+ * @return true if the entry would be logged;
+ * false otherwise.
+ */
+#define LOG_MOD_LEVEL_IS_ACTIVE(mod_level, entry_level) \
+ (LOG_LEVEL <= (entry_level) && (mod_level) <= (entry_level))
+
+/* Newtmgr Log opcodes */
+#define LOGS_NMGR_OP_READ (0)
+#define LOGS_NMGR_OP_CLEAR (1)
+#define LOGS_NMGR_OP_APPEND (2)
+#define LOGS_NMGR_OP_MODULE_LIST (3)
+#define LOGS_NMGR_OP_LEVEL_LIST (4)
+#define LOGS_NMGR_OP_LOGS_LIST (5)
+#define LOGS_NMGR_OP_SET_WATERMARK (6)
+#define LOGS_NMGR_OP_MODLEVEL (8)
+
+#define LOG_PRINTF_MAX_ENTRY_LEN (128)
+
+/* Global log info */
+struct log_info {
+#if MYNEWT_VAL(LOG_GLOBAL_IDX)
+ uint32_t li_next_index;
+#endif
+ uint8_t li_version;
+};
+
+extern struct log_info g_log_info;
+
+/** @typedef log_append_cb
+ * @brief Callback that is executed each time the corresponding log is appended
+ * to.
+ *
+ * @param log The log that was just appended to.
+ * @param idx The index of newly appended log entry.
+ */
+typedef void log_append_cb(struct log *log, uint32_t idx);
+
+/** @typdef log_notify_rotate_cb
+ * @brief Callback that is executed each time we are about to rotate a log.
+ *
+ * @param log The log that is about to rotate
+ */
+typedef void log_notify_rotate_cb(const struct log *log);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/libs/mynewt-nimble/porting/nimble/include/logcfg/logcfg.h b/src/libs/mynewt-nimble/porting/nimble/include/logcfg/logcfg.h
index 983f419f..837cdeac 100644
--- a/src/libs/mynewt-nimble/porting/nimble/include/logcfg/logcfg.h
+++ b/src/libs/mynewt-nimble/porting/nimble/include/logcfg/logcfg.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_LOGCFG_
@@ -7,24 +7,14 @@
#include "modlog/modlog.h"
#include "log_common/log_common.h"
-#include <libraries/log/nrf_log.h>
-#if 1
-#define BLE_HS_LOG_DEBUG(...) NRF_LOG_DEBUG(__VA_ARGS__)
-#define BLE_HS_LOG_INFO(...) NRF_LOG_INFO(__VA_ARGS__)
-#define BLE_HS_LOG_WARN(...) NRF_LOG_WARNING( __VA_ARGS__)
-#define BLE_HS_LOG_ERROR(...) NRF_LOG_ERROR(__VA_ARGS__)
-#define BLE_HS_LOG_CRITICAL(...) NRF_LOG_ERROR(__VA_ARGS__)
-#define BLE_HS_LOG_DISABLED(...) MODLOG_DISABLED(4, __VA_ARGS__)
-#endif
-#if 0
#define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
#define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__)
#define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__)
#define BLE_HS_LOG_ERROR(...) MODLOG_ERROR(4, __VA_ARGS__)
#define BLE_HS_LOG_CRITICAL(...) MODLOG_CRITICAL(4, __VA_ARGS__)
#define BLE_HS_LOG_DISABLED(...) MODLOG_DISABLED(4, __VA_ARGS__)
-#endif
+
#define DFLT_LOG_DEBUG(...) IGNORE(__VA_ARGS__)
#define DFLT_LOG_INFO(...) MODLOG_INFO(0, __VA_ARGS__)
#define DFLT_LOG_WARN(...) MODLOG_WARN(0, __VA_ARGS__)
diff --git a/src/libs/mynewt-nimble/porting/nimble/include/modlog/modlog.h b/src/libs/mynewt-nimble/porting/nimble/include/modlog/modlog.h
index 29b1e8f0..03904610 100644
--- a/src/libs/mynewt-nimble/porting/nimble/include/modlog/modlog.h
+++ b/src/libs/mynewt-nimble/porting/nimble/include/modlog/modlog.h
@@ -22,6 +22,7 @@
#include <stdio.h>
+#include "log_common/log_common.h"
#include "log/log.h"
#define MODLOG_MODULE_DFLT 255
diff --git a/src/libs/mynewt-nimble/porting/nimble/include/syscfg/syscfg.h b/src/libs/mynewt-nimble/porting/nimble/include/syscfg/syscfg.h
index 6efa3f28..94b72cb6 100644
--- a/src/libs/mynewt-nimble/porting/nimble/include/syscfg/syscfg.h
+++ b/src/libs/mynewt-nimble/porting/nimble/include/syscfg/syscfg.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_SYSCFG_
@@ -15,10 +15,6 @@
#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name
#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val
-#ifndef OS_TICKS_PER_SEC
-#define OS_TICKS_PER_SEC 1024
-#endif
-
/*** @apache-mynewt-core/crypto/tinycrypt */
#ifndef MYNEWT_VAL_TINYCRYPT_SYSINIT_STAGE
#define MYNEWT_VAL_TINYCRYPT_SYSINIT_STAGE (200)
@@ -369,6 +365,14 @@
#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31)
#endif
+#ifndef MYNEWT_VAL_BLE_ISO
+#define MYNEWT_VAL_BLE_ISO (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ISO_TEST
+#define MYNEWT_VAL_BLE_ISO_TEST (0)
+#endif
+
#ifndef MYNEWT_VAL_BLE_MAX_CONNECTIONS
#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (1)
#endif
@@ -1264,4 +1268,10 @@
#define MYNEWT_VAL_TIMER_5 (1)
#endif
+/* Value copied from BLE_LL_OUR_SCA */
+#ifndef MYNEWT_VAL_BLE_LL_SCA
+#define MYNEWT_VAL_BLE_LL_SCA (60)
+#endif
+
+
#endif
diff --git a/src/libs/mynewt-nimble/porting/nimble/include/sysflash/sysflash.h b/src/libs/mynewt-nimble/porting/nimble/include/sysflash/sysflash.h
index 413cb267..ab1341b2 100644
--- a/src/libs/mynewt-nimble/porting/nimble/include/sysflash/sysflash.h
+++ b/src/libs/mynewt-nimble/porting/nimble/include/sysflash/sysflash.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_SYSFLASH_
diff --git a/src/libs/mynewt-nimble/porting/nimble/src/nimble_port.c b/src/libs/mynewt-nimble/porting/nimble/src/nimble_port.c
index ff350a89..06b5f6df 100644
--- a/src/libs/mynewt-nimble/porting/nimble/src/nimble_port.c
+++ b/src/libs/mynewt-nimble/porting/nimble/src/nimble_port.c
@@ -24,34 +24,28 @@
#include "nimble/nimble_port.h"
#if NIMBLE_CFG_CONTROLLER
#include "controller/ble_ll.h"
+#include "transport/ram/ble_hci_ram.h"
#endif
static struct ble_npl_eventq g_eventq_dflt;
+extern void os_msys_init(void);
+
void
nimble_port_init(void)
{
- void os_msys_init(void);
- void ble_store_ram_init(void);
-#if NIMBLE_CFG_CONTROLLER
- void ble_hci_ram_init(void);
-#endif
-
/* Initialize default event queue */
ble_npl_eventq_init(&g_eventq_dflt);
-
+ /* Initialize the global memory pool */
os_msys_init();
-
+ /* Initialize the host */
ble_hs_init();
- /* XXX Need to have template for store */
- ble_store_ram_init();
-
#if NIMBLE_CFG_CONTROLLER
+ ble_hci_ram_init();
hal_timer_init(5, NULL);
os_cputime_init(32768);
ble_ll_init();
- ble_hci_ram_init();
#endif
}
diff --git a/src/libs/mynewt-nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h b/src/libs/mynewt-nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h
index d8810f35..545be0f4 100644
--- a/src/libs/mynewt-nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h
+++ b/src/libs/mynewt-nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h
@@ -282,14 +282,12 @@ static inline uint32_t
ble_npl_hw_enter_critical(void)
{
//vPortEnterCritical();
-
return npl_freertos_hw_enter_critical();
}
static inline void
ble_npl_hw_exit_critical(uint32_t ctx)
{
- // vPortExitCritical();
npl_freertos_hw_exit_critical(ctx);
}
diff --git a/src/libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c b/src/libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c
index 64196b36..8ee3475a 100644
--- a/src/libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c
+++ b/src/libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c
@@ -37,7 +37,7 @@ nimble_port_freertos_init(TaskFunction_t host_task_fn)
* provided by NimBLE and in case of FreeRTOS it does not need to be wrapped
* since it has compatible prototype.
*/
- xTaskCreate(nimble_port_ll_task_func, "ll", configMINIMAL_STACK_SIZE + 100,
+ xTaskCreate(nimble_port_ll_task_func, "ll", configMINIMAL_STACK_SIZE + 400,
NULL, configMAX_PRIORITIES - 1, &ll_task_h);
#endif
@@ -46,6 +46,6 @@ nimble_port_freertos_init(TaskFunction_t host_task_fn)
* have separate task for NimBLE host, but since something needs to handle
* default queue it is just easier to make separate task which does this.
*/
- xTaskCreate(host_task_fn, "ble", configMINIMAL_STACK_SIZE + 200,
+ xTaskCreate(host_task_fn, "ble", configMINIMAL_STACK_SIZE + 400,
NULL, tskIDLE_PRIORITY + 1, &host_task_h);
}
diff --git a/src/libs/mynewt-nimble/porting/npl/freertos/src/npl_os_freertos.c b/src/libs/mynewt-nimble/porting/npl/freertos/src/npl_os_freertos.c
index eb3b4c99..87936bd8 100644
--- a/src/libs/mynewt-nimble/porting/npl/freertos/src/npl_os_freertos.c
+++ b/src/libs/mynewt-nimble/porting/npl/freertos/src/npl_os_freertos.c
@@ -268,16 +268,10 @@ void
npl_freertos_callout_init(struct ble_npl_callout *co, struct ble_npl_eventq *evq,
ble_npl_event_fn *ev_cb, void *ev_arg)
{
- // I added this 'if' because nimble seems to never delete the timers. I assume it wants to recycle them.
- // This condition ensure that a new timer is created only if 'co' points to an uninitialized structure.
- // If the struct contains an existing timer, no new timer is created, which prevent a significant memory leak.
- // TODO Ensure that this workaround is valid and does not generate bad side-effect.
- if(co->handle == NULL) {
memset(co, 0, sizeof(*co));
co->handle = xTimerCreate("co", 1, pdFALSE, co, os_callout_timer_cb);
co->evq = evq;
ble_npl_event_init(&co->ev, ev_cb, ev_arg);
- }
}
ble_npl_error_t
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/include/console/console.h b/src/libs/mynewt-nimble/porting/npl/nuttx/include/console/console.h
new file mode 100644
index 00000000..0f65d475
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/include/console/console.h
@@ -0,0 +1,36 @@
+/*
+ * 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 __CONSOLE_H__
+#define __CONSOLE_H__
+
+#include <nuttx/config.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define console_printf(_fmt, ...) printf(_fmt, ##__VA_ARGS__)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONSOLE_H__ */
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/include/modlog/modlog.h b/src/libs/mynewt-nimble/porting/npl/nuttx/include/modlog/modlog.h
new file mode 100644
index 00000000..5e51b501
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/include/modlog/modlog.h
@@ -0,0 +1,68 @@
+/*
+ * 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_MODLOG_
+#define H_MODLOG_
+
+#include <stdio.h>
+#include <stdint.h>
+
+#include "log_common/log_common.h"
+
+#define MODLOG_MODULE_DFLT 255
+
+#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_DEBUG || defined __DOXYGEN__
+#define MODLOG_DEBUG(ml_mod_, ml_msg_, ...) \
+ printf((ml_msg_), ##__VA_ARGS__)
+#else
+#define MODLOG_DEBUG(ml_mod_, ...) IGNORE(__VA_ARGS__)
+#endif
+
+#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_INFO || defined __DOXYGEN__
+#define MODLOG_INFO(ml_mod_, ml_msg_, ...) \
+ printf((ml_msg_), ##__VA_ARGS__)
+#else
+#define MODLOG_INFO(ml_mod_, ...) IGNORE(__VA_ARGS__)
+#endif
+
+#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_WARN || defined __DOXYGEN__
+#define MODLOG_WARN(ml_mod_, ml_msg_, ...) \
+ printf((ml_msg_), ##__VA_ARGS__)
+#else
+#define MODLOG_WARN(ml_mod_, ...) IGNORE(__VA_ARGS__)
+#endif
+
+#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_ERROR || defined __DOXYGEN__
+#define MODLOG_ERROR(ml_mod_, ml_msg_, ...) \
+ printf((ml_msg_), ##__VA_ARGS__)
+#else
+#define MODLOG_ERROR(ml_mod_, ...) IGNORE(__VA_ARGS__)
+#endif
+
+#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_CRITICAL || defined __DOXYGEN__
+#define MODLOG_CRITICAL(ml_mod_, ml_msg_, ...) \
+ printf((ml_msg_), ##__VA_ARGS__)
+#else
+#define MODLOG_CRITICAL(ml_mod_, ...) IGNORE(__VA_ARGS__)
+#endif
+
+#define MODLOG(ml_lvl_, ml_mod_, ...) \
+ MODLOG_ ## ml_lvl_((ml_mod_), __VA_ARGS__)
+
+#endif
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/nimble_npl_os.h b/src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/nimble_npl_os.h
new file mode 100644
index 00000000..0f765f5a
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/nimble_npl_os.h
@@ -0,0 +1,71 @@
+/*
+ * 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 _NIMBLE_NPL_OS_H_
+#define _NIMBLE_NPL_OS_H_
+
+#include <nuttx/config.h>
+#include <assert.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "os_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BLE_NPL_OS_ALIGNMENT 4
+
+#define BLE_NPL_TIME_FOREVER INT32_MAX
+
+#define SYSINIT_PANIC_MSG(msg) { fprintf(stderr, "%s\n", msg); abort(); }
+
+#define SYSINIT_PANIC_ASSERT_MSG(rc, msg) do \
+{ \
+ if (!(rc)) { \
+ SYSINIT_PANIC_MSG(msg); \
+ } \
+} while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Define some variables since nimBLE is designed to be built ignoring
+ * undefined macros and we do not ignore warnings on NuttX.
+ *
+ * Note: MYNEWT will give undefined warning, but some parts of the code
+ * interpret !defined(MYNEWT) as MYNEWT=0, so we shouldn't define it to zero
+ * either.
+ *
+ * Note 2: default_RNG_defined could probably set to 1 but this requires
+ * testing
+ */
+
+#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PRIVACY 0
+#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV 0
+#define MYNEWT_VAL_BLE_LL_DTM_EXTENSIONS 0
+#define MYNEWT_VAL_BLE_CONTROLLER 0
+#define default_RNG_defined 0
+#define BLETEST_THROUGHPUT_TEST 0
+#define MYNEWT_VAL_TRNG 0
+#define MYNEWT_VAL_SELFTEST 0
+
+#endif /* _NPL_H_ */
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/os_types.h b/src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/os_types.h
new file mode 100644
index 00000000..93d52891
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/os_types.h
@@ -0,0 +1,90 @@
+/*
+ * 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 _NPL_OS_TYPES_H
+#define _NPL_OS_TYPES_H
+
+#include <nuttx/config.h>
+#include <time.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <sched.h>
+#include <mqueue.h>
+
+/* The highest and lowest task priorities */
+#define OS_TASK_PRI_HIGHEST (sched_get_priority_max(SCHED_RR))
+#define OS_TASK_PRI_LOWEST (sched_get_priority_min(SCHED_RR))
+
+typedef uint32_t ble_npl_time_t;
+typedef int32_t ble_npl_stime_t;
+
+//typedef int os_sr_t;
+typedef int ble_npl_stack_t;
+
+
+struct ble_npl_event {
+ uint8_t ev_queued;
+ ble_npl_event_fn *ev_cb;
+ void *ev_arg;
+};
+
+struct ble_npl_eventq {
+ mqd_t mq;
+};
+
+struct ble_npl_callout {
+ struct ble_npl_event c_ev;
+ struct ble_npl_eventq *c_evq;
+ uint32_t c_ticks;
+ timer_t c_timer;
+ bool c_active;
+};
+
+struct ble_npl_mutex {
+ pthread_mutex_t lock;
+ pthread_mutexattr_t attr;
+ struct timespec wait;
+};
+
+struct ble_npl_sem {
+ sem_t lock;
+};
+
+struct ble_npl_task {
+ pthread_t handle;
+ pthread_attr_t attr;
+ struct sched_param param;
+ const char* name;
+};
+
+typedef void *(*ble_npl_task_func_t)(void *);
+
+int ble_npl_task_init(struct ble_npl_task *t, const char *name, ble_npl_task_func_t func,
+ void *arg, uint8_t prio, ble_npl_time_t sanity_itvl,
+ ble_npl_stack_t *stack_bottom, uint16_t stack_size);
+
+int ble_npl_task_remove(struct ble_npl_task *t);
+
+uint8_t ble_npl_task_count(void);
+
+void ble_npl_task_yield(void);
+
+#endif // _NPL_OS_TYPES_H
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_atomic.c b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_atomic.c
new file mode 100644
index 00000000..ceededb2
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_atomic.c
@@ -0,0 +1,39 @@
+/*
+ * 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 <nuttx/config.h>
+#include <stdint.h>
+#include <pthread.h>
+
+#include "nimble/nimble_npl.h"
+
+static pthread_mutex_t s_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+
+uint32_t
+ble_npl_hw_enter_critical(void)
+{
+ pthread_mutex_lock(&s_mutex);
+ return 0;
+}
+
+void
+ble_npl_hw_exit_critical(uint32_t ctx)
+{
+ pthread_mutex_unlock(&s_mutex);
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_callout.c b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_callout.c
new file mode 100644
index 00000000..affa1c2d
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_callout.c
@@ -0,0 +1,166 @@
+/*
+ * 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 <nuttx/config.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+#include <time.h>
+#include <signal.h>
+
+#include "nimble/nimble_npl.h"
+
+static void
+ble_npl_callout_timer_cb(union sigval sv)
+{
+ struct ble_npl_callout *c = (struct ble_npl_callout *)sv.sival_ptr;
+ assert(c);
+
+ if (c->c_evq) {
+ ble_npl_eventq_put(c->c_evq, &c->c_ev);
+ } else {
+ c->c_ev.ev_cb(&c->c_ev);
+ }
+}
+
+void
+ble_npl_callout_init(struct ble_npl_callout *c,
+ struct ble_npl_eventq *evq,
+ ble_npl_event_fn *ev_cb,
+ void *ev_arg)
+{
+ struct sigevent event;
+
+ /* Initialize the callout. */
+ memset(c, 0, sizeof(*c));
+ c->c_ev.ev_cb = ev_cb;
+ c->c_ev.ev_arg = ev_arg;
+ c->c_evq = evq;
+ c->c_active = false;
+
+ event.sigev_notify = SIGEV_THREAD;
+ event.sigev_value.sival_ptr = c; // put callout obj in signal args
+ event.sigev_notify_function = ble_npl_callout_timer_cb;
+ event.sigev_notify_attributes = NULL;
+
+ timer_create(CLOCK_REALTIME, &event, &c->c_timer);
+}
+
+bool
+ble_npl_callout_is_active(struct ble_npl_callout *c)
+{
+ /* TODO: seek native posix method to determine whether timer_t is active.
+ TODO: fix bug where one-shot timer is still active after fired. */
+
+ return c->c_active;
+}
+
+int
+ble_npl_callout_inited(struct ble_npl_callout *c)
+{
+ return (c->c_timer != NULL);
+}
+
+ble_npl_error_t
+ble_npl_callout_reset(struct ble_npl_callout *c,
+ ble_npl_time_t ticks)
+{
+ struct itimerspec its;
+
+ if (ticks < 0) {
+ return BLE_NPL_EINVAL;
+ }
+
+ if (ticks == 0) {
+ ticks = 1;
+ }
+
+ c->c_ticks = ble_npl_time_get() + ticks;
+
+ its.it_interval.tv_sec = 0;
+ its.it_interval.tv_nsec = 0; /* one shot */
+ its.it_value.tv_sec = (ticks / 1000);
+ its.it_value.tv_nsec = (ticks % 1000) * 1000000; /* expiration */
+ its.it_value.tv_nsec %= 1000000000;
+ c->c_active = true;
+ timer_settime(c->c_timer, 0, &its, NULL);
+
+ return BLE_NPL_OK;
+}
+
+int
+ble_npl_callout_queued(struct ble_npl_callout *c)
+{
+ struct itimerspec its;
+ timer_gettime(c->c_timer, &its);
+
+ return ((its.it_value.tv_sec > 0) ||
+ (its.it_value.tv_nsec > 0));
+}
+
+void
+ble_npl_callout_stop(struct ble_npl_callout *c)
+{
+ if (!ble_npl_callout_inited(c)) {
+ return;
+ }
+
+ struct itimerspec its;
+ its.it_interval.tv_sec = 0;
+ its.it_interval.tv_nsec = 0;
+ its.it_value.tv_sec = 0;
+ its.it_value.tv_nsec = 0;
+ timer_settime(c->c_timer, 0, &its, NULL);
+ c->c_active = false;
+}
+
+ble_npl_time_t
+ble_npl_callout_get_ticks(struct ble_npl_callout *co)
+{
+ return co->c_ticks;
+}
+
+void
+ble_npl_callout_set_arg(struct ble_npl_callout *co, void *arg)
+{
+ co->c_ev.ev_arg = arg;
+}
+
+uint32_t
+ble_npl_callout_remaining_ticks(struct ble_npl_callout *co,
+ ble_npl_time_t now)
+{
+ ble_npl_time_t rt;
+ uint32_t exp;
+
+ struct itimerspec its;
+ timer_gettime(co->c_timer, &its);
+
+ exp = its.it_value.tv_sec * 1000;
+
+ if (exp > now) {
+ rt = exp - now;
+ } else {
+ rt = 0;
+ }
+
+ return rt;
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_eventq.c b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_eventq.c
new file mode 100644
index 00000000..815b0969
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_eventq.c
@@ -0,0 +1,177 @@
+/*
+ * 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 <nuttx/config.h>
+#include <assert.h>
+#include <stdint.h>
+#include <string.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "nimble/nimble_npl.h"
+
+static struct ble_npl_eventq dflt_evq =
+{
+ .mq = (mqd_t)-1
+};
+
+int qnum = 0;
+
+struct ble_npl_eventq *
+ble_npl_eventq_dflt_get(void)
+{
+ return &dflt_evq;
+}
+
+void
+ble_npl_eventq_init(struct ble_npl_eventq *evq)
+{
+ char path[PATH_MAX];
+ struct mq_attr attr;
+ attr.mq_maxmsg = 16;
+ attr.mq_msgsize = sizeof(struct ble_npl_event*);
+ attr.mq_flags = 0;
+
+ qnum++;
+ sprintf(path, "/nimbleq%i", qnum);
+ evq->mq = mq_open(path, O_CREAT | O_RDWR, 0, &attr);
+ DEBUGASSERT((intptr_t)evq->mq >= 0);
+}
+
+bool
+ble_npl_eventq_is_empty(struct ble_npl_eventq *evq)
+{
+ struct mq_attr attr;
+ mq_getattr(evq->mq, &attr);
+
+ return (attr.mq_curmsgs == 0);
+}
+
+int
+ble_npl_eventq_inited(const struct ble_npl_eventq *evq)
+{
+ return (evq->mq != ((mqd_t)-1));
+}
+
+void
+ble_npl_eventq_put(struct ble_npl_eventq *evq, struct ble_npl_event *ev)
+{
+ if (ev->ev_queued)
+ {
+ return;
+ }
+
+ ev->ev_queued = 1;
+ mq_send(evq->mq, (const char*)&ev, sizeof(ev), 0);
+}
+
+struct ble_npl_event *
+ble_npl_eventq_get(struct ble_npl_eventq *evq,
+ ble_npl_time_t tmo)
+{
+ struct ble_npl_event *ev = NULL;
+
+ if (tmo == BLE_NPL_TIME_FOREVER)
+ {
+ do
+ {
+ mq_receive(evq->mq, (char*)&ev, sizeof(ev), NULL);
+ } while (ev && ev->ev_queued == 0);
+ }
+ else
+ {
+ struct timespec now, t;
+
+ clock_gettime(CLOCK_REALTIME, &now);
+
+ t.tv_sec += tmo / USEC_PER_SEC;
+ t.tv_nsec = (tmo - t.tv_sec) * NSEC_PER_MSEC;
+ clock_timespec_add(&now, &t, &t);
+
+ do
+ {
+ mq_timedreceive(evq->mq, (char*)&ev, sizeof(ev), NULL, &t);
+ } while (ev && ev->ev_queued == 0);
+ }
+
+ if (ev) {
+ ev->ev_queued = 0;
+ }
+
+ return ev;
+}
+
+void
+ble_npl_eventq_run(struct ble_npl_eventq *evq)
+{
+ struct ble_npl_event *ev;
+
+ ev = ble_npl_eventq_get(evq, BLE_NPL_TIME_FOREVER);
+ ble_npl_event_run(ev);
+}
+
+
+// ========================================================================
+// Event Implementation
+// ========================================================================
+
+void
+ble_npl_event_init(struct ble_npl_event *ev, ble_npl_event_fn *fn,
+ void *arg)
+{
+ memset(ev, 0, sizeof(*ev));
+ ev->ev_cb = fn;
+ ev->ev_arg = arg;
+}
+
+bool
+ble_npl_event_is_queued(struct ble_npl_event *ev)
+{
+ return ev->ev_queued;
+}
+
+void *
+ble_npl_event_get_arg(struct ble_npl_event *ev)
+{
+ return ev->ev_arg;
+}
+
+void
+ble_npl_event_set_arg(struct ble_npl_event *ev, void *arg)
+{
+ ev->ev_arg = arg;
+}
+
+void
+ble_npl_event_run(struct ble_npl_event *ev)
+{
+ assert(ev->ev_cb != NULL);
+
+ ev->ev_cb(ev);
+}
+
+void
+ble_npl_eventq_remove(struct ble_npl_eventq *evq, struct ble_npl_event *ev)
+{
+ /* we simply mark the event as unqueued. we will ignore these elements
+ * when receiving from the queue */
+
+ ev->ev_queued = 0;
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_mutex.c b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_mutex.c
new file mode 100644
index 00000000..0c43f369
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_mutex.c
@@ -0,0 +1,82 @@
+/*
+ * 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 <nuttx/config.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include "os/os.h"
+#include "nimble/nimble_npl.h"
+
+ble_npl_error_t
+ble_npl_mutex_init(struct ble_npl_mutex *mu)
+{
+ if (!mu) {
+ return BLE_NPL_INVALID_PARAM;
+ }
+
+ pthread_mutexattr_init(&mu->attr);
+ pthread_mutexattr_settype(&mu->attr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&mu->lock, &mu->attr);
+
+ return BLE_NPL_OK;
+}
+
+ble_npl_error_t
+ble_npl_mutex_release(struct ble_npl_mutex *mu)
+{
+ if (!mu) {
+ return BLE_NPL_INVALID_PARAM;
+ }
+
+ if (pthread_mutex_unlock(&mu->lock)) {
+ return BLE_NPL_BAD_MUTEX;
+ }
+
+ return BLE_NPL_OK;
+}
+
+ble_npl_error_t
+ble_npl_mutex_pend(struct ble_npl_mutex *mu, uint32_t timeout)
+{
+ int err;
+
+ if (!mu) {
+ return BLE_NPL_INVALID_PARAM;
+ }
+
+ if (timeout == BLE_NPL_TIME_FOREVER) {
+ err = pthread_mutex_lock(&mu->lock);
+ } else {
+ err = clock_gettime(CLOCK_REALTIME, &mu->wait);
+ if (err) {
+ return BLE_NPL_ERROR;
+ }
+
+ mu->wait.tv_sec += timeout / 1000;
+ mu->wait.tv_nsec += (timeout % 1000) * 1000000;
+
+ err = pthread_mutex_timedlock(&mu->lock, &mu->wait);
+ if (err == ETIMEDOUT) {
+ return BLE_NPL_TIMEOUT;
+ }
+ }
+
+ return (err) ? BLE_NPL_ERROR : BLE_NPL_OK;
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_sem.c b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_sem.c
new file mode 100644
index 00000000..91a70964
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_sem.c
@@ -0,0 +1,100 @@
+/*
+ * 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 <nuttx/config.h>
+#include <assert.h>
+#include <errno.h>
+#include <semaphore.h>
+
+#include "os/os.h"
+#include "nimble/nimble_npl.h"
+
+ble_npl_error_t
+ble_npl_sem_init(struct ble_npl_sem *sem, uint16_t tokens)
+{
+ if (!sem) {
+ return BLE_NPL_INVALID_PARAM;
+ }
+
+ sem_init(&sem->lock, 0, tokens);
+
+ return BLE_NPL_OK;
+}
+
+ble_npl_error_t
+ble_npl_sem_release(struct ble_npl_sem *sem)
+{
+ int err;
+
+ if (!sem) {
+ return BLE_NPL_INVALID_PARAM;
+ }
+
+ err = sem_post(&sem->lock);
+
+ return (err) ? BLE_NPL_ERROR : BLE_NPL_OK;
+}
+
+ble_npl_error_t
+ble_npl_sem_pend(struct ble_npl_sem *sem, uint32_t timeout)
+{
+ int err = 0;
+ struct timespec wait;
+
+ if (!sem) {
+ return BLE_NPL_INVALID_PARAM;
+ }
+
+ if (timeout == BLE_NPL_TIME_FOREVER) {
+ err = sem_wait(&sem->lock);
+ } else {
+ err = clock_gettime(CLOCK_REALTIME, &wait);
+ if (err) {
+ return BLE_NPL_ERROR;
+ }
+
+ wait.tv_sec += timeout / 1000;
+ wait.tv_nsec += (timeout % 1000) * 1000000;
+
+ err = sem_timedwait(&sem->lock, &wait);
+ if (err && errno == ETIMEDOUT) {
+ return BLE_NPL_TIMEOUT;
+ }
+ }
+
+ return (err) ? BLE_NPL_ERROR : BLE_NPL_OK;
+}
+
+uint16_t
+ble_npl_sem_get_count(struct ble_npl_sem *sem)
+{
+ int count;
+
+ assert(sem);
+ assert(&sem->lock);
+ sem_getvalue(&sem->lock, &count);
+
+ /* NuttX can return negative value, return 0 in that case */
+
+ if (count < 0) {
+ count = 0;
+ }
+
+ return count;
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_task.c b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_task.c
new file mode 100644
index 00000000..2e020236
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_task.c
@@ -0,0 +1,117 @@
+/*
+ * 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 <nuttx/config.h>
+#include "os/os.h"
+#include "nimble/nimble_npl.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Initialize a task.
+ *
+ * This function initializes the task structure pointed to by t,
+ * clearing and setting it's stack pointer, provides sane defaults
+ * and sets the task as ready to run, and inserts it into the operating
+ * system scheduler.
+ *
+ * @param t The task to initialize
+ * @param name The name of the task to initialize
+ * @param func The task function to call
+ * @param arg The argument to pass to this task function
+ * @param prio The priority at which to run this task
+ * @param sanity_itvl The time at which this task should check in with the
+ * sanity task. OS_WAIT_FOREVER means never check in
+ * here.
+ * @param stack_bottom A pointer to the bottom of a task's stack
+ * @param stack_size The overall size of the task's stack.
+ *
+ * @return 0 on success, non-zero on failure.
+ */
+int
+ble_npl_task_init(struct ble_npl_task *t, const char *name, ble_npl_task_func_t func,
+ void *arg, uint8_t prio, ble_npl_time_t sanity_itvl,
+ ble_npl_stack_t *stack_bottom, uint16_t stack_size)
+{
+ int err;
+ if ((t == NULL) || (func == NULL)) {
+ return OS_INVALID_PARM;
+ }
+
+ err = pthread_attr_init(&t->attr);
+ if (err) return err;
+ err = pthread_attr_getschedparam (&t->attr, &t->param);
+ if (err) return err;
+ err = pthread_attr_setschedpolicy(&t->attr, SCHED_RR);
+ if (err) return err;
+ t->param.sched_priority = prio;
+ err = pthread_attr_setschedparam (&t->attr, &t->param);
+ if (err) return err;
+
+ t->name = name;
+ err = pthread_create(&t->handle, &t->attr, func, arg);
+
+ return err;
+}
+
+/*
+ * Removes specified task
+ * XXX
+ * NOTE: This interface is currently experimental and not ready for common use
+ */
+int
+ble_npl_task_remove(struct ble_npl_task *t)
+{
+ return pthread_cancel(t->handle);
+}
+
+/**
+ * Return the number of tasks initialized.
+ *
+ * @return number of tasks initialized
+ */
+uint8_t
+ble_npl_task_count(void)
+{
+ return 0;
+}
+
+void *
+ble_npl_get_current_task_id(void)
+{
+ return (void *)(uintptr_t)pthread_self();
+}
+
+bool
+ble_npl_os_started(void)
+{
+ return true;
+}
+
+void
+ble_npl_task_yield(void)
+{
+ pthread_yield();
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_time.c b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_time.c
new file mode 100644
index 00000000..99b4c912
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/src/os_time.c
@@ -0,0 +1,85 @@
+/*
+ * 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 <nuttx/config.h>
+#include <assert.h>
+#include <stdint.h>
+#include <string.h>
+#include "os/os.h"
+#include "nimble/nimble_npl.h"
+
+#include <unistd.h>
+#include <time.h>
+
+/**
+ * Return ticks [ms] since system start as uint32_t.
+ */
+ble_npl_time_t
+ble_npl_time_get(void)
+{
+ struct timespec now;
+ if (clock_gettime(CLOCK_MONOTONIC, &now)) {
+ return 0;
+ }
+ return now.tv_sec * 1000.0 + now.tv_nsec / 1000000.0;
+}
+
+
+ble_npl_error_t
+ble_npl_time_ms_to_ticks(uint32_t ms, ble_npl_time_t *out_ticks)
+{
+ *out_ticks = ms;
+
+ return BLE_NPL_OK;
+}
+
+
+ble_npl_error_t
+ble_npl_time_ticks_to_ms(ble_npl_time_t ticks, uint32_t *out_ms)
+{
+ *out_ms = ticks;
+
+ return BLE_NPL_OK;
+}
+
+ble_npl_time_t
+ble_npl_time_ms_to_ticks32(uint32_t ms)
+{
+ return ms;
+}
+
+uint32_t
+ble_npl_time_ticks_to_ms32(ble_npl_time_t ticks)
+{
+ return ticks;
+}
+
+void
+ble_npl_time_delay(ble_npl_time_t ticks)
+{
+ struct timespec sleep_time;
+ long ms = ble_npl_time_ticks_to_ms32(ticks);
+ uint32_t s = ms / 1000;
+
+ ms -= s * 1000;
+ sleep_time.tv_sec = s;
+ sleep_time.tv_nsec = ms * 1000000;
+
+ nanosleep(&sleep_time, NULL);
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/src/wqueue.h b/src/libs/mynewt-nimble/porting/npl/nuttx/src/wqueue.h
new file mode 100644
index 00000000..7821eacd
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/src/wqueue.h
@@ -0,0 +1,104 @@
+/*
+ wqueue.h
+ Worker thread queue based on the Standard C++ library list
+ template class.
+ ------------------------------------------
+ Copyright (c) 2013 Vic Hargrave
+ Licensed 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.
+*/
+
+// https://vichargrave.github.io/articles/2013-01/multithreaded-work-queue-in-cpp
+// https://github.com/vichargrave/wqueue/blob/master/wqueue.h
+
+
+#ifndef __wqueue_h__
+#define __wqueue_h__
+
+#include <nuttx/config.h>
+#include <pthread.h>
+#include <queue.h>
+
+struct wqueue_s
+{
+ dq_queue_s m_queue;
+ pthread_mutex_t m_mutex;
+ pthread_mutexattr_t m_mutex_attr;
+ pthread_cond_t m_condv;
+};
+
+using namespace std;
+
+template <typename T> class wqueue
+{
+ dq_queue_s m_queue;
+ pthread_mutex_t m_mutex;
+ pthread_mutexattr_t m_mutex_attr;
+ pthread_cond_t m_condv;
+
+public:
+ wqueue()
+ {
+ dq_init(m_queue);
+ pthread_mutexattr_init(&m_mutex_attr);
+ pthread_mutexattr_settype(&m_mutex_attr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&m_mutex, &m_mutex_attr);
+ pthread_cond_init(&m_condv, NULL);
+ }
+
+ ~wqueue() {
+ pthread_mutex_destroy(&m_mutex);
+ pthread_cond_destroy(&m_condv);
+ }
+
+ void put(T item) {
+ dq_entry_t* entry = malloc(sizeof(T));
+
+ pthread_mutex_lock(&m_mutex);
+ dq_addlast(entry, &m_queue);
+ m_queue.push_back(item);
+ pthread_cond_signal(&m_condv);
+ pthread_mutex_unlock(&m_mutex);
+ }
+
+ T get(uint32_t tmo) {
+ pthread_mutex_lock(&m_mutex);
+ if (tmo) {
+ while (m_queue.size() == 0) {
+ pthread_cond_wait(&m_condv, &m_mutex);
+ }
+ }
+
+ T item = NULL;
+
+ if (m_queue.size() != 0) {
+ item = m_queue.front();
+ m_queue.pop_front();
+ }
+
+ pthread_mutex_unlock(&m_mutex);
+ return item;
+ }
+
+ void remove(T item) {
+ pthread_mutex_lock(&m_mutex);
+ m_queue.remove(item);
+ pthread_mutex_unlock(&m_mutex);
+ }
+
+ int size() {
+ pthread_mutex_lock(&m_mutex);
+ int size = m_queue.size();
+ pthread_mutex_unlock(&m_mutex);
+ return size;
+ }
+};
+
+#endif
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/test/Make.defs b/src/libs/mynewt-nimble/porting/npl/nuttx/test/Make.defs
new file mode 100644
index 00000000..a4bdce16
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/test/Make.defs
@@ -0,0 +1,58 @@
+#
+# 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.
+#
+
+CFLAGS += \
+ -I. \
+ -I$(NIMBLE_ROOT)/nimble/include \
+ -I$(NIMBLE_ROOT)/porting/npl/nuttx/include \
+ -I$(NIMBLE_ROOT)/porting/npl/nuttx/src \
+ -I$(NIMBLE_ROOT)/porting/nimble/include
+
+OSAL_PATH = $(NIMBLE_ROOT)/porting/npl/nuttx/src
+
+CSRCS = $(wildcard $(OSAL_PATH)/*.c) \
+ $(wildcard $(OSAL_PATH)/*.cc) \
+ $(NIMBLE_ROOT)/porting/nimble/src/os_mempool.c
+
+CXXOBJS += $($(wildcard *.cxx):$(CXXEXT)=$(SUFFIX)$(OBJEXT))
+
+CFLAGS += -DNIMBLE_CFG_CONTROLLER=0 -DOS_CFG_ALIGN_4=4 -DOS_CFG_ALIGNMENT=4
+
+DEPPATH += --dep-path $(NIMBLE_ROOT)/porting/npl/nuttx/test
+VPATH += :$(NIMBLE_ROOT)/porting/npl/nuttx/test
+VPATH += :$(NIMBLE_ROOT)/porting/nimble/src
+VPATH += :$(OSAL_PATH)
+
+PROGNAME = test_npl_task test_npl_eventq test_npl_callout test_npl_sem
+MAINSRC = $(wildcard $(NIMBLE_ROOT)/porting/npl/nuttx/test/*.c)
+
+clean::
+ (cd $(NIMBLE_ROOT)/porting/npl/nuttx/test && rm -f *.o)
+ (cd $(NIMBLE_ROOT)/porting/nimble/src && rm -f *.o)
+ (cd $(OSAL_PATH) && rm -f *.o)
+
+test_npl_task.exe: test_npl_task.o $(OBJS)
+ $(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
+
+test_npl_eventq.exe: test_npl_eventq.o $(OBJS)
+ $(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
+
+test_npl_callout.exe: test_npl_callout.o $(OBJS)
+ $(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
+
+test_npl_sem.exe: test_npl_sem.o $(OBJS)
+ $(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_callout.c b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_callout.c
new file mode 100644
index 00000000..d04303f8
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_callout.c
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ */
+
+/**
+ Unit tests for the ble_npl_callout api:
+
+ void ble_npl_callout_init(struct ble_npl_callout *cf, struct ble_npl_eventq *evq,
+ ble_npl_event_fn *ev_cb, void *ev_arg);
+ int ble_npl_callout_reset(struct ble_npl_callout *, int32_t);
+ int ble_npl_callout_queued(struct ble_npl_callout *c);
+ void ble_npl_callout_stop(struct ble_npl_callout *c);
+*/
+
+#include "test_util.h"
+#include "nimble/nimble_npl.h"
+
+#define TEST_ARGS_VALUE (55)
+#define TEST_INTERVAL (100)
+
+static bool s_tests_running = true;
+static struct ble_npl_task s_task;
+static struct ble_npl_callout s_callout;
+static int s_callout_args = TEST_ARGS_VALUE;
+
+static struct ble_npl_eventq s_eventq;
+
+
+void on_callout(struct ble_npl_event *ev)
+{
+ VerifyOrQuit(ev->ev_arg == &s_callout_args,
+ "callout: wrong args passed");
+
+ VerifyOrQuit(*(int*)ev->ev_arg == TEST_ARGS_VALUE,
+ "callout: args corrupted");
+
+ s_tests_running = false;
+}
+
+/**
+ * ble_npl_callout_init(struct ble_npl_callout *c, struct ble_npl_eventq *evq,
+ * ble_npl_event_fn *ev_cb, void *ev_arg)
+ */
+int test_init(void)
+{
+ ble_npl_callout_init(&s_callout,
+ &s_eventq,
+ on_callout,
+ &s_callout_args);
+ return PASS;
+}
+
+int test_queued(void)
+{
+ //VerifyOrQuit(ble_npl_callout_queued(&s_callout),
+ // "callout: not queued when expected");
+ return PASS;
+}
+
+int test_reset(void)
+{
+ return ble_npl_callout_reset(&s_callout, TEST_INTERVAL);
+}
+
+int test_stop(void)
+{
+ return PASS;
+}
+
+
+/**
+ * ble_npl_callout_init(struct ble_npl_callout *c, struct ble_npl_eventq *evq,
+ * ble_npl_event_fn *ev_cb, void *ev_arg)
+ */
+void *test_task_run(void *args)
+{
+ SuccessOrQuit(test_init(), "callout_init failed");
+ SuccessOrQuit(test_queued(), "callout_queued failed");
+ SuccessOrQuit(test_reset(), "callout_reset failed");
+
+ while (s_tests_running)
+ {
+ ble_npl_eventq_run(&s_eventq);
+ }
+
+ printf("All tests passed\n");
+ exit(PASS);
+
+ return NULL;
+}
+
+int main(void)
+{
+ ble_npl_eventq_init(&s_eventq);
+
+ SuccessOrQuit(ble_npl_task_init(&s_task, "s_task", test_task_run,
+ NULL, 1, 0, NULL, 0),
+ "task: error initializing");
+
+ while (1) {}
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_eventq.c b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_eventq.c
new file mode 100644
index 00000000..f0c362b9
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_eventq.c
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+/**
+ Unit tests for the ble_npl_eventq api:
+
+ void ble_npl_eventq_init(struct ble_npl_eventq *);
+ void ble_npl_eventq_put(struct ble_npl_eventq *, struct ble_npl_event *);
+ struct ble_npl_event *ble_npl_eventq_get_no_wait(struct ble_npl_eventq *evq);
+ struct ble_npl_event *ble_npl_eventq_get(struct ble_npl_eventq *);
+ void ble_npl_eventq_run(struct ble_npl_eventq *evq);
+ struct ble_npl_event *ble_npl_eventq_poll(struct ble_npl_eventq **, int, ble_npl_time_t);
+ void ble_npl_eventq_remove(struct ble_npl_eventq *, struct ble_npl_event *);
+ struct ble_npl_eventq *ble_npl_eventq_dflt_get(void);
+*/
+
+#include <assert.h>
+#include <pthread.h>
+#include "test_util.h"
+#include "nimble/nimble_npl.h"
+
+#define TEST_ARGS_VALUE (55)
+#define TEST_STACK_SIZE (1024)
+
+static bool s_tests_running = true;
+static struct ble_npl_task s_task_runner;
+static struct ble_npl_task s_task_dispatcher;
+
+static struct ble_npl_eventq s_eventq;
+static struct ble_npl_event s_event;
+static int s_event_args = TEST_ARGS_VALUE;
+
+
+void on_event(struct ble_npl_event *ev)
+{
+ VerifyOrQuit(ev->ev_arg == &s_event_args,
+ "callout: wrong args passed");
+
+ VerifyOrQuit(*(int*)ev->ev_arg == TEST_ARGS_VALUE,
+ "callout: args corrupted");
+
+ s_tests_running = false;
+}
+
+int test_init(void)
+{
+ //VerifyOrQuit(!ble_npl_eventq_inited(&s_eventq), "eventq: empty q initialized");
+ ble_npl_eventq_init(&s_eventq);
+ //VerifyOrQuit(ble_npl_eventq_inited(&s_eventq), "eventq: not initialized");
+
+ return PASS;
+}
+
+int test_run(void)
+{
+ while (s_tests_running)
+ {
+ ble_npl_eventq_run(&s_eventq);
+ }
+
+ return PASS;
+}
+
+int test_put(void)
+{
+ s_event.ev_cb = on_event;
+ s_event.ev_arg = &s_event_args;
+ ble_npl_eventq_put(&s_eventq, &s_event);
+ return PASS;
+}
+
+int test_get_no_wait(void)
+{
+ //struct ble_npl_event *ev = ble_npl_eventq_get_no_wait(&s_eventq);
+ return FAIL;
+}
+
+int test_get(void)
+{
+ struct ble_npl_event *ev = ble_npl_eventq_get(&s_eventq,
+ BLE_NPL_TIME_FOREVER);
+
+ VerifyOrQuit(ev == &s_event,
+ "callout: wrong event passed");
+
+ return PASS;
+}
+
+
+void *task_test_runner(void *args)
+{
+ int count = 1000000000;
+
+ SuccessOrQuit(test_init(), "eventq_init failed");
+ SuccessOrQuit(test_put(), "eventq_put failed");
+ SuccessOrQuit(test_get(), "eventq_get failed");
+ SuccessOrQuit(test_put(), "eventq_put failed");
+ SuccessOrQuit(test_run(), "eventq_run failed");
+
+ printf("All tests passed\n");
+ exit(PASS);
+
+ return NULL;
+}
+
+int main(void)
+{
+ SuccessOrQuit(ble_npl_task_init(&s_task_runner,
+ "task_test_runner",
+ task_test_runner,
+ NULL, 1, 0, NULL, 0),
+ "task: error initializing");
+
+ while (1) {}
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_mempool.c b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_mempool.c
new file mode 100644
index 00000000..2dac0bb1
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_mempool.c
@@ -0,0 +1,111 @@
+/*
+ * 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 "test_util.h"
+#include "nimble/nimble_npl.h"
+
+#define TEST_MEMPOOL_BLOCKS 4
+#define TEST_MEMPOOL_BLOCK_SIZE 128
+
+static struct ble_npl_mempool s_mempool;
+
+static os_membuf_t s_mempool_mem[OS_MEMPOOL_SIZE(TEST_MEMPOOL_BLOCKS,
+ TEST_MEMPOOL_BLOCK_SIZE)];
+
+static void *s_memblock[TEST_MEMPOOL_BLOCKS];
+
+/**
+ * Unit test for initializing a mempool.
+ *
+ * ble_npl_error_t ble_npl_mempool_init(struct ble_npl_mempool *mp, int blocks,
+ * int block_size, void *membuf, char *name);
+ *
+ */
+int test_init(void)
+{
+ int err;
+ err = ble_npl_mempool_init(NULL,
+ TEST_MEMPOOL_BLOCKS,
+ TEST_MEMPOOL_BLOCK_SIZE,
+ NULL,
+ "Null mempool");
+ VerifyOrQuit(err, "ble_npl_mempool_init accepted NULL parameters.");
+
+ err = ble_npl_mempool_init(&s_mempool,
+ TEST_MEMPOOL_BLOCKS,
+ TEST_MEMPOOL_BLOCK_SIZE,
+ s_mempool_mem,
+ "s_mempool");
+ return err;
+}
+
+/**
+ * Test integrity check of a mempool.
+ *
+ * bool ble_npl_mempool_is_sane(const struct ble_npl_mempool *mp);
+ */
+int test_is_sane(void)
+{
+ return (ble_npl_mempool_is_sane(&s_mempool)) ? PASS : FAIL;
+}
+
+/**
+ * Test getting a memory block from the pool, putting it back,
+ * and checking if it is still valid.
+ *
+ * void *ble_npl_memblock_get(struct ble_npl_mempool *mp);
+ *
+ * ble_npl_error_t ble_npl_memblock_put(struct ble_npl_mempool *mp, void *block_addr);
+ *
+ * int ble_npl_memblock_from(const struct ble_npl_mempool *mp, const void *block_addr);
+ */
+int test_stress(void)
+{
+ int loops = 3;
+ while(loops--)
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ s_memblock[i] = ble_npl_memblock_get(&s_mempool);
+ VerifyOrQuit(ble_npl_memblock_from(&s_mempool, s_memblock[i]),
+ "ble_npl_memblock_get return invalid block.");
+ }
+
+
+ for (int i = 0; i < 4; i++)
+ {
+ SuccessOrQuit(ble_npl_memblock_put(&s_mempool, s_memblock[i]),
+ "ble_npl_memblock_put refused to take valid block.");
+ //VerifyOrQuit(!ble_npl_memblock_from(&s_mempool, s_memblock[i]),
+ // "Block still valid after ble_npl_memblock_put.");
+ }
+
+ }
+ return PASS;
+}
+
+int main(void)
+{
+ SuccessOrQuit(test_init(), "Failed: ble_npl_mempool_init");
+ SuccessOrQuit(test_is_sane(), "Failed: ble_npl_mempool_is_sane");
+ SuccessOrQuit(test_stress(), "Failed: ble_npl_mempool stree test");
+ SuccessOrQuit(test_is_sane(), "Failed: ble_npl_mempool_is_sane");
+ printf("All tests passed\n");
+ return PASS;
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_sem.c b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_sem.c
new file mode 100644
index 00000000..b62f8e2a
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_sem.c
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+
+/**
+ Unit tests for the Semaphore api (ble_npl_sem):
+
+ ble_npl_error_t ble_npl_sem_init(struct ble_npl_sem *sem, uint16_t tokens);
+ ble_npl_error_t ble_npl_sem_release(struct ble_npl_sem *sem);
+ ble_npl_error_t ble_npl_sem_pend(struct ble_npl_sem *sem, uint32_t timeout);
+ uint16_t ble_npl_sem_get_count(struct ble_npl_sem *sem);
+*/
+
+#include "test_util.h"
+#include "nimble/nimble_npl.h"
+//#include "os/os.h"
+
+#define TEST_ITERATIONS 10
+
+#define TASK1_PRIO 1
+#define TASK2_PRIO 1
+
+#define TASK1_STACK_SIZE 1028
+#define TASK2_STACK_SIZE 1028
+
+static struct ble_npl_task task1;
+static struct ble_npl_task task2;
+
+static ble_npl_stack_t task1_stack[TASK1_STACK_SIZE];
+static ble_npl_stack_t task2_stack[TASK2_STACK_SIZE];
+
+struct ble_npl_sem task1_sem;
+struct ble_npl_sem task2_sem;
+
+/* Task 1 handler function */
+void *
+task1_handler(void *arg)
+{
+ for (int i = 0; i < TEST_ITERATIONS; i++)
+ {
+ /* Release semaphore to task 2 */
+ SuccessOrQuit(ble_npl_sem_release(&task1_sem),
+ "ble_npl_sem_release: error releasing task2_sem.");
+
+ /* Wait for semaphore from task 2 */
+ SuccessOrQuit(ble_npl_sem_pend(&task2_sem, BLE_NPL_TIME_FOREVER),
+ "ble_npl_sem_pend: error waiting for task2_sem.");
+ }
+
+ printf("All tests passed\n");
+ exit(PASS);
+
+ return NULL;
+}
+
+/* Task 2 handler function */
+void *
+task2_handler(void *arg)
+{
+ while(1)
+ {
+ /* Wait for semaphore from task1 */
+ SuccessOrQuit(ble_npl_sem_pend(&task1_sem, BLE_NPL_TIME_FOREVER),
+ "ble_npl_sem_pend: error waiting for task1_sem.");
+
+ /* Release task2 semaphore */
+ SuccessOrQuit(ble_npl_sem_release(&task2_sem),
+ "ble_npl_sem_release: error releasing task1_sem.");
+ }
+
+ return NULL;
+}
+
+
+/* Initialize task 1 exposed data objects */
+void
+task1_init(void)
+{
+ /* Initialize task1 semaphore */
+ SuccessOrQuit(ble_npl_sem_init(&task1_sem, 0),
+ "ble_npl_sem_init: task1 returned error.");
+}
+
+/* Initialize task 2 exposed data objects */
+void
+task2_init(void)
+{
+ /* Initialize task1 semaphore */
+ SuccessOrQuit(ble_npl_sem_init(&task2_sem, 0),
+ "ble_npl_sem_init: task2 returned error.");
+}
+
+/**
+ * init_app_tasks
+ *
+ * This function performs initializations that are required before tasks run.
+ *
+ * @return int 0 success; error otherwise.
+ */
+static int
+init_app_tasks(void)
+{
+ /*
+ * Call task specific initialization functions to initialize any shared objects
+ * before initializing the tasks with the OS.
+ */
+ task1_init();
+ task2_init();
+
+ /*
+ * Initialize tasks 1 and 2 with the OS.
+ */
+ ble_npl_task_init(&task1, "task1", task1_handler, NULL, TASK1_PRIO,
+ BLE_NPL_TIME_FOREVER, task1_stack, TASK1_STACK_SIZE);
+
+ ble_npl_task_init(&task2, "task2", task2_handler, NULL, TASK2_PRIO,
+ BLE_NPL_TIME_FOREVER, task2_stack, TASK2_STACK_SIZE);
+
+ return 0;
+}
+
+/**
+ * main
+ *
+ * The main function for the application. This function initializes the system and packages,
+ * calls the application specific task initialization function, then waits and dispatches
+ * events from the OS default event queue in an infinite loop.
+ */
+int
+main(int argc, char **arg)
+{
+ /* Initialize application specific tasks */
+ init_app_tasks();
+
+ while (1)
+ {
+ ble_npl_eventq_run(ble_npl_eventq_dflt_get());
+ }
+ /* main never returns */
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_task.c b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_task.c
new file mode 100644
index 00000000..66310cd7
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_task.c
@@ -0,0 +1,98 @@
+/*
+ * 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 "test_util.h"
+#include "nimble/nimble_npl.h"
+
+#include <pthread.h>
+
+#define TASK0_ARG 55
+#define TASK1_ARG 66
+
+static struct ble_npl_task s_task[2];
+static int s_task_arg[2] =
+{
+ TASK0_ARG, TASK1_ARG
+};
+
+
+void *task0_run(void *args)
+{
+ int i = 10000;
+ VerifyOrQuit(args == &s_task_arg[0], "Wrong args passed to task0");
+
+ while (i--)
+ {
+ }
+
+ return NULL;
+}
+
+void *task1_run(void *args)
+{
+ int i = 10000;
+ VerifyOrQuit(args == &s_task_arg[1], "Wrong args passed to task0");
+
+ while (i--)
+ {
+ }
+
+ printf("All tests passed\n");
+ exit(PASS);
+
+ return NULL;
+}
+
+/**
+ * Unit test for initializing a task.
+ *
+ * int ble_npl_task_init(struct ble_npl_task *t, const char *name, ble_npl_task_func_t func,
+ * void *arg, uint8_t prio, ble_npl_time_t sanity_itvl,
+ * ble_npl_stack_t *stack_bottom, uint16_t stack_size)
+ *
+ */
+int test_init(void)
+{
+ int err;
+ err = ble_npl_task_init(NULL,
+ "Null task",
+ NULL, NULL, 1, 0, NULL, 0);
+ VerifyOrQuit(err, "ble_npl_task_init accepted NULL parameters.");
+
+ err = ble_npl_task_init(&s_task[0],
+ "s_task[0]",
+ task0_run, &s_task_arg[0], 1, 0, NULL, 0);
+ SuccessOrQuit(err, "ble_npl_task_init failed.");
+
+ err = ble_npl_task_init(&s_task[1],
+ "s_task[1]",
+ task1_run, &s_task_arg[1], 1, 0, NULL, 0);
+
+ return err;
+}
+
+int main(void)
+{
+ int ret = PASS;
+ SuccessOrQuit(test_init(), "Failed: ble_npl_task_init");
+
+ pthread_exit(&ret);
+
+ return ret;
+}
diff --git a/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_util.h b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_util.h
new file mode 100644
index 00000000..90985c3f
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/npl/nuttx/test/test_util.h
@@ -0,0 +1,56 @@
+/*
+ * 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 _TEST_UTIL_H_
+#define _TEST_UTIL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define PASS (0)
+#define FAIL (-1)
+
+#define SuccessOrQuit(ERR, MSG) \
+ do { \
+ if ((ERR)) \
+ { \
+ fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, MSG); \
+ exit(-1); \
+ } \
+ } while (false)
+
+#define VerifyOrQuit(TST, MSG) \
+ do { \
+ if (!(TST)) \
+ { \
+ fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, MSG); \
+ exit(-1); \
+ } \
+ } while (false)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _TEST_UTIL_H_ */
diff --git a/src/libs/mynewt-nimble/porting/npl/riot/include/logcfg/logcfg.h b/src/libs/mynewt-nimble/porting/npl/riot/include/logcfg/logcfg.h
index e21a3ae5..837cdeac 100644
--- a/src/libs/mynewt-nimble/porting/npl/riot/include/logcfg/logcfg.h
+++ b/src/libs/mynewt-nimble/porting/npl/riot/include/logcfg/logcfg.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_LOGCFG_
diff --git a/src/libs/mynewt-nimble/porting/npl/riot/include/syscfg/syscfg.h b/src/libs/mynewt-nimble/porting/npl/riot/include/syscfg/syscfg.h
index e78ebe0a..816f410a 100644
--- a/src/libs/mynewt-nimble/porting/npl/riot/include/syscfg/syscfg.h
+++ b/src/libs/mynewt-nimble/porting/npl/riot/include/syscfg/syscfg.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_SYSCFG_
@@ -15,8 +15,6 @@
#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name
#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val
-
-
/*** @apache-mynewt-core/compiler/arm-none-eabi-m4 */
#ifndef MYNEWT_VAL_HARDFLOAT
#define MYNEWT_VAL_HARDFLOAT (0)
@@ -167,6 +165,10 @@
#define MYNEWT_VAL_NFC_PINS_AS_GPIO (1)
#endif
+#ifndef MYNEWT_VAL_OS_TICKS_PER_SEC
+#define MYNEWT_VAL_OS_TICKS_PER_SEC (128)
+#endif
+
#ifndef MYNEWT_VAL_PWM_0
#define MYNEWT_VAL_PWM_0 (0)
#endif
@@ -357,6 +359,10 @@
#undef MYNEWT_VAL_SPI_3_MASTER_PIN_SCK
+#ifndef MYNEWT_VAL_TEMP
+#define MYNEWT_VAL_TEMP (0)
+#endif
+
/* Overridden by @apache-mynewt-core/hw/bsp/nordic_pca10056 (defined by @apache-mynewt-core/hw/mcu/nordic/nrf52xxx) */
#ifndef MYNEWT_VAL_TIMER_0
#define MYNEWT_VAL_TIMER_0 (0)
@@ -427,7 +433,7 @@
#undef MYNEWT_VAL_UART_1_PIN_TX
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-core/hw/mcu/nordic/nrf52xxx) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-core/hw/mcu/nordic/nrf52xxx) */
#ifndef MYNEWT_VAL_XTAL_32768
#define MYNEWT_VAL_XTAL_32768 (1)
#endif
@@ -445,12 +451,12 @@
#define MYNEWT_VAL_FLOAT_USER (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-core/kernel/os) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-core/kernel/os) */
#ifndef MYNEWT_VAL_MSYS_1_BLOCK_COUNT
#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT (5)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-core/kernel/os) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-core/kernel/os) */
#ifndef MYNEWT_VAL_MSYS_1_BLOCK_SIZE
#define MYNEWT_VAL_MSYS_1_BLOCK_SIZE (88)
#endif
@@ -769,11 +775,19 @@
#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31)
#endif
+#ifndef MYNEWT_VAL_BLE_ISO
+#define MYNEWT_VAL_BLE_ISO (0)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_ISO_TEST
+#define MYNEWT_VAL_BLE_ISO_TEST (0)
+#endif
+
#ifndef MYNEWT_VAL_BLE_MAX_CONNECTIONS
#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble) */
#ifndef MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS
#define MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS (0)
#endif
@@ -823,7 +837,7 @@
#define MYNEWT_VAL_BLE_DEVICE (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
#ifndef MYNEWT_VAL_BLE_HW_WHITELIST_ENABLE
#define MYNEWT_VAL_BLE_HW_WHITELIST_ENABLE (0)
#endif
@@ -836,7 +850,11 @@
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_CONN_PARAM_REQ (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
+#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_CTRL_TO_HOST_FLOW_CONTROL
+#define MYNEWT_VAL_BLE_LL_CFG_FEAT_CTRL_TO_HOST_FLOW_CONTROL (0)
+#endif
+
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_DATA_LEN_EXT
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_DATA_LEN_EXT (0)
#endif
@@ -849,12 +867,12 @@
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CODED_PHY (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CSA2
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CSA2 (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION (0)
#endif
@@ -868,6 +886,16 @@
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV (0)
#endif
+/* Value copied from BLE_ISO */
+#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_ISO
+#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_ISO (0)
+#endif
+
+/* Value copied from BLE_ISO_TEST */
+#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_ISO_TEST
+#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_ISO_TEST (0)
+#endif
+
/* Value copied from BLE_PERIODIC_ADV */
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV (0)
@@ -888,16 +916,20 @@
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_SYNC_TRANSFER (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PRIVACY
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PRIVACY (0)
#endif
+#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_SCA_UPDATE
+#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_SCA_UPDATE (0)
+#endif
+
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_SLAVE_INIT_FEAT_XCHG
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_SLAVE_INIT_FEAT_XCHG (1)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_MAX_TX_BYTES
#define MYNEWT_VAL_BLE_LL_CONN_INIT_MAX_TX_BYTES (MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE)
#endif
@@ -910,12 +942,20 @@
#define MYNEWT_VAL_BLE_LL_CONN_INIT_SLOTS (4)
#endif
-#ifndef MYNEWT_VAL_BLE_LL_DBG_HCI_CMD_PIN
-#define MYNEWT_VAL_BLE_LL_DBG_HCI_CMD_PIN (-1)
+#ifndef MYNEWT_VAL_BLE_LL_DEBUG_GPIO_HCI_CMD
+#define MYNEWT_VAL_BLE_LL_DEBUG_GPIO_HCI_CMD (-1)
#endif
-#ifndef MYNEWT_VAL_BLE_LL_DBG_HCI_EV_PIN
-#define MYNEWT_VAL_BLE_LL_DBG_HCI_EV_PIN (-1)
+#ifndef MYNEWT_VAL_BLE_LL_DEBUG_GPIO_HCI_EV
+#define MYNEWT_VAL_BLE_LL_DEBUG_GPIO_HCI_EV (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_LL_DEBUG_GPIO_SCHED_ITEM_CB
+#define MYNEWT_VAL_BLE_LL_DEBUG_GPIO_SCHED_ITEM_CB (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_LL_DEBUG_GPIO_SCHED_RUN
+#define MYNEWT_VAL_BLE_LL_DEBUG_GPIO_SCHED_RUN (-1)
#endif
#ifndef MYNEWT_VAL_BLE_LL_DIRECT_TEST_MODE
@@ -980,6 +1020,11 @@
#define MYNEWT_VAL_BLE_LL_RNG_BUFSIZE (32)
#endif
+/* Value copied from BLE_LL_OUR_SCA */
+#ifndef MYNEWT_VAL_BLE_LL_SCA
+#define MYNEWT_VAL_BLE_LL_SCA (60)
+#endif
+
#ifndef MYNEWT_VAL_BLE_LL_SCHED_AUX_CHAIN_MAFS_DELAY
#define MYNEWT_VAL_BLE_LL_SCHED_AUX_CHAIN_MAFS_DELAY (0)
#endif
@@ -1000,12 +1045,12 @@
#define MYNEWT_VAL_BLE_LL_STRICT_CONN_SCHEDULING (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
#ifndef MYNEWT_VAL_BLE_LL_SUPP_MAX_RX_BYTES
#define MYNEWT_VAL_BLE_LL_SUPP_MAX_RX_BYTES (MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/controller) */
#ifndef MYNEWT_VAL_BLE_LL_SUPP_MAX_TX_BYTES
#define MYNEWT_VAL_BLE_LL_SUPP_MAX_TX_BYTES (MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE)
#endif
@@ -1372,7 +1417,7 @@
#define MYNEWT_VAL_BLE_SM_KEYPRESS (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/host) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/host) */
#ifndef MYNEWT_VAL_BLE_SM_LEGACY
#define MYNEWT_VAL_BLE_SM_LEGACY (0)
#endif
@@ -1393,7 +1438,7 @@
#define MYNEWT_VAL_BLE_SM_OUR_KEY_DIST (0)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/host) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/host) */
#ifndef MYNEWT_VAL_BLE_SM_SC
#define MYNEWT_VAL_BLE_SM_SC (0)
#endif
@@ -1465,9 +1510,9 @@
#endif
/*** @apache-mynewt-nimble/nimble/transport/ram */
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/transport/ram) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/transport/ram) */
#ifndef MYNEWT_VAL_BLE_ACL_BUF_COUNT
-#define MYNEWT_VAL_BLE_ACL_BUF_COUNT (4)
+#define MYNEWT_VAL_BLE_ACL_BUF_COUNT (24)
#endif
#ifndef MYNEWT_VAL_BLE_ACL_BUF_SIZE
@@ -1478,7 +1523,7 @@
#define MYNEWT_VAL_BLE_HCI_EVT_BUF_SIZE (70)
#endif
-/* Overridden by @apache-mynewt-nimble/targets/riot (defined by @apache-mynewt-nimble/nimble/transport/ram) */
+/* Overridden by @apache-mynewt-nimble/porting/targets/riot (defined by @apache-mynewt-nimble/nimble/transport/ram) */
#ifndef MYNEWT_VAL_BLE_HCI_EVT_HI_BUF_COUNT
#define MYNEWT_VAL_BLE_HCI_EVT_HI_BUF_COUNT (2)
#endif
diff --git a/src/libs/mynewt-nimble/porting/npl/riot/include/sysflash/sysflash.h b/src/libs/mynewt-nimble/porting/npl/riot/include/sysflash/sysflash.h
index 413cb267..ab1341b2 100644
--- a/src/libs/mynewt-nimble/porting/npl/riot/include/sysflash/sysflash.h
+++ b/src/libs/mynewt-nimble/porting/npl/riot/include/sysflash/sysflash.h
@@ -1,5 +1,5 @@
/**
- * This file was generated by Apache newt version: 1.8.0-dev
+ * This file was generated by Apache newt version: 1.9.0-dev
*/
#ifndef H_MYNEWT_SYSFLASH_
diff --git a/src/libs/mynewt-nimble/porting/targets/linux/pkg.yml b/src/libs/mynewt-nimble/porting/targets/linux/pkg.yml
index f1159d4a..c819a83c 100644
--- a/src/libs/mynewt-nimble/porting/targets/linux/pkg.yml
+++ b/src/libs/mynewt-nimble/porting/targets/linux/pkg.yml
@@ -16,7 +16,7 @@
# under the License.
#
-pkg.name: "targets/linux"
+pkg.name: "porting/targets/linux"
pkg.type: "target"
pkg.description: This target is used to generate syscfg.h file and other artifacts for linux example app.
pkg.author:
diff --git a/src/libs/mynewt-nimble/porting/targets/linux_blemesh/pkg.yml b/src/libs/mynewt-nimble/porting/targets/linux_blemesh/pkg.yml
index c3149333..3cbe09a4 100644
--- a/src/libs/mynewt-nimble/porting/targets/linux_blemesh/pkg.yml
+++ b/src/libs/mynewt-nimble/porting/targets/linux_blemesh/pkg.yml
@@ -16,7 +16,7 @@
# under the License.
#
-pkg.name: "targets/linux_blemesh"
+pkg.name: "porting/targets/linux_blemesh"
pkg.type: "target"
pkg.description: This target is used to generate syscfg.h file and other artifacts for linux_blemesh example app.
pkg.author:
diff --git a/src/libs/mynewt-nimble/porting/targets/nuttx/pkg.yml b/src/libs/mynewt-nimble/porting/targets/nuttx/pkg.yml
new file mode 100644
index 00000000..e105cd63
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/targets/nuttx/pkg.yml
@@ -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.
+#
+
+pkg.name: "porting/targets/nuttx"
+pkg.type: "target"
+pkg.description: This target is used to generate syscfg.h file and other artifacts for nuttx example app.
+pkg.author:
+pkg.homepage:
+
+pkg.deps:
+- "@apache-mynewt-core/kernel/os"
+- "@apache-mynewt-core/sys/console/stub"
+- "@apache-mynewt-core/sys/log/stub"
+- "@apache-mynewt-core/sys/stats/stub"
+- "@apache-mynewt-nimble/nimble/host"
+- "@apache-mynewt-nimble/nimble/transport/socket"
+- "@apache-mynewt-nimble/nimble/host/services/ans"
+- "@apache-mynewt-nimble/nimble/host/services/bas"
+- "@apache-mynewt-nimble/nimble/host/services/dis"
+- "@apache-mynewt-nimble/nimble/host/services/gap"
+- "@apache-mynewt-nimble/nimble/host/services/gatt"
+- "@apache-mynewt-nimble/nimble/host/services/ias"
+- "@apache-mynewt-nimble/nimble/host/services/ipss"
+- "@apache-mynewt-nimble/nimble/host/services/lls"
+- "@apache-mynewt-nimble/nimble/host/services/tps"
diff --git a/src/libs/mynewt-nimble/porting/targets/nuttx/syscfg.yml b/src/libs/mynewt-nimble/porting/targets/nuttx/syscfg.yml
new file mode 100644
index 00000000..fdfa7b59
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/targets/nuttx/syscfg.yml
@@ -0,0 +1,28 @@
+# 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.
+#
+
+syscfg.vals:
+ BLE_SOCK_USE_TCP: 0
+ BLE_SOCK_USE_NUTTX: 1
+ BLE_SOCK_TASK_PRIO: 3
+ BLE_SOCK_STACK_SIZE: 1028
+ BLE_LL_CFG_FEAT_LL_PRIVACY: 0
+ LOG_LEVEL: 2
+ BLE_SM_LEGACY: 1
+ BLE_SM_SC: 1
+
diff --git a/src/libs/mynewt-nimble/porting/targets/nuttx/target.yml b/src/libs/mynewt-nimble/porting/targets/nuttx/target.yml
new file mode 100644
index 00000000..9ab4152c
--- /dev/null
+++ b/src/libs/mynewt-nimble/porting/targets/nuttx/target.yml
@@ -0,0 +1,20 @@
+# 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.
+#
+target.app: "porting/targets/dummy_app"
+target.bsp: "porting/targets/dummy_bsp"
+target.build_profile: "debug"
diff --git a/src/libs/mynewt-nimble/porting/targets/porting_default/pkg.yml b/src/libs/mynewt-nimble/porting/targets/porting_default/pkg.yml
index f7319c25..44a34ba0 100644
--- a/src/libs/mynewt-nimble/porting/targets/porting_default/pkg.yml
+++ b/src/libs/mynewt-nimble/porting/targets/porting_default/pkg.yml
@@ -16,7 +16,7 @@
# under the License.
#
-pkg.name: "targets/porting_default"
+pkg.name: "porting/targets/porting_default"
pkg.type: "target"
pkg.description: This target is used to generate syscfg.h file and other artifacts for default Nimble port includes.
pkg.author:
diff --git a/src/libs/mynewt-nimble/porting/targets/riot/pkg.yml b/src/libs/mynewt-nimble/porting/targets/riot/pkg.yml
index b6610c30..7d1a3243 100644
--- a/src/libs/mynewt-nimble/porting/targets/riot/pkg.yml
+++ b/src/libs/mynewt-nimble/porting/targets/riot/pkg.yml
@@ -16,7 +16,7 @@
# under the License.
#
-pkg.name: "targets/riot"
+pkg.name: "porting/targets/riot"
pkg.type: "target"
pkg.description: This target is used to generate syscfg.h file and other artifacts for RIOT Nimble port.
pkg.author:
diff --git a/src/libs/mynewt-nimble/porting/targets/riot/syscfg.yml b/src/libs/mynewt-nimble/porting/targets/riot/syscfg.yml
index 7bbb57fe..d6ee102b 100644
--- a/src/libs/mynewt-nimble/porting/targets/riot/syscfg.yml
+++ b/src/libs/mynewt-nimble/porting/targets/riot/syscfg.yml
@@ -17,7 +17,7 @@
#
syscfg.vals:
- BLE_ACL_BUF_COUNT: 4
+ BLE_ACL_BUF_COUNT: 24
BLE_HCI_EVT_HI_BUF_COUNT: 2
BLE_HW_WHITELIST_ENABLE: 0
BLE_LL_CFG_FEAT_DATA_LEN_EXT: 0
diff --git a/src/libs/mynewt-nimble/porting/update_generated_files.sh b/src/libs/mynewt-nimble/porting/update_generated_files.sh
index c01dddd2..6309ed2b 100755
--- a/src/libs/mynewt-nimble/porting/update_generated_files.sh
+++ b/src/libs/mynewt-nimble/porting/update_generated_files.sh
@@ -23,6 +23,7 @@ if [ ! -f "project.yml" ]; then
fi
declare -A targets=(
+ ["nuttx"]="repos/apache-mynewt-nimble/porting/examples/nuttx/"
["linux"]="repos/apache-mynewt-nimble/porting/examples/linux/"
["linux_blemesh"]="repos/apache-mynewt-nimble/porting/examples/linux_blemesh/"
["porting_default"]="repos/apache-mynewt-nimble/porting/nimble"
@@ -31,6 +32,11 @@ declare -A targets=(
for target in "${!targets[@]}"; do
echo "Updating target $target"
- newt build "$target" > /dev/null 2>&1
- cp "bin/@apache-mynewt-nimble/targets/${target}/generated/include" "${targets[$target]}" -r
+ newt build "@apache-mynewt-nimble/porting/targets/$target" > /dev/null 2>&1
+ cp "bin/@apache-mynewt-nimble/porting/targets/${target}/generated/include" "${targets[$target]}" -r
+ # Remove repo version and hash MYNEWT_VALS as it doesn't make much sense to commit them and they
+ # defeat the purpose of this script.
+ find "${targets[$target]}/include" -type f -name 'syscfg.h' -exec sed -i '/MYNEWT_VAL_REPO_*/,/#endif/d' {} \;
+ find "${targets[$target]}/include" -type f -name 'syscfg.h' -exec sed -i '/\/\*\*\* Repository/,/\*\//d' {} \;
+ find "${targets[$target]}/include" -type f -name 'syscfg.h' -exec sed -i '$!N;/^\n$/{$q;D;};P;D;' {} \;
done