zephyr/subsys/bluetooth/host/testing.c
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00

114 lines
2.2 KiB
C

/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <stddef.h>
#include <zephyr/bluetooth/testing.h>
#if defined(CONFIG_BT_MESH)
#include "mesh/net.h"
#include "mesh/lpn.h"
#include "mesh/rpl.h"
#include "mesh/transport.h"
#endif /* CONFIG_BT_MESH */
#include "testing.h"
static sys_slist_t cb_slist;
void bt_test_cb_register(struct bt_test_cb *cb)
{
sys_slist_append(&cb_slist, &cb->node);
}
void bt_test_cb_unregister(struct bt_test_cb *cb)
{
sys_slist_find_and_remove(&cb_slist, &cb->node);
}
#if defined(CONFIG_BT_MESH)
void bt_test_mesh_net_recv(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst,
const void *payload, size_t payload_len)
{
struct bt_test_cb *cb;
SYS_SLIST_FOR_EACH_CONTAINER(&cb_slist, cb, node) {
if (cb->mesh_net_recv) {
cb->mesh_net_recv(ttl, ctl, src, dst, payload,
payload_len);
}
}
}
void bt_test_mesh_model_bound(uint16_t addr, struct bt_mesh_model *model,
uint16_t key_idx)
{
struct bt_test_cb *cb;
SYS_SLIST_FOR_EACH_CONTAINER(&cb_slist, cb, node) {
if (cb->mesh_model_bound) {
cb->mesh_model_bound(addr, model, key_idx);
}
}
}
void bt_test_mesh_model_unbound(uint16_t addr, struct bt_mesh_model *model,
uint16_t key_idx)
{
struct bt_test_cb *cb;
SYS_SLIST_FOR_EACH_CONTAINER(&cb_slist, cb, node) {
if (cb->mesh_model_unbound) {
cb->mesh_model_unbound(addr, model, key_idx);
}
}
}
void bt_test_mesh_prov_invalid_bearer(uint8_t opcode)
{
struct bt_test_cb *cb;
SYS_SLIST_FOR_EACH_CONTAINER(&cb_slist, cb, node) {
if (cb->mesh_prov_invalid_bearer) {
cb->mesh_prov_invalid_bearer(opcode);
}
}
}
void bt_test_mesh_trans_incomp_timer_exp(void)
{
struct bt_test_cb *cb;
SYS_SLIST_FOR_EACH_CONTAINER(&cb_slist, cb, node) {
if (cb->mesh_trans_incomp_timer_exp) {
cb->mesh_trans_incomp_timer_exp();
}
}
}
int bt_test_mesh_lpn_group_add(uint16_t group)
{
bt_mesh_lpn_group_add(group);
return 0;
}
int bt_test_mesh_lpn_group_remove(uint16_t *groups, size_t groups_count)
{
bt_mesh_lpn_group_del(groups, groups_count);
return 0;
}
int bt_test_mesh_rpl_clear(void)
{
bt_mesh_rpl_clear();
return 0;
}
#endif /* CONFIG_BT_MESH */