1 /** 2 * @file testing.h 3 * @brief Internal API for Bluetooth testing. 4 */ 5 6 /* 7 * Copyright (c) 2017 Intel Corporation 8 * 9 * SPDX-License-Identifier: Apache-2.0 10 */ 11 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ 12 #define ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ 13 14 #include <stdint.h> 15 16 #if defined(CONFIG_BT_MESH) 17 #include <zephyr/bluetooth/mesh.h> 18 #endif /* CONFIG_BT_MESH */ 19 20 /** 21 * @brief Bluetooth testing 22 * @defgroup bt_test_cb Bluetooth testing callbacks 23 * @ingroup bluetooth 24 * @{ 25 */ 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /** @brief Bluetooth Testing callbacks structure. 32 * 33 * Callback structure to be used for Bluetooth testing purposes. 34 * Allows access to Bluetooth stack internals, not exposed by public API. 35 */ 36 struct bt_test_cb { 37 #if defined(CONFIG_BT_MESH) 38 void (*mesh_net_recv)(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst, 39 const void *payload, size_t payload_len); 40 void (*mesh_model_recv)(uint16_t src, uint16_t dst, const void *payload, 41 size_t payload_len); 42 void (*mesh_model_bound)(uint16_t addr, const struct bt_mesh_model *model, 43 uint16_t key_idx); 44 void (*mesh_model_unbound)(uint16_t addr, const struct bt_mesh_model *model, 45 uint16_t key_idx); 46 void (*mesh_prov_invalid_bearer)(uint8_t opcode); 47 void (*mesh_trans_incomp_timer_exp)(void); 48 #endif /* CONFIG_BT_MESH */ 49 50 sys_snode_t node; 51 }; 52 53 /** Register callbacks for Bluetooth testing purposes 54 * 55 * @param cb bt_test_cb callback structure 56 * 57 * @retval 0 Success. 58 * @retval -EEXIST if @p cb was already registered. 59 */ 60 int bt_test_cb_register(struct bt_test_cb *cb); 61 62 /** Unregister callbacks for Bluetooth testing purposes 63 * 64 * @param cb bt_test_cb callback structure 65 */ 66 void bt_test_cb_unregister(struct bt_test_cb *cb); 67 68 /** Send Friend Subscription List Add message. 69 * 70 * Used by Low Power node to send the group address for which messages are to 71 * be stored by Friend node. 72 * 73 * @param group Group address 74 * 75 * @return Zero on success or (negative) error code otherwise. 76 */ 77 int bt_test_mesh_lpn_group_add(uint16_t group); 78 79 /** Send Friend Subscription List Remove message. 80 * 81 * Used by Low Power node to remove the group addresses from Friend node 82 * subscription list. Messages sent to those addresses will not be stored 83 * by Friend node. 84 * 85 * @param groups Group addresses 86 * @param groups_count Group addresses count 87 * 88 * @return Zero on success or (negative) error code otherwise. 89 */ 90 int bt_test_mesh_lpn_group_remove(uint16_t *groups, size_t groups_count); 91 92 /** Clear replay protection list cache. 93 * 94 * @return Zero on success or (negative) error code otherwise. 95 */ 96 int bt_test_mesh_rpl_clear(void); 97 98 /** 99 * @} 100 */ 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ */ 107