Merge branch 'feature/ble_mesh_add_bqb_log_test_macro' into 'master'

ble_mesh: stack: Add macros for BQB test to enable some internal function or log

See merge request espressif/esp-idf!22540
This commit is contained in:
Island 2023-03-20 11:43:53 +08:00
commit b5549cb373
3 changed files with 113 additions and 0 deletions

View File

@ -1132,6 +1132,19 @@ if BLE_MESH
This option adds extra self-tests which are run every time BLE Mesh
networking is initialized.
config BLE_MESH_BQB_TEST
bool
default n
help
This option is used to enable some internal functions for auto-pts test.
config BLE_MESH_BQB_TEST_LOG
bool
depends on BLE_MESH_BQB_TEST
default y
help
This option is used to enable the log of auto-pts test.
if BLE_MESH_SELF_TEST
config BLE_MESH_TEST_AUTO_ENTER_NETWORK

View File

@ -120,6 +120,52 @@ extern "C" {
#define NET_BUF_SIMPLE_ASSERT(cond)
#endif
#if CONFIG_BLE_MESH_BQB_TEST_LOG
/**
* For example, the test case "MESH/NODE/TNPT/BV-01-C"
* could use BT_BQB(BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_NODE | BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_TNPT, "msg %s", msg)
* to print some message.
*/
enum BLE_MESH_BQB_TEST_LOG_LEVEL {
BLE_MESH_BQB_TEST_LOG_LEVEL_OUTPUT_ALL = 0, /* Output all BQB related test log */
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_NODE = BIT(0),
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_PVNR = BIT(1),
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_CFGCL = BIT(2),
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_SR = BIT(3),
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_CL = BIT(4),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_PBADV = BIT(5),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_MPS = BIT(6),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_PROV = BIT(7),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_BCN = BIT(8),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_NET = BIT(9),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_RLY = BIT(10),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_TNPT = BIT(11),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_IVU = BIT(12),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_KR = BIT(13),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_FRND_FN = BIT(14),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_FRND_LPN = BIT(15),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_PROX = BIT(16),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_MPXS = BIT(17),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_CFG = BIT(18),
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_HM = BIT(19),
};
#define BLE_MESH_BQB_TEST_LOG_LEVEL_OUTPUT_NONE 0x000FFFFF
#endif /* CONFIG_BLE_MESH_BQB_TEST_LOG */
#if (CONFIG_BLE_MESH_BQB_TEST_LOG && !CONFIG_BLE_MESH_NO_LOG)
extern bool bt_mesh_bqb_test_flag_check(uint32_t flag_mask);
extern int bt_mesh_bqb_test_flag_set(uint32_t value);
#define BT_BQB(flag_mask, fmt, args...) \
do { \
if (bt_mesh_bqb_test_flag_check(flag_mask)) \
BLE_MESH_PRINT_I("BLE_MESH_BQB", fmt, ## args); \
} while (0)
#else
#define BT_BQB(flag_mask, fmt, args...)
#endif
#ifdef __cplusplus
}
#endif

View File

@ -7,9 +7,11 @@
*/
#include <string.h>
#include <errno.h>
#include "mesh_types.h"
#include "mesh_util.h"
#include "mesh_trace.h"
const char *bt_hex(const void *buf, size_t len)
{
@ -42,3 +44,55 @@ void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len)
*dst++ = *--src;
}
}
#ifdef CONFIG_BLE_MESH_BQB_TEST_LOG
enum BLE_MESH_BQB_TEST_FLAG_OP {
BLE_MESH_BQB_TEST_FLAG_OP_GET = 0,
BLE_MESH_BQB_TEST_FLAG_OP_SET,
};
static uint32_t bt_mesh_bqb_test_flag(uint8_t op, uint32_t value)
{
static uint32_t bqb_log_flag = 0;
switch (operation) {
case BLE_MESH_BQB_TEST_FLAG_OP_GET:
break;
case BLE_MESH_BQB_TEST_FLAG_OP_SET:
bqb_log_flag = value;
break;
default:
BT_ERR("Unknown BQB test flag opcode 0x%02x", op);
break;
}
return bqb_log_flag;
}
uint32_t bt_mesh_bqb_test_flag_get(void)
{
return bt_mesh_bqb_test_flag(BLE_MESH_BQB_TEST_FLAG_OP_GET, 0);
}
int bt_mesh_bqb_test_flag_set(uint32_t flag_mask)
{
if (module_mask > BLE_MESH_BQB_TEST_LOG_LEVEL_OUTPUT_NONE) {
BT_ERR("Invalid BQB test flag mask 0x%08x", flag_mask);
return -EINVAL;
}
return (bt_mesh_bqb_test_flag(BLE_MESH_BQB_TEST_FLAG_OP_SET, flag_mask) == flag_mask) ? 0 : -EINVAL;
}
bool bt_mesh_bqb_test_flag_check(uint32_t flag_mask)
{
if (module_mask > BLE_MESH_BQB_TEST_LOG_LEVEL_OUTPUT_NONE) {
BT_ERR("Invalid BQB test flag mask 0x%08x", flag_mask);
return false;
}
return ((bt_mesh_bqb_test_flag_get() & flag_mask) == flag_mask);
}
#endif /* CONFIG_BLE_MESH_BQB_TEST_LOG */