Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/nimble/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PKG_NAME = nimble
PKG_URL = https://github.com/apache/mynewt-nimble.git
PKG_VERSION = a7b3c939146e735b59d55bff740c906bde6f86f9
PKG_VERSION = 9d4bda2edcf0e7c2a03aa908321293a53361d258
PKG_LICENSE = Apache-2.0

TDIR = $(RIOTPKG)/$(PKG_NAME)
Expand Down
15 changes: 12 additions & 3 deletions tests/nimble_l2cap/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@

#include "assert.h"
#include "shell.h"
#include "thread.h"
#include "thread_flags.h"
#include "net/bluetil/ad.h"

#include "nimble_l2cap_test_conf.h"

#define ENABLE_DEBUG (1)
#include "debug.h"

#define FLAG_UP (1u << 0)
#define FLAG_SYNC (1u << 1)
#define FLAG_UP (1u << 0)
#define FLAG_SYNC (1u << 1)
#define FLAG_TX_UNSTALLED (1u << 2)

/* synchronization state */
static thread_t *_main;
Expand Down Expand Up @@ -96,6 +99,9 @@ static int _on_l2cap_evt(struct ble_l2cap_event *event, void *arg)
case BLE_L2CAP_EVENT_COC_DATA_RECEIVED:
_on_data(event);
break;
case BLE_L2CAP_EVENT_COC_TX_UNSTALLED:
thread_flags_set(_main, FLAG_TX_UNSTALLED);
break;
case BLE_L2CAP_EVENT_COC_ACCEPT:
/* this event should never be triggered for the L2CAP client */
/* fallthrough */
Expand Down Expand Up @@ -191,9 +197,12 @@ static void _send(uint32_t type, uint32_t seq, size_t len)

do {
res = ble_l2cap_send(_coc, txd);
if (res == BLE_HS_EBUSY) {
thread_flags_wait_all(FLAG_TX_UNSTALLED);
}
} while (res == BLE_HS_EBUSY);

if (res != 0) {
if ((res != 0) && (res != BLE_HS_ESTALLED)) {
printf("# err: failed to send (%i)\n", res);
assert(0);
}
Expand Down
5 changes: 4 additions & 1 deletion tests/nimble_l2cap_server/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void _on_data(struct ble_l2cap_event *event)
printf("# Received: len %5i, seq %5u\n", rx_len, (unsigned)_rxbuf[POS_SEQ]);

res = ble_l2cap_send(_coc, rxd);
assert(res == 0);
assert((res == 0) || (res == BLE_HS_ESTALLED));

/* allocate new mbuf for receiving new data */
rxd = os_mbuf_get_pkthdr(&_coc_mbuf_pool, 0);
Expand Down Expand Up @@ -118,6 +118,9 @@ static int _on_l2cap_evt(struct ble_l2cap_event *event, void *arg)
case BLE_L2CAP_EVENT_COC_DATA_RECEIVED:
_on_data(event);
break;
case BLE_L2CAP_EVENT_COC_TX_UNSTALLED:
/* this event is expected, but we have nothing to do here */
break;
default:
assert(0);
break;
Expand Down
2 changes: 1 addition & 1 deletion tests/nimble_l2cap_server/nimble.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CFLAGS += -DAPP_CID=$(APP_CID)
# configure NimBLE
USEPKG += nimble
CFLAGS += -DMYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM=1
CFLAGS += -DMYNEWT_VAL_BLE_L2CAP_COC_MTU=250
CFLAGS += -DMYNEWT_VAL_BLE_L2CAP_COC_MPS=250
CFLAGS += -DMYNEWT_VAL_BLE_MAX_CONNECTIONS=1
CFLAGS += -DMYNEWT_VAL_MSYS_1_BLOCK_COUNT=55

Expand Down