1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/l2cap: use newly introduced TX_UNSTALLED evt

This commit is contained in:
Hauke Petersen 2019-04-29 16:15:23 +02:00
parent 88f9cf780a
commit 5bd53db88f
2 changed files with 16 additions and 4 deletions

View File

@ -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);
}

View File

@ -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;