From d90b7274fa8bbfa09f79660b45b550d91f7b0125 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Tue, 2 Feb 2021 22:09:00 +0100 Subject: Update to nimble 1.3 master branch commit 82153e744833821e20e9a8b0d61c38b2b0dbcfe1 WARNING : heartbeat task is disabled! --- .../npl/freertos/include/nimble/nimble_npl_os.h | 2 - .../npl/freertos/src/nimble_port_freertos.c | 4 +- .../porting/npl/freertos/src/npl_os_freertos.c | 6 - .../porting/npl/nuttx/include/console/console.h | 36 +++++ .../porting/npl/nuttx/include/modlog/modlog.h | 68 ++++++++ .../npl/nuttx/include/nimble/nimble_npl_os.h | 71 +++++++++ .../porting/npl/nuttx/include/nimble/os_types.h | 90 +++++++++++ .../porting/npl/nuttx/src/os_atomic.c | 39 +++++ .../porting/npl/nuttx/src/os_callout.c | 166 +++++++++++++++++++ .../porting/npl/nuttx/src/os_eventq.c | 177 +++++++++++++++++++++ .../mynewt-nimble/porting/npl/nuttx/src/os_mutex.c | 82 ++++++++++ .../mynewt-nimble/porting/npl/nuttx/src/os_sem.c | 100 ++++++++++++ .../mynewt-nimble/porting/npl/nuttx/src/os_task.c | 117 ++++++++++++++ .../mynewt-nimble/porting/npl/nuttx/src/os_time.c | 85 ++++++++++ .../mynewt-nimble/porting/npl/nuttx/src/wqueue.h | 104 ++++++++++++ .../mynewt-nimble/porting/npl/nuttx/test/Make.defs | 58 +++++++ .../porting/npl/nuttx/test/test_npl_callout.c | 116 ++++++++++++++ .../porting/npl/nuttx/test/test_npl_eventq.c | 131 +++++++++++++++ .../porting/npl/nuttx/test/test_npl_mempool.c | 111 +++++++++++++ .../porting/npl/nuttx/test/test_npl_sem.c | 155 ++++++++++++++++++ .../porting/npl/nuttx/test/test_npl_task.c | 98 ++++++++++++ .../porting/npl/nuttx/test/test_util.h | 56 +++++++ .../porting/npl/riot/include/logcfg/logcfg.h | 2 +- .../porting/npl/riot/include/syscfg/syscfg.h | 93 ++++++++--- .../porting/npl/riot/include/sysflash/sysflash.h | 2 +- 25 files changed, 1933 insertions(+), 36 deletions(-) create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/include/console/console.h create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/include/modlog/modlog.h create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/nimble_npl_os.h create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/include/nimble/os_types.h create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/src/os_atomic.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/src/os_callout.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/src/os_eventq.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/src/os_mutex.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/src/os_sem.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/src/os_task.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/src/os_time.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/src/wqueue.h create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/test/Make.defs create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_callout.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_eventq.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_mempool.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_sem.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/test/test_npl_task.c create mode 100644 src/libs/mynewt-nimble/porting/npl/nuttx/test/test_util.h (limited to 'src/libs/mynewt-nimble/porting/npl') 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 +#include + +#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 +#include + +#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 +#include +#include +#include + +#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 +#include +#include +#include +#include +#include +#include +#include + +/* 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 +#include +#include + +#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 +#include +#include +#include +#include + +#include +#include + +#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 +#include +#include +#include +#include +#include +#include + +#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 +#include +#include + +#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 +#include +#include +#include + +#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 +#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 +#include +#include +#include +#include "os/os.h" +#include "nimble/nimble_npl.h" + +#include +#include + +/** + * 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 +#include +#include + +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 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 +#include +#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 + +#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 +#include + +#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_ -- cgit v1.2.3