From 80bee1da1f3b93a07686ab916c824ab4aa7d0f46 Mon Sep 17 00:00:00 2001 From: lly Date: Tue, 12 Jan 2021 16:20:11 +0800 Subject: [PATCH 1/3] ble_mesh: stack: Add prefix BLE_MESH_ for log related macros --- .../mesh_common/include/mesh_trace.h | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h index d4b96e109c..aa46790f12 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h @@ -18,39 +18,39 @@ extern "C" { #endif /* Define common tracing for all */ -#ifndef LOG_LEVEL_ERROR -#define LOG_LEVEL_ERROR 1 -#endif /* LOG_LEVEL_ERROR */ +#ifndef BLE_MESH_LOG_LEVEL_ERROR +#define BLE_MESH_LOG_LEVEL_ERROR 1 +#endif /* BLE_MESH_LOG_LEVEL_ERROR */ -#ifndef LOG_LEVEL_WARN -#define LOG_LEVEL_WARN 2 -#endif /* LOG_LEVEL_WARN */ +#ifndef BLE_MESH_LOG_LEVEL_WARN +#define BLE_MESH_LOG_LEVEL_WARN 2 +#endif /* BLE_MESH_LOG_LEVEL_WARN */ -#ifndef LOG_LEVEL_INFO -#define LOG_LEVEL_INFO 3 -#endif /* LOG_LEVEL_INFO */ +#ifndef BLE_MESH_LOG_LEVEL_INFO +#define BLE_MESH_LOG_LEVEL_INFO 3 +#endif /* BLE_MESH_LOG_LEVEL_INFO */ -#ifndef LOG_LEVEL_DEBUG -#define LOG_LEVEL_DEBUG 4 -#endif /* LOG_LEVEL_DEBUG */ +#ifndef BLE_MESH_LOG_LEVEL_DEBUG +#define BLE_MESH_LOG_LEVEL_DEBUG 4 +#endif /* BLE_MESH_LOG_LEVEL_DEBUG */ -#ifndef LOG_LEVEL_VERBOSE -#define LOG_LEVEL_VERBOSE 5 -#endif /*LOG_LEVEL_VERBOSE */ +#ifndef BLE_MESH_LOG_LEVEL_VERBOSE +#define BLE_MESH_LOG_LEVEL_VERBOSE 5 +#endif /*BLE_MESH_LOG_LEVEL_VERBOSE */ #ifdef CONFIG_BLE_MESH_STACK_TRACE_LEVEL -#define MESH_LOG_LEVEL CONFIG_BLE_MESH_STACK_TRACE_LEVEL +#define BLE_MESH_LOG_LEVEL CONFIG_BLE_MESH_STACK_TRACE_LEVEL #else -#define MESH_LOG_LEVEL LOG_LEVEL_WARN +#define BLE_MESH_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN #endif #ifdef CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL -#define NET_BUF_LOG_LEVEL CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL +#define BLE_MESH_NET_BUF_LOG_LEVEL CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL #else -#define NET_BUF_LOG_LEVEL LOG_LEVEL_WARN +#define BLE_MESH_NET_BUF_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN #endif -#define MESH_TRACE_TAG "BLE_MESH" +#define BLE_MESH_TRACE_TAG "BLE_MESH" #if (LOG_LOCAL_LEVEL >= 4) #define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL + 1) @@ -58,13 +58,13 @@ extern "C" { #define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL #endif -#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= LOG_LEVEL_##LEVEL) +#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= BLE_MESH_LOG_LEVEL_##LEVEL) -#define BLE_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } -#define BLE_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } -#define BLE_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } -#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } -#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } #define printk esp_rom_printf @@ -86,14 +86,14 @@ extern "C" { #endif #ifndef __ASSERT_NO_MSG -#define __ASSERT_NO_MSG(x) do { if (!(x)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, "error %s %u", __FILE__, __LINE__); } while (0) +#define __ASSERT_NO_MSG(x) do { if (!(x)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, "error %s %u", __FILE__, __LINE__); } while (0) #endif #if !CONFIG_BLE_MESH_NO_LOG -#define BT_ERR(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(MESH, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0) -#define BT_WARN(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(MESH, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0) -#define BT_INFO(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(MESH, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0) -#define BT_DBG(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(MESH, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_ERR(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_WARN(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_INFO(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_DBG(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) #else #define BT_ERR(fmt, args...) #define BT_WARN(fmt, args...) @@ -102,10 +102,10 @@ extern "C" { #endif #if defined(CONFIG_BLE_MESH_NET_BUF_LOG) && (!CONFIG_BLE_MESH_NO_LOG) -#define NET_BUF_ERR(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0) -#define NET_BUF_WARN(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0) -#define NET_BUF_INFO(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0) -#define NET_BUF_DBG(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) #define NET_BUF_ASSERT(cond) __ASSERT_NO_MSG(cond) #else #define NET_BUF_ERR(fmt, args...) @@ -116,10 +116,10 @@ extern "C" { #endif #if defined(CONFIG_BLE_MESH_NET_BUF_SIMPLE_LOG) && (!CONFIG_BLE_MESH_NO_LOG) -#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0) -#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0) -#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0) -#define NET_BUF_SIMPLE_DBG(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) #define NET_BUF_SIMPLE_ASSERT(cond) __ASSERT_NO_MSG(cond) #else #define NET_BUF_SIMPLE_ERR(fmt, args...) From bcd9710b8696d5ddcbb29c2f8c4a415d0ba77528 Mon Sep 17 00:00:00 2001 From: lly Date: Tue, 12 Jan 2021 16:24:57 +0800 Subject: [PATCH 2/3] ble_mesh: ci: Add disable log sdkconfig test files --- .../onoff_server/sdkconfig.ci.bluedroid_log | 16 ++++++++++++++++ .../onoff_server/sdkconfig.ci.nimble_log | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid_log create mode 100644 examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble_log diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid_log b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid_log new file mode 100644 index 0000000000..32a770f443 --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid_log @@ -0,0 +1,16 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y +CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CTRL_MODE_BTDM=n +CONFIG_BTDM_MODEM_SLEEP=n +CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE=y +CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN=y +CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MANUAL=y +CONFIG_BT_BTU_TASK_STACK_SIZE=4512 + +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_FRIEND=y +CONFIG_BLE_MESH_SETTINGS=y +CONFIG_BLE_MESH_NO_LOG=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble_log b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble_log new file mode 100644 index 0000000000..e52e3bc5aa --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble_log @@ -0,0 +1,15 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y +CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CTRL_MODE_BTDM=n +CONFIG_BTDM_MODEM_SLEEP=n +CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE=y +CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN=y +CONFIG_BT_NIMBLE_ENABLED=y + +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_LOW_POWER=y +CONFIG_BLE_MESH_SETTINGS=y +CONFIG_BLE_MESH_NO_LOG=y From 0edb86ddb0444169cd9ee6f3d979a671d63eedfb Mon Sep 17 00:00:00 2001 From: lly Date: Tue, 12 Jan 2021 17:26:48 +0800 Subject: [PATCH 3/3] ble_mesh: stack: Fix compile warning when log is disabled --- .../bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c index f9027f735f..cdc1863068 100644 --- a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c @@ -1186,6 +1186,8 @@ static int gatts_register(struct bt_mesh_gatt_service *svc) handle = last->attrs[last->attr_count - 1].handle; BT_DBG("gatts register, handle %d", handle); + ARG_UNUSED(handle); + populate: sys_slist_append(&bt_mesh_gatts_db, &svc->node); return 0;