This is an automated email from the ASF dual-hosted git repository. rymek pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 55e2c86357202927d48c5a3b7d437a462030b3cb Author: Mehul Hirpara <mehul.hirp...@inedasystems.com> AuthorDate: Wed Oct 24 17:31:27 2018 +0530 [porting][linux] Added required APIs to build glue.c for BLE Mesh app --- porting/npl/linux/src/os_callout.c | 27 +++++++++++++++++++++++++++ porting/npl/linux/src/os_eventq.cc | 12 ++++++++++++ porting/npl/linux/src/os_time.c | 7 +++++++ 3 files changed, 46 insertions(+) diff --git a/porting/npl/linux/src/os_callout.c b/porting/npl/linux/src/os_callout.c index 1804705..d3091fa 100644 --- a/porting/npl/linux/src/os_callout.c +++ b/porting/npl/linux/src/os_callout.c @@ -129,3 +129,30 @@ 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/porting/npl/linux/src/os_eventq.cc b/porting/npl/linux/src/os_eventq.cc index 0415836..2ede70b 100644 --- a/porting/npl/linux/src/os_eventq.cc +++ b/porting/npl/linux/src/os_eventq.cc @@ -46,6 +46,18 @@ ble_npl_eventq_init(struct ble_npl_eventq *evq) evq->q = new wqueue_t(); } +bool +ble_npl_eventq_is_empty(struct ble_npl_eventq *evq) +{ + wqueue_t *q = static_cast<wqueue_t *>(evq->q); + + if (q->size()) { + return 1; + } else { + return 0; + } +} + int ble_npl_eventq_inited(const struct ble_npl_eventq *evq) { diff --git a/porting/npl/linux/src/os_time.c b/porting/npl/linux/src/os_time.c index 613e299..6df2e25 100644 --- a/porting/npl/linux/src/os_time.c +++ b/porting/npl/linux/src/os_time.c @@ -23,6 +23,7 @@ #include "os/os.h" #include "nimble/nimble_npl.h" +#include <unistd.h> #include <time.h> /** @@ -63,3 +64,9 @@ 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) +{ + sleep(ble_npl_time_ticks_to_ms32(ticks)/1000); +}