From f1b182b5856434c55fb688919bf163d274e8a8ac Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Fri, 23 Aug 2024 12:34:08 +0200 Subject: [PATCH] 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 --- MAINTAINERS.yml | 2 -- subsys/bluetooth/host/CMakeLists.txt | 1 - subsys/bluetooth/host/testing.h | 23 ------------ subsys/bluetooth/mesh/CMakeLists.txt | 2 ++ subsys/bluetooth/mesh/access.c | 2 +- subsys/bluetooth/mesh/cfg_srv.c | 2 +- subsys/bluetooth/mesh/pb_adv.c | 2 +- subsys/bluetooth/{host => mesh}/testing.c | 2 -- .../bluetooth/mesh}/testing.h | 35 +++++++------------ subsys/bluetooth/mesh/transport.c | 3 +- tests/bluetooth/tester/src/audio/btp_vcp.c | 1 - tests/bluetooth/tester/src/btp_mesh.c | 2 +- 12 files changed, 20 insertions(+), 57 deletions(-) delete mode 100644 subsys/bluetooth/host/testing.h rename subsys/bluetooth/{host => mesh}/testing.c (98%) rename {include/zephyr/bluetooth => subsys/bluetooth/mesh}/testing.h (79%) diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index a3780ed8ae7..0e168504467 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -391,7 +391,6 @@ Bluetooth Host: - include/zephyr/bluetooth/iso.h - include/zephyr/bluetooth/controller.h - include/zephyr/bluetooth/mesh.h - - include/zephyr/bluetooth/testing.h - doc/connectivity/bluetooth/bluetooth-ctlr-arch.rst - doc/connectivity/bluetooth/autopts/ - doc/connectivity/bluetooth/img/ctlr* @@ -449,7 +448,6 @@ Bluetooth Mesh: - doc/connectivity/bluetooth/api/mesh/ - include/zephyr/bluetooth/mesh/ - include/zephyr/bluetooth/mesh.h - - include/zephyr/bluetooth/testing.h - samples/bluetooth/mesh*/ - subsys/bluetooth/mesh/ - tests/bluetooth/mesh*/ diff --git a/subsys/bluetooth/host/CMakeLists.txt b/subsys/bluetooth/host/CMakeLists.txt index ae574e2b5bf..1b1b6a58543 100644 --- a/subsys/bluetooth/host/CMakeLists.txt +++ b/subsys/bluetooth/host/CMakeLists.txt @@ -8,7 +8,6 @@ add_subdirectory_ifdef(CONFIG_BT_CLASSIC classic) zephyr_library_sources_ifdef(CONFIG_BT_HCI_RAW hci_raw.c hci_common.c) zephyr_library_sources_ifdef(CONFIG_BT_MONITOR monitor.c) zephyr_library_sources_ifdef(CONFIG_BT_TINYCRYPT_ECC hci_ecc.c) -zephyr_library_sources_ifdef(CONFIG_BT_TESTING testing.c) zephyr_library_sources_ifdef(CONFIG_BT_SETTINGS settings.c) zephyr_library_sources_ifdef(CONFIG_BT_HOST_CCM aes_ccm.c) zephyr_library_sources_ifdef(CONFIG_BT_LONG_WQ long_wq.c) diff --git a/subsys/bluetooth/host/testing.h b/subsys/bluetooth/host/testing.h deleted file mode 100644 index 8ed1fa61e46..00000000000 --- a/subsys/bluetooth/host/testing.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @file testing.h - * @brief Internal API for Bluetooth testing. - */ - -/* - * Copyright (c) 2017 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#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 */ diff --git a/subsys/bluetooth/mesh/CMakeLists.txt b/subsys/bluetooth/mesh/CMakeLists.txt index 2009601f0f8..ac69a9234d8 100644 --- a/subsys/bluetooth/mesh/CMakeLists.txt +++ b/subsys/bluetooth/mesh/CMakeLists.txt @@ -130,3 +130,5 @@ zephyr_library_link_libraries_ifdef(CONFIG_MBEDTLS mbedTLS) zephyr_library_include_directories_ifdef(CONFIG_BUILD_WITH_TFM $/api_ns/interface/include ) + +zephyr_library_sources_ifdef(CONFIG_BT_TESTING testing.c) diff --git a/subsys/bluetooth/mesh/access.c b/subsys/bluetooth/mesh/access.c index e095d9babdb..a9e8d918de7 100644 --- a/subsys/bluetooth/mesh/access.c +++ b/subsys/bluetooth/mesh/access.c @@ -16,7 +16,7 @@ #include "common/bt_str.h" -#include "host/testing.h" +#include "testing.h" #include "mesh.h" #include "net.h" diff --git a/subsys/bluetooth/mesh/cfg_srv.c b/subsys/bluetooth/mesh/cfg_srv.c index 268f883d8b8..36d912f37a5 100644 --- a/subsys/bluetooth/mesh/cfg_srv.c +++ b/subsys/bluetooth/mesh/cfg_srv.c @@ -18,7 +18,7 @@ #include "common/bt_str.h" -#include "host/testing.h" +#include "testing.h" #include "mesh.h" #include "net.h" diff --git a/subsys/bluetooth/mesh/pb_adv.c b/subsys/bluetooth/mesh/pb_adv.c index e5946e739d6..be5a88c56be 100644 --- a/subsys/bluetooth/mesh/pb_adv.c +++ b/subsys/bluetooth/mesh/pb_adv.c @@ -9,7 +9,7 @@ #include #include #include -#include "host/testing.h" +#include "testing.h" #include "net.h" #include "crypto.h" #include "beacon.h" diff --git a/subsys/bluetooth/host/testing.c b/subsys/bluetooth/mesh/testing.c similarity index 98% rename from subsys/bluetooth/host/testing.c rename to subsys/bluetooth/mesh/testing.c index 16fb15b94e6..75c0964e792 100644 --- a/subsys/bluetooth/host/testing.c +++ b/subsys/bluetooth/mesh/testing.c @@ -7,8 +7,6 @@ #include #include -#include - #if defined(CONFIG_BT_MESH) #include "mesh/net.h" #include "mesh/lpn.h" diff --git a/include/zephyr/bluetooth/testing.h b/subsys/bluetooth/mesh/testing.h similarity index 79% rename from include/zephyr/bluetooth/testing.h rename to subsys/bluetooth/mesh/testing.h index 74806a53a6d..95937184815 100644 --- a/include/zephyr/bluetooth/testing.h +++ b/subsys/bluetooth/mesh/testing.h @@ -8,26 +8,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#ifndef ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ -#define ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ #include +#include #if defined(CONFIG_BT_MESH) #include #endif /* CONFIG_BT_MESH */ -/** - * @brief Bluetooth testing - * @defgroup bt_test_cb Bluetooth testing callbacks - * @ingroup bluetooth - * @{ - */ - -#ifdef __cplusplus -extern "C" { -#endif - /** @brief Bluetooth Testing callbacks structure. * * Callback structure to be used for Bluetooth testing purposes. @@ -95,12 +83,15 @@ int bt_test_mesh_lpn_group_remove(uint16_t *groups, size_t groups_count); */ int bt_test_mesh_rpl_clear(void); -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ */ +#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 */ diff --git a/subsys/bluetooth/mesh/transport.c b/subsys/bluetooth/mesh/transport.c index 66678911f1b..c95fa81f9f6 100644 --- a/subsys/bluetooth/mesh/transport.c +++ b/subsys/bluetooth/mesh/transport.c @@ -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" diff --git a/tests/bluetooth/tester/src/audio/btp_vcp.c b/tests/bluetooth/tester/src/audio/btp_vcp.c index d4561065214..db53f0d27d5 100644 --- a/tests/bluetooth/tester/src/audio/btp_vcp.c +++ b/tests/bluetooth/tester/src/audio/btp_vcp.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/bluetooth/tester/src/btp_mesh.c b/tests/bluetooth/tester/src/btp_mesh.c index 6e6416c8a40..ca8efc4e3fa 100644 --- a/tests/bluetooth/tester/src/btp_mesh.c +++ b/tests/bluetooth/tester/src/btp_mesh.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -18,6 +17,7 @@ #include #include #include "mesh/access.h" +#include "mesh/testing.h" #include #define LOG_MODULE_NAME bttester_mesh