Bluetooth: Mesh: Rename mesh test primitives
Since testing.c/h was moved to mesh, all functions and structs in those files now follow a bt_mesh_test_* naming scheme to be consistent with the naming in Zephyr. Due to missing includes in many files, this commit also added some that were missing in order to build since the order of includes have changed. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
f1b182b585
commit
3e9197a58a
10 changed files with 96 additions and 95 deletions
|
@ -1530,8 +1530,7 @@ int bt_mesh_model_recv(struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
|
|||
LOG_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TESTING)) {
|
||||
bt_test_mesh_model_recv(ctx->addr, ctx->recv_dst, buf->data,
|
||||
buf->len);
|
||||
bt_mesh_test_model_recv(ctx->addr, ctx->recv_dst, buf->data, buf->len);
|
||||
}
|
||||
|
||||
if (get_opcode(buf, &opcode) < 0) {
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/sys/util_macro.h>
|
||||
#include <zephyr/sys_clock.h>
|
||||
|
||||
#ifndef ZEPHYR_SUBSYS_BLUETOOTH_MESH_ADV_H_
|
||||
#define ZEPHYR_SUBSYS_BLUETOOTH_MESH_ADV_H_
|
||||
|
||||
|
|
|
@ -1889,7 +1889,7 @@ static int mod_app_bind(const struct bt_mesh_model *model,
|
|||
status = mod_bind(mod, key_app_idx);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TESTING) && status == STATUS_SUCCESS) {
|
||||
bt_test_mesh_model_bound(ctx->addr, mod, key_app_idx);
|
||||
bt_mesh_test_model_bound(ctx->addr, mod, key_app_idx);
|
||||
}
|
||||
|
||||
send_status:
|
||||
|
@ -1946,7 +1946,7 @@ static int mod_app_unbind(const struct bt_mesh_model *model,
|
|||
status = mod_unbind(mod, key_app_idx, true);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TESTING) && status == STATUS_SUCCESS) {
|
||||
bt_test_mesh_model_unbound(ctx->addr, mod, key_app_idx);
|
||||
bt_mesh_test_model_unbound(ctx->addr, mod, key_app_idx);
|
||||
}
|
||||
|
||||
send_status:
|
||||
|
|
|
@ -4,9 +4,16 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "adv.h"
|
||||
#include "subnet.h"
|
||||
#include <zephyr/bluetooth/mesh/keys.h>
|
||||
#include <zephyr/bluetooth/mesh/sar_cfg.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/net/buf.h>
|
||||
#include <zephyr/sys/atomic.h>
|
||||
#include <zephyr/sys/slist.h>
|
||||
|
||||
#define BT_MESH_IV_UPDATE(flags) ((flags >> 1) & 0x01)
|
||||
#define BT_MESH_KEY_REFRESH(flags) (flags & 0x01)
|
||||
|
|
|
@ -683,7 +683,7 @@ static void gen_prov_ctl(struct prov_rx *rx, struct net_buf_simple *buf)
|
|||
LOG_ERR("Unknown bearer opcode: 0x%02x", BEARER_CTL(rx->gpc));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TESTING)) {
|
||||
bt_test_mesh_prov_invalid_bearer(BEARER_CTL(rx->gpc));
|
||||
bt_mesh_test_prov_invalid_bearer(BEARER_CTL(rx->gpc));
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <zephyr/bluetooth/mesh/keys.h>
|
||||
#include <zephyr/net/buf.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/sys/iterable_sections.h>
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
* Copyright (c) 2024 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.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 <zephyr/bluetooth/mesh/access.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/sys/slist.h>
|
||||
|
||||
#include "net.h"
|
||||
#include "lpn.h"
|
||||
#include "rpl.h"
|
||||
#include "testing.h"
|
||||
#include "transport.h"
|
||||
|
||||
static sys_slist_t cb_slist;
|
||||
|
||||
int bt_test_cb_register(struct bt_test_cb *cb)
|
||||
int bt_mesh_test_cb_register(struct bt_mesh_test_cb *cb)
|
||||
{
|
||||
if (sys_slist_find(&cb_slist, &cb->node, NULL)) {
|
||||
return -EEXIST;
|
||||
|
@ -29,92 +32,87 @@ int bt_test_cb_register(struct bt_test_cb *cb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void bt_test_cb_unregister(struct bt_test_cb *cb)
|
||||
void bt_mesh_test_cb_unregister(struct bt_mesh_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,
|
||||
void bt_mesh_test_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;
|
||||
struct bt_mesh_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);
|
||||
if (cb->net_recv) {
|
||||
cb->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)
|
||||
void bt_mesh_test_model_recv(uint16_t src, uint16_t dst, const void *payload, size_t payload_len)
|
||||
{
|
||||
struct bt_test_cb *cb;
|
||||
struct bt_mesh_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);
|
||||
if (cb->model_recv) {
|
||||
cb->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)
|
||||
void bt_mesh_test_model_bound(uint16_t addr, const struct bt_mesh_model *model, uint16_t key_idx)
|
||||
{
|
||||
struct bt_test_cb *cb;
|
||||
struct bt_mesh_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);
|
||||
if (cb->model_bound) {
|
||||
cb->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)
|
||||
void bt_mesh_test_model_unbound(uint16_t addr, const struct bt_mesh_model *model, uint16_t key_idx)
|
||||
{
|
||||
struct bt_test_cb *cb;
|
||||
struct bt_mesh_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);
|
||||
if (cb->model_unbound) {
|
||||
cb->model_unbound(addr, model, key_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bt_test_mesh_prov_invalid_bearer(uint8_t opcode)
|
||||
void bt_mesh_test_prov_invalid_bearer(uint8_t opcode)
|
||||
{
|
||||
struct bt_test_cb *cb;
|
||||
struct bt_mesh_test_cb *cb;
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&cb_slist, cb, node) {
|
||||
if (cb->mesh_prov_invalid_bearer) {
|
||||
cb->mesh_prov_invalid_bearer(opcode);
|
||||
if (cb->prov_invalid_bearer) {
|
||||
cb->prov_invalid_bearer(opcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bt_test_mesh_trans_incomp_timer_exp(void)
|
||||
void bt_mesh_test_trans_incomp_timer_exp(void)
|
||||
{
|
||||
struct bt_test_cb *cb;
|
||||
struct bt_mesh_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 (cb->trans_incomp_timer_exp) {
|
||||
cb->trans_incomp_timer_exp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_MESH_LOW_POWER)
|
||||
int bt_test_mesh_lpn_group_add(uint16_t group)
|
||||
int bt_mesh_test_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)
|
||||
int bt_mesh_test_lpn_group_remove(uint16_t *groups, size_t groups_count)
|
||||
{
|
||||
bt_mesh_lpn_group_del(groups, groups_count);
|
||||
|
||||
|
@ -122,10 +120,9 @@ int bt_test_mesh_lpn_group_remove(uint16_t *groups, size_t groups_count)
|
|||
}
|
||||
#endif /* CONFIG_BT_MESH_LOW_POWER */
|
||||
|
||||
int bt_test_mesh_rpl_clear(void)
|
||||
int bt_mesh_test_rpl_clear(void)
|
||||
{
|
||||
bt_mesh_rpl_clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BT_MESH */
|
||||
|
|
|
@ -5,53 +5,48 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
* Copyright (c) 2024 Nordic Semiconductor ASA
|
||||
*
|
||||
* 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 */
|
||||
#include <zephyr/bluetooth/mesh/access.h>
|
||||
#include <zephyr/sys/slist.h>
|
||||
|
||||
/** @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 */
|
||||
struct bt_mesh_test_cb {
|
||||
void (*net_recv)(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst, const void *payload,
|
||||
size_t payload_len);
|
||||
void (*model_recv)(uint16_t src, uint16_t dst, const void *payload, size_t payload_len);
|
||||
void (*model_bound)(uint16_t addr, const struct bt_mesh_model *model, uint16_t key_idx);
|
||||
void (*model_unbound)(uint16_t addr, const struct bt_mesh_model *model, uint16_t key_idx);
|
||||
void (*prov_invalid_bearer)(uint8_t opcode);
|
||||
void (*trans_incomp_timer_exp)(void);
|
||||
|
||||
sys_snode_t node;
|
||||
};
|
||||
|
||||
/** Register callbacks for Bluetooth testing purposes
|
||||
*
|
||||
* @param cb bt_test_cb callback structure
|
||||
* @param cb bt_mesh_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);
|
||||
int bt_mesh_test_cb_register(struct bt_mesh_test_cb *cb);
|
||||
|
||||
/** Unregister callbacks for Bluetooth testing purposes
|
||||
*
|
||||
* @param cb bt_test_cb callback structure
|
||||
* @param cb bt_mesh_test_cb callback structure
|
||||
*/
|
||||
void bt_test_cb_unregister(struct bt_test_cb *cb);
|
||||
void bt_mesh_test_cb_unregister(struct bt_mesh_test_cb *cb);
|
||||
|
||||
/** Send Friend Subscription List Add message.
|
||||
*
|
||||
|
@ -62,7 +57,7 @@ void bt_test_cb_unregister(struct bt_test_cb *cb);
|
|||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*/
|
||||
int bt_test_mesh_lpn_group_add(uint16_t group);
|
||||
int bt_mesh_test_lpn_group_add(uint16_t group);
|
||||
|
||||
/** Send Friend Subscription List Remove message.
|
||||
*
|
||||
|
@ -75,23 +70,18 @@ int bt_test_mesh_lpn_group_add(uint16_t group);
|
|||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*/
|
||||
int bt_test_mesh_lpn_group_remove(uint16_t *groups, size_t groups_count);
|
||||
int bt_mesh_test_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);
|
||||
int bt_mesh_test_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,
|
||||
void bt_mesh_test_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 */
|
||||
void bt_mesh_test_model_recv(uint16_t src, uint16_t dst, const void *payload, size_t payload_len);
|
||||
void bt_mesh_test_model_bound(uint16_t addr, const struct bt_mesh_model *model, uint16_t key_idx);
|
||||
void bt_mesh_test_model_unbound(uint16_t addr, const struct bt_mesh_model *model, uint16_t key_idx);
|
||||
void bt_mesh_test_prov_invalid_bearer(uint8_t opcode);
|
||||
void bt_mesh_test_trans_incomp_timer_exp(void);
|
||||
|
|
|
@ -1192,7 +1192,7 @@ static void seg_discard(struct k_work *work)
|
|||
rx->block = 0U;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TESTING)) {
|
||||
bt_test_mesh_trans_incomp_timer_exp();
|
||||
bt_mesh_test_trans_incomp_timer_exp();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1635,8 +1635,8 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx)
|
|||
LOG_DBG("Payload %s", bt_hex(buf->data, buf->len));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TESTING)) {
|
||||
bt_test_mesh_net_recv(rx->ctx.recv_ttl, rx->ctl, rx->ctx.addr,
|
||||
rx->ctx.recv_dst, buf->data, buf->len);
|
||||
bt_mesh_test_net_recv(rx->ctx.recv_ttl, rx->ctl, rx->ctx.addr, rx->ctx.recv_dst,
|
||||
buf->data, buf->len);
|
||||
}
|
||||
|
||||
/* If LPN mode is enabled messages are only accepted when we've
|
||||
|
|
|
@ -1829,7 +1829,7 @@ static uint8_t lpn_subscribe(const void *cmd, uint16_t cmd_len,
|
|||
|
||||
LOG_DBG("address 0x%04x", address);
|
||||
|
||||
err = bt_test_mesh_lpn_group_add(address);
|
||||
err = bt_mesh_test_lpn_group_add(address);
|
||||
if (err) {
|
||||
LOG_ERR("Failed to subscribe (err %d)", err);
|
||||
return BTP_STATUS_FAILED;
|
||||
|
@ -1847,7 +1847,7 @@ static uint8_t lpn_unsubscribe(const void *cmd, uint16_t cmd_len,
|
|||
|
||||
LOG_DBG("address 0x%04x", address);
|
||||
|
||||
err = bt_test_mesh_lpn_group_remove(&address, 1);
|
||||
err = bt_mesh_test_lpn_group_remove(&address, 1);
|
||||
if (err) {
|
||||
LOG_ERR("Failed to unsubscribe (err %d)", err);
|
||||
return BTP_STATUS_FAILED;
|
||||
|
@ -1864,7 +1864,7 @@ static uint8_t rpl_clear(const void *cmd, uint16_t cmd_len,
|
|||
|
||||
LOG_DBG("");
|
||||
|
||||
err = bt_test_mesh_rpl_clear();
|
||||
err = bt_mesh_test_rpl_clear();
|
||||
if (err) {
|
||||
LOG_ERR("Failed to clear RPL (err %d)", err);
|
||||
return BTP_STATUS_FAILED;
|
||||
|
@ -5338,13 +5338,13 @@ static void incomp_timer_exp_cb(void)
|
|||
tester_event(BTP_SERVICE_ID_MESH, BTP_MESH_EV_INCOMP_TIMER_EXP, NULL, 0);
|
||||
}
|
||||
|
||||
static struct bt_test_cb bt_test_cb = {
|
||||
.mesh_net_recv = net_recv_ev,
|
||||
.mesh_model_recv = model_recv_ev,
|
||||
.mesh_model_bound = model_bound_cb,
|
||||
.mesh_model_unbound = model_unbound_cb,
|
||||
.mesh_prov_invalid_bearer = invalid_bearer_cb,
|
||||
.mesh_trans_incomp_timer_exp = incomp_timer_exp_cb,
|
||||
static struct bt_mesh_test_cb bt_mesh_test_cb = {
|
||||
.net_recv = net_recv_ev,
|
||||
.model_recv = model_recv_ev,
|
||||
.model_bound = model_bound_cb,
|
||||
.model_unbound = model_unbound_cb,
|
||||
.prov_invalid_bearer = invalid_bearer_cb,
|
||||
.trans_incomp_timer_exp = incomp_timer_exp_cb,
|
||||
};
|
||||
|
||||
static void friend_established(uint16_t net_idx, uint16_t lpn_addr,
|
||||
|
@ -5417,7 +5417,7 @@ BT_MESH_LPN_CB_DEFINE(lpn_cb) = {
|
|||
uint8_t tester_init_mesh(void)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_BT_TESTING)) {
|
||||
bt_test_cb_register(&bt_test_cb);
|
||||
bt_mesh_test_cb_register(&bt_mesh_test_cb);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_MESH_COMP_PAGE_2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue