Skip to content

Commit

Permalink
nimble/transport: Fix build with RX task
Browse files Browse the repository at this point in the history
Move syscfg to enable RX task to main transport package.

RX task priority should not be set to default value to avoid conflicts
with other task priorities if RX task is not used (this is always
verified by newt). Since empty value is not a valid priority we should
better only define that setting if RX task is enabled and do the same
for RX task stack size for consistency.

nrf5340 transport needs subrpio 1 to be able to override values set by
transport.
  • Loading branch information
andrzej-kaczmarek committed Aug 9, 2024
1 parent c5881fa commit 4394e2d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions nimble/transport/nrf5340/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pkg.name: nimble/transport/nrf5340
pkg.description: HCI transport for nRF5340
pkg.author: "Apache Mynewt <dev@mynewt.apache.org>"
pkg.homepage: "http://mynewt.apache.org/"
pkg.subpriority: 1
pkg.keywords:
- ble
- bluetooth
Expand Down
4 changes: 2 additions & 2 deletions nimble/transport/nrf5340/src/nrf5340_ble_hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ nrf5340_ble_hci_trans_rx(int channel, void *user_data)
{
assert(channel == IPC_RX_CHANNEL);

#if MYNEWT_VAL(BLE_TRANSPORT_NRF5340_RX_TASK)
#if MYNEWT_VAL(BLE_TRANSPORT_RX_TASK)
ble_transport_rx();
#else
rx_func(NULL);
Expand All @@ -123,7 +123,7 @@ nrf5340_ble_hci_init(void)
{
SYSINIT_ASSERT_ACTIVE();

#if MYNEWT_VAL(BLE_TRANSPORT_NRF5340_RX_TASK)
#if MYNEWT_VAL(BLE_TRANSPORT_RX_TASK)
ble_transport_rx_register(rx_func, NULL);
#endif
ipc_nrf5340_recv(IPC_RX_CHANNEL, nrf5340_ble_hci_trans_rx, NULL);
Expand Down
13 changes: 3 additions & 10 deletions nimble/transport/nrf5340/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@
# specific language governing permissions and limitations
# under the License.

syscfg.defs:
BLE_TRANSPORT_NRF5340_RX_TASK:
description: >
Use separate task for RX. This is required and enabled by default
if monitor is used, optional otherwise.
value: 0

syscfg.vals.BLE_MONITOR:
BLE_TRANSPORT_NRF5340_RX_TASK: 1
BLE_TRANSPORT_RX_PRIO: 1
BLE_TRANSPORT_RX_STACK_SIZE: 120
BLE_TRANSPORT_RX_TASK: 1
BLE_TRANSPORT_RX_TASK_PRIO: 1
BLE_TRANSPORT_RX_TASK_STACK_SIZE: 120
8 changes: 4 additions & 4 deletions nimble/transport/src/rx_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#include <nimble/transport.h>
#include <nimble/nimble_npl.h>

#if !defined(MYNEWT) || MYNEWT_VAL(BLE_TRANSPORT_RX_STACK_SIZE) > 0
#if MYNEWT_VAL(BLE_TRANSPORT_RX_TASK)

static ble_transport_rx_func_t *rx_func;
static void *rx_func_arg;

#if MYNEWT
OS_TASK_STACK_DEFINE(rx_stack, MYNEWT_VAL(BLE_TRANSPORT_RX_STACK_SIZE));
OS_TASK_STACK_DEFINE(rx_stack, MYNEWT_VAL(BLE_TRANSPORT_RX_TASK_STACK_SIZE));
static struct os_task rx_task;
#endif

Expand Down Expand Up @@ -70,8 +70,8 @@ ble_transport_rx_register(ble_transport_rx_func_t *func, void *arg)

#ifdef MYNEWT
os_task_init(&rx_task, "hci_rx_task", rx_task_func, NULL,
MYNEWT_VAL(BLE_TRANSPORT_RX_PRIO), OS_WAIT_FOREVER, rx_stack,
MYNEWT_VAL(BLE_TRANSPORT_RX_STACK_SIZE));
MYNEWT_VAL(BLE_TRANSPORT_RX_TASK_PRIO), OS_WAIT_FOREVER,
rx_stack, MYNEWT_VAL(BLE_TRANSPORT_RX_TASK_STACK_SIZE));
#endif
}

Expand Down
15 changes: 12 additions & 3 deletions nimble/transport/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,21 @@ syscfg.defs:
of ISO buffers available for controller.
value: MYNEWT_VAL(BLE_TRANSPORT_ISO_COUNT)

BLE_TRANSPORT_RX_PRIO:
BLE_TRANSPORT_RX_TASK:
description: >
Use separate task for RX. Only works with transport that do have
explicit support to use this feature.
value: 0

syscfg.defs.BLE_TRANSPORT_RX_TASK:
BLE_TRANSPORT_RX_TASK_PRIO:
description: Priority of RX task
type: task_priority
value: 126
BLE_TRANSPORT_RX_STACK_SIZE:
restrictions: $notnull
value:
BLE_TRANSPORT_RX_TASK_STACK_SIZE:
description: Stack size of RX task
restrictions: $notnull
value:

# import monitor and defunct settings from separate file to reduce clutter in main file
Expand Down

0 comments on commit 4394e2d

Please sign in to comment.