The purpose of this test is to prove that the zephyr host can handle the behavior described in the Bluetooth Core Specification Vol.3 Part.F 3.3.2 "Sequential protocol". The host should be able to handle all of those in parallel: one indication, one write request, multiple commands and multiple notifications. The "tester" part had to be written with a "tiny host" implementation instead of the Zephyr host, as the ZH conflates GATT client and server and doesn't allow a device to enqueue an ATT request + an ATT indication on the same bearer. Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
60 lines
3.0 KiB
C
60 lines
3.0 KiB
C
/*
|
|
* Copyright (c) 2023 Nordic Semiconductor ASA
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "bs_tracing.h"
|
|
#include "bs_types.h"
|
|
#include "bstests.h"
|
|
|
|
#define BS_SECONDS(dur_sec) ((bs_time_t)dur_sec * USEC_PER_SEC)
|
|
#define TEST_TIMEOUT_SIMULATED BS_SECONDS(10)
|
|
|
|
extern enum bst_result_t bst_result;
|
|
|
|
#define DECLARE_FLAG(flag) extern atomic_t flag
|
|
#define DEFINE_FLAG(flag) atomic_t flag = (atomic_t) false
|
|
#define SET_FLAG(flag) (void)atomic_set(&flag, (atomic_t) true)
|
|
#define UNSET_FLAG(flag) (void)atomic_set(&flag, (atomic_t) false)
|
|
|
|
#define WAIT_FOR_VAL(var, val) \
|
|
while (atomic_get(&var) != val) { \
|
|
(void)k_sleep(K_MSEC(1)); \
|
|
}
|
|
#define WAIT_FOR_FLAG(flag) \
|
|
while (!(bool)atomic_get(&flag)) { \
|
|
(void)k_sleep(K_MSEC(1)); \
|
|
}
|
|
#define WAIT_FOR_FLAG_UNSET(flag) \
|
|
while ((bool)atomic_get(&flag)) { \
|
|
(void)k_sleep(K_MSEC(1)); \
|
|
}
|
|
#define TAKE_FLAG(flag) \
|
|
while (!(bool)atomic_cas(&flag, true, false)) { \
|
|
(void)k_sleep(K_MSEC(1)); \
|
|
}
|
|
|
|
#define ASSERT(expr, ...) \
|
|
do { \
|
|
if (!(expr)) { \
|
|
FAIL(__VA_ARGS__); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define FAIL(...) \
|
|
do { \
|
|
bst_result = Failed; \
|
|
bs_trace_error_time_line(__VA_ARGS__); \
|
|
} while (0)
|
|
|
|
#define PASS(...) \
|
|
do { \
|
|
bst_result = Passed; \
|
|
bs_trace_info_time(1, __VA_ARGS__); \
|
|
} while (0)
|
|
|
|
#define HVX_HANDLE 0x0012
|
|
#define INDICATION_PAYLOAD "indication"
|
|
#define NOTIFICATION_PAYLOAD "notification"
|