Bluetooth: Mesh: Move testing.h to mesh subsys instead of include
The file is only ever used by mesh and it is even stated in the header of the file that it is internal APIs. The include file has been merged with the host testing.h file as that was mesh specific as well. Similarly the testing.c file was also moved This is part of a process to clean up the file structure of Bluetooth as it's a bit messy, which is evident from the MAINTAINERS.yml file. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
87c1e2a40f
commit
f1b182b585
12 changed files with 20 additions and 57 deletions
|
@ -130,3 +130,5 @@ zephyr_library_link_libraries_ifdef(CONFIG_MBEDTLS mbedTLS)
|
|||
zephyr_library_include_directories_ifdef(CONFIG_BUILD_WITH_TFM
|
||||
$<TARGET_PROPERTY:tfm,TFM_BINARY_DIR>/api_ns/interface/include
|
||||
)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_TESTING testing.c)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "common/bt_str.h"
|
||||
|
||||
#include "host/testing.h"
|
||||
#include "testing.h"
|
||||
|
||||
#include "mesh.h"
|
||||
#include "net.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "common/bt_str.h"
|
||||
|
||||
#include "host/testing.h"
|
||||
#include "testing.h"
|
||||
|
||||
#include "mesh.h"
|
||||
#include "net.h"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <zephyr/bluetooth/conn.h>
|
||||
#include <zephyr/bluetooth/mesh.h>
|
||||
#include <zephyr/net/buf.h>
|
||||
#include "host/testing.h"
|
||||
#include "testing.h"
|
||||
#include "net.h"
|
||||
#include "crypto.h"
|
||||
#include "beacon.h"
|
||||
|
|
131
subsys/bluetooth/mesh/testing.c
Normal file
131
subsys/bluetooth/mesh/testing.c
Normal file
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <stddef.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;
|
||||
|
||||
int bt_test_cb_register(struct bt_test_cb *cb)
|
||||
{
|
||||
if (sys_slist_find(&cb_slist, &cb->node, NULL)) {
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
sys_slist_append(&cb_slist, &cb->node);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_recv(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_model_recv) {
|
||||
cb->mesh_model_recv(src, dst, payload, payload_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bt_test_mesh_model_bound(uint16_t addr, const 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, const 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_MESH_LOW_POWER)
|
||||
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;
|
||||
}
|
||||
#endif /* CONFIG_BT_MESH_LOW_POWER */
|
||||
|
||||
int bt_test_mesh_rpl_clear(void)
|
||||
{
|
||||
bt_mesh_rpl_clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BT_MESH */
|
97
subsys/bluetooth/mesh/testing.h
Normal file
97
subsys/bluetooth/mesh/testing.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/**
|
||||
* @file testing.h
|
||||
* @brief Internal API for Bluetooth testing.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <zephyr/sys/slist.h>
|
||||
|
||||
#if defined(CONFIG_BT_MESH)
|
||||
#include <zephyr/bluetooth/mesh.h>
|
||||
#endif /* CONFIG_BT_MESH */
|
||||
|
||||
/** @brief Bluetooth Testing callbacks structure.
|
||||
*
|
||||
* Callback structure to be used for Bluetooth testing purposes.
|
||||
* Allows access to Bluetooth stack internals, not exposed by public API.
|
||||
*/
|
||||
struct bt_test_cb {
|
||||
#if defined(CONFIG_BT_MESH)
|
||||
void (*mesh_net_recv)(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst,
|
||||
const void *payload, size_t payload_len);
|
||||
void (*mesh_model_recv)(uint16_t src, uint16_t dst, const void *payload,
|
||||
size_t payload_len);
|
||||
void (*mesh_model_bound)(uint16_t addr, const struct bt_mesh_model *model,
|
||||
uint16_t key_idx);
|
||||
void (*mesh_model_unbound)(uint16_t addr, const struct bt_mesh_model *model,
|
||||
uint16_t key_idx);
|
||||
void (*mesh_prov_invalid_bearer)(uint8_t opcode);
|
||||
void (*mesh_trans_incomp_timer_exp)(void);
|
||||
#endif /* CONFIG_BT_MESH */
|
||||
|
||||
sys_snode_t node;
|
||||
};
|
||||
|
||||
/** Register callbacks for Bluetooth testing purposes
|
||||
*
|
||||
* @param cb bt_test_cb callback structure
|
||||
*
|
||||
* @retval 0 Success.
|
||||
* @retval -EEXIST if @p cb was already registered.
|
||||
*/
|
||||
int bt_test_cb_register(struct bt_test_cb *cb);
|
||||
|
||||
/** Unregister callbacks for Bluetooth testing purposes
|
||||
*
|
||||
* @param cb bt_test_cb callback structure
|
||||
*/
|
||||
void bt_test_cb_unregister(struct bt_test_cb *cb);
|
||||
|
||||
/** Send Friend Subscription List Add message.
|
||||
*
|
||||
* Used by Low Power node to send the group address for which messages are to
|
||||
* be stored by Friend node.
|
||||
*
|
||||
* @param group Group address
|
||||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*/
|
||||
int bt_test_mesh_lpn_group_add(uint16_t group);
|
||||
|
||||
/** Send Friend Subscription List Remove message.
|
||||
*
|
||||
* Used by Low Power node to remove the group addresses from Friend node
|
||||
* subscription list. Messages sent to those addresses will not be stored
|
||||
* by Friend node.
|
||||
*
|
||||
* @param groups Group addresses
|
||||
* @param groups_count Group addresses count
|
||||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*/
|
||||
int bt_test_mesh_lpn_group_remove(uint16_t *groups, size_t groups_count);
|
||||
|
||||
/** Clear replay protection list cache.
|
||||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*/
|
||||
int bt_test_mesh_rpl_clear(void);
|
||||
|
||||
#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);
|
||||
void bt_test_mesh_model_recv(uint16_t src, uint16_t dst, const void *payload,
|
||||
size_t payload_len);
|
||||
void bt_test_mesh_model_bound(uint16_t addr, const struct bt_mesh_model *model,
|
||||
uint16_t key_idx);
|
||||
void bt_test_mesh_model_unbound(uint16_t addr, const struct bt_mesh_model *model,
|
||||
uint16_t key_idx);
|
||||
void bt_test_mesh_prov_invalid_bearer(uint8_t opcode);
|
||||
void bt_test_mesh_trans_incomp_timer_exp(void);
|
||||
#endif /* CONFIG_BT_MESH */
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
#include "common/bt_str.h"
|
||||
|
||||
#include "host/testing.h"
|
||||
|
||||
#include "crypto.h"
|
||||
#include "mesh.h"
|
||||
#include "net.h"
|
||||
|
@ -33,6 +31,7 @@
|
|||
#include "sar_cfg_internal.h"
|
||||
#include "settings.h"
|
||||
#include "heartbeat.h"
|
||||
#include "testing.h"
|
||||
#include "transport.h"
|
||||
#include "va.h"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue