From 88f9cf780a4d9bc2837f07ecebc4487149298ada Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Tue, 26 Mar 2019 09:27:41 +0100 Subject: [PATCH 1/3] ble/nimble: bump version to 9d4bda2 --- pkg/nimble/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/nimble/Makefile b/pkg/nimble/Makefile index 475a5fff5b53..f10cbb524c4e 100644 --- a/pkg/nimble/Makefile +++ b/pkg/nimble/Makefile @@ -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) From 5bd53db88fbc16be93587a48de5ab0f375602438 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Mon, 29 Apr 2019 16:15:23 +0200 Subject: [PATCH 2/3] tests/l2cap: use newly introduced TX_UNSTALLED evt --- tests/nimble_l2cap/main.c | 15 ++++++++++++--- tests/nimble_l2cap_server/main.c | 5 ++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/nimble_l2cap/main.c b/tests/nimble_l2cap/main.c index 9671fe027b99..3ea1b567e05c 100644 --- a/tests/nimble_l2cap/main.c +++ b/tests/nimble_l2cap/main.c @@ -29,6 +29,8 @@ #include "assert.h" #include "shell.h" +#include "thread.h" +#include "thread_flags.h" #include "net/bluetil/ad.h" #include "nimble_l2cap_test_conf.h" @@ -36,8 +38,9 @@ #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; @@ -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 */ @@ -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); } diff --git a/tests/nimble_l2cap_server/main.c b/tests/nimble_l2cap_server/main.c index d15e4c4f89b7..3903c6407c98 100644 --- a/tests/nimble_l2cap_server/main.c +++ b/tests/nimble_l2cap_server/main.c @@ -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); @@ -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; From e172c80bad569af58621373e61c92d9b96c14d4f Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Mon, 29 Apr 2019 16:15:55 +0200 Subject: [PATCH 3/3] tests/nimble_l2cap: adapt to config var name change --- tests/nimble_l2cap_server/nimble.inc.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/nimble_l2cap_server/nimble.inc.mk b/tests/nimble_l2cap_server/nimble.inc.mk index 7389897331f7..a4db5febfac8 100644 --- a/tests/nimble_l2cap_server/nimble.inc.mk +++ b/tests/nimble_l2cap_server/nimble.inc.mk @@ -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