From 4d9eee14e96d1c501a3f623a64f7ce2f70768f94 Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Thu, 24 May 2018 14:05:02 +0200 Subject: [PATCH] nimble/ll: Add workaround for initializing LL task on RIOT This is just a workaround, we need to find some more generic solution here. --- nimble/controller/src/ble_ll.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nimble/controller/src/ble_ll.c b/nimble/controller/src/ble_ll.c index 49c77219c..88f9f9892 100644 --- a/nimble/controller/src/ble_ll.c +++ b/nimble/controller/src/ble_ll.c @@ -1090,6 +1090,17 @@ ble_ll_task(void *arg) { struct ble_npl_event *ev; + /* + * XXX RIOT ties event queue to a thread which initialized it so we need to + * create event queue in LL task, not in general init function. This can + * lead to some races between host and LL so for now let us have it as a + * hack for RIOT where races can be avoided by proper initialization inside + * package. + */ +#ifdef RIOT_VERSION + ble_npl_eventq_init(&g_ble_ll_data.ll_evq); +#endif + /* Init ble phy */ ble_phy_init(); @@ -1456,8 +1467,17 @@ ble_ll_init(void) lldata->ll_num_acl_pkts = MYNEWT_VAL(BLE_ACL_BUF_COUNT); lldata->ll_acl_pkt_size = MYNEWT_VAL(BLE_ACL_BUF_SIZE); + /* + * XXX RIOT ties event queue to a thread which initialized it so we need to + * create event queue in LL task, not in general init function. This can + * lead to some races between host and LL so for now let us have it as a + * hack for RIOT where races can be avoided by proper initialization inside + * package. + */ +#ifndef RIOT_VERSION /* Initialize eventq */ ble_npl_eventq_init(&lldata->ll_evq); +#endif /* Initialize the transmit (from host) and receive (from phy) queues */ STAILQ_INIT(&lldata->ll_tx_pkt_q);