fix(ble_mesh): resolve miscellaneous logging issues

This commit is contained in:
luoxu
2025-09-09 15:31:01 +08:00
committed by Luo Xu
parent 556eeb934d
commit dfde4492d7
11 changed files with 67 additions and 77 deletions

View File

@@ -29,10 +29,8 @@
static struct bt_mesh_adv_queue *adv_queue;
#if CONFIG_BLE_MESH_RELAY_ADV_BUF
#define BLE_MESH_RELAY_QUEUE_SIZE CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT
static QueueSetHandle_t mesh_queue_set;
#define BLE_MESH_QUEUE_SET_SIZE (BLE_MESH_ADV_QUEUE_SIZE + BLE_MESH_RELAY_QUEUE_SIZE)
#define BLE_MESH_QUEUE_SET_SIZE (bt_mesh_adv_buf_count_get() + bt_mesh_relay_adv_buf_count_get())
#endif /* CONFIG_BLE_MESH_RELAY_ADV_BUF */
static int adv_send(struct net_buf *buf)

View File

@@ -158,7 +158,7 @@ int bt_mesh_adv_inst_init(enum bt_mesh_adv_inst_type inst_type, uint8_t inst_id)
return -EINVAL;
}
if (inst_id == BLE_MESH_ADV_INS_UNUSED) {
if (inst_id == BLE_MESH_ADV_INST_UNUSED) {
BT_ERR("UnusedAdvInstID");
return -EINVAL;
}
@@ -181,7 +181,7 @@ int bt_mesh_adv_inst_deinit(enum bt_mesh_adv_inst_type inst_type)
bt_le_ext_adv_stop(adv_insts[inst_type].id);
adv_insts[inst_type].id = BLE_MESH_ADV_INS_UNUSED;
adv_insts[inst_type].id = BLE_MESH_ADV_INST_UNUSED;
#if CONFIG_BLE_MESH_SUPPORT_MULTI_ADV
adv_insts[inst_type].spt_mask = 0;
#endif /* CONFIG_BLE_MESH_SUPPORT_MULTI_ADV */
@@ -243,7 +243,7 @@ struct bt_mesh_adv *ext_long_relay_adv_alloc(int id, enum bt_mesh_adv_type type)
#endif /* CONFIG_BLE_MESH_LONG_PACKET_RELAY_ADV_BUF_COUNT */
#endif /* CONFIG_BLE_MESH_LONG_PACKET */
struct bt_mesh_adv_type_manager *bt_mesh_adv_types_mgnt_get(enum bt_mesh_adv_type adv_type)
struct bt_mesh_adv_type_manager *bt_mesh_adv_types_mgmt_get(enum bt_mesh_adv_type adv_type)
{
BT_DBG("AdvTypeMgmtGet, AdvType %u", adv_type);
@@ -668,21 +668,6 @@ uint16_t bt_mesh_get_stored_relay_count(void)
return count;
}
static ALWAYS_INLINE
uint16_t bt_mesh_relay_adv_buf_count_get(void)
{
uint16_t relay_adv_count = 2 + CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT;
#if CONFIG_BLE_MESH_EXT_ADV && CONFIG_BLE_MESH_RELAY
relay_adv_count += CONFIG_BLE_MESH_EXT_RELAY_ADV_BUF_COUNT;
#endif
#if CONFIG_BLE_MESH_LONG_PACKET && CONFIG_BLE_MESH_RELAY
relay_adv_count += CONFIG_BLE_MESH_LONG_PACKET_RELAY_ADV_BUF_COUNT;
#endif
return relay_adv_count;
}
void bt_mesh_relay_adv_init(void)
{
BT_DBG("RelayAdvInit");
@@ -806,33 +791,6 @@ void bt_mesh_frnd_adv_deinit(void)
}
#endif /* CONFIG_BLE_MESH_FRIEND */
static ALWAYS_INLINE
uint16_t bt_mesh_adv_buf_count_get(void)
{
uint16_t adv_count = 2 + CONFIG_BLE_MESH_ADV_BUF_COUNT;
#if CONFIG_BLE_MESH_EXT_ADV
adv_count += CONFIG_BLE_MESH_EXT_ADV_BUF_COUNT;
#if !CONFIG_BLE_MESH_RELAY_ADV_BUF && CONFIG_BLE_MESH_RELAY
adv_count += CONFIG_BLE_MESH_EXT_RELAY_ADV_BUF_COUNT;
#endif /* !CONFIG_BLE_MESH_RELAY_ADV_BUF && CONFIG_BLE_MESH_RELAY */
#endif /* CONFIG_BLE_MESH_EXT_ADV */
#if CONFIG_BLE_MESH_LONG_PACKET
adv_count += CONFIG_BLE_MESH_LONG_PACKET_ADV_BUF_COUNT;
#if !CONFIG_BLE_MESH_RELAY_ADV_BUF && CONFIG_BLE_MESH_RELAY
adv_count += CONFIG_BLE_MESH_LONG_PACKET_RELAY_ADV_BUF_COUNT;
#endif /* !CONFIG_BLE_MESH_RELAY_ADV_BUF && CONFIG_BLE_MESH_RELAY */
#endif /* CONFIG_BLE_MESH_LONG_PACKET */
#if (CONFIG_BLE_MESH_SUPPORT_BLE_ADV && \
!(CONFIG_BLE_MESH_USE_BLE_50 && CONFIG_BLE_MESH_SEPARATE_BLE_ADV_INSTANCE))
adv_count += CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT;
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
return adv_count;
}
void bt_mesh_adv_task_init(void adv_thread(void *p))
{
BT_DBG("AdvTaskInit");
@@ -861,7 +819,14 @@ void bt_mesh_adv_task_init(void adv_thread(void *p))
#else /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && (CONFIG_SPIRAM_CACHE_WORKAROUND || !CONFIG_IDF_TARGET_ESP32) && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY */
int ret = xTaskCreatePinnedToCore(adv_thread, BLE_MESH_ADV_TASK_NAME, BLE_MESH_ADV_TASK_STACK_SIZE, NULL,
BLE_MESH_ADV_TASK_PRIO, &adv_task.handle, BLE_MESH_ADV_TASK_CORE);
#if CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
if (ret != pdTRUE) {
BT_ERR("xTaskCreatePinnedToCore failed, ret %d", ret);
return;
}
#else
assert(ret == pdTRUE);
#endif /* CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE */
#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && (CONFIG_SPIRAM_CACHE_WORKAROUND || !CONFIG_IDF_TARGET_ESP32) && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY */
}

View File

@@ -298,6 +298,21 @@ void bt_mesh_adv_inst_type_clear(enum bt_mesh_adv_inst_type inst_type,
#endif /* CONFIG_BLE_MESH_SUPPORT_MULTI_ADV */
#if CONFIG_BLE_MESH_RELAY_ADV_BUF
static ALWAYS_INLINE
uint16_t bt_mesh_relay_adv_buf_count_get(void)
{
uint16_t relay_adv_count = 2 + CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT;
#if CONFIG_BLE_MESH_EXT_ADV && CONFIG_BLE_MESH_RELAY
relay_adv_count += CONFIG_BLE_MESH_EXT_RELAY_ADV_BUF_COUNT;
#endif
#if CONFIG_BLE_MESH_LONG_PACKET && CONFIG_BLE_MESH_RELAY
relay_adv_count += CONFIG_BLE_MESH_LONG_PACKET_RELAY_ADV_BUF_COUNT;
#endif
return relay_adv_count;
}
void bt_mesh_relay_adv_init(void);
bool bt_mesh_ignore_relay_packet(uint32_t timestamp);
@@ -325,6 +340,33 @@ void bt_mesh_frnd_adv_deinit(void);
#endif /* CONFIG_BLE_MESH_DEINIT */
#endif /* CONFIG_BLE_MESH_FRIEND */
static ALWAYS_INLINE
uint16_t bt_mesh_adv_buf_count_get(void)
{
uint16_t adv_count = 2 + CONFIG_BLE_MESH_ADV_BUF_COUNT;
#if CONFIG_BLE_MESH_EXT_ADV
adv_count += CONFIG_BLE_MESH_EXT_ADV_BUF_COUNT;
#if !CONFIG_BLE_MESH_RELAY_ADV_BUF && CONFIG_BLE_MESH_RELAY
adv_count += CONFIG_BLE_MESH_EXT_RELAY_ADV_BUF_COUNT;
#endif /* !CONFIG_BLE_MESH_RELAY_ADV_BUF && CONFIG_BLE_MESH_RELAY */
#endif /* CONFIG_BLE_MESH_EXT_ADV */
#if CONFIG_BLE_MESH_LONG_PACKET
adv_count += CONFIG_BLE_MESH_LONG_PACKET_ADV_BUF_COUNT;
#if !CONFIG_BLE_MESH_RELAY_ADV_BUF && CONFIG_BLE_MESH_RELAY
adv_count += CONFIG_BLE_MESH_LONG_PACKET_RELAY_ADV_BUF_COUNT;
#endif /* !CONFIG_BLE_MESH_RELAY_ADV_BUF && CONFIG_BLE_MESH_RELAY */
#endif /* CONFIG_BLE_MESH_LONG_PACKET */
#if (CONFIG_BLE_MESH_SUPPORT_BLE_ADV && \
!(CONFIG_BLE_MESH_USE_BLE_50 && CONFIG_BLE_MESH_SEPARATE_BLE_ADV_INSTANCE))
adv_count += CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT;
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
return adv_count;
}
void bt_mesh_adv_task_init(void adv_thread(void *p));
void bt_mesh_adv_common_init(void);

View File

@@ -3356,7 +3356,7 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
static uint8_t hb_log(uint16_t val)
{
BT_DBG("HbLog, Val 0x%04x", val);
switch (val) {
case 0x0000:
return 0x00;

View File

@@ -142,7 +142,8 @@ static int adv_send(struct bt_mesh_adv_inst *inst, uint16_t *adv_duration)
err = bt_le_ext_adv_start(inst->id, &param, &ad, 1, NULL, 0);
}
break;
}
break;
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
case BLE_MESH_ADV_BLE:

View File

@@ -792,7 +792,7 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx,
static void enqueue_buf(struct bt_mesh_friend *frnd, struct net_buf *buf)
{
BT_DBG("EnqueueBuf, Buf %p QueueSize %u", __func__, buf, frnd->queue_size);
BT_DBG("EnqueueBuf, Buf %p QueueSize %u", buf, frnd->queue_size);
net_buf_slist_put(&frnd->queue, buf);
frnd->queue_size++;
@@ -802,7 +802,7 @@ static void enqueue_update(struct bt_mesh_friend *frnd, uint8_t md)
{
struct net_buf *buf = NULL;
BT_DBG("EnqueueUpdate, LPN 0x%04x MD %u", __func__, frnd->lpn, md);
BT_DBG("EnqueueUpdate, LPN 0x%04x MD %u", frnd->lpn, md);
buf = encode_update(frnd, md);
if (!buf) {

View File

@@ -104,7 +104,7 @@ static bool check_dup(struct net_buf_simple *data)
}
}
BT_DBG("DupCacheAdd, CacheNext %ld", val, dup_cache_next);
BT_DBG("DupCacheAdd, CacheNext %ld %d", val, dup_cache_next);
dup_cache[dup_cache_next++] = val;
dup_cache_next %= ARRAY_SIZE(dup_cache);

View File

@@ -2812,7 +2812,7 @@ static void protocol_timeout(struct k_work *work)
{
struct bt_mesh_prov_link *link = work->user_data;
BT_WARN("Protocol timeout,LinkId:%08x", link->link_id);
BT_WARN("Protocol timeout,RmtAddr:%s", bt_hex(link->addr.val, 6));
close_link(link, CLOSE_REASON_TIMEOUT);
}

View File

@@ -36,7 +36,7 @@ _Static_assert(!(IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && IS_ENABLED(CON
#endif
#if CONFIG_BLE_MESH_USE_BLE_50
static uint8_t proxy_adv_inst = BLE_MESH_ADV_INS_UNUSED;
static uint8_t proxy_adv_inst = BLE_MESH_ADV_INST_UNUSED;
#endif /* CONFIG_BLE_MESH_USE_BLE_50 */
#define ADV_OPT (BLE_MESH_ADV_OPT_CONNECTABLE | BLE_MESH_ADV_OPT_ONE_TIME)
@@ -2028,7 +2028,7 @@ int32_t bt_mesh_proxy_server_adv_start(void)
}
#if CONFIG_BLE_MESH_USE_BLE_50
if (proxy_adv_inst == BLE_MESH_ADV_INS_UNUSED) {
if (proxy_adv_inst == BLE_MESH_ADV_INST_UNUSED) {
BT_DBG("ProxyAdvInstUnused");
return K_FOREVER;
}
@@ -2108,7 +2108,7 @@ int bt_mesh_proxy_server_adv_stop(void)
}
#if CONFIG_BLE_MESH_USE_BLE_50
if (proxy_adv_inst == BLE_MESH_ADV_INS_UNUSED) {
if (proxy_adv_inst == BLE_MESH_ADV_INST_UNUSED) {
BT_ERR("Proxy adv inst is not initialized!");
return -EINVAL;
}
@@ -2189,7 +2189,7 @@ int bt_mesh_proxy_server_deinit(void)
BT_DBG("ProxyServerDeinit");
#if CONFIG_BLE_MESH_USE_BLE_50
proxy_adv_inst = BLE_MESH_ADV_INS_UNUSED;
proxy_adv_inst = BLE_MESH_ADV_INST_UNUSED;
#endif /* CONFIG_BLE_MESH_USE_BLE_50 */
bt_mesh_proxy_server_adv_flag_set(false);

View File

@@ -788,7 +788,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg,
uint8_t aid = 0U;
int err = 0;
BT_DBG("TransSend");
BT_DBG("transcend");
if (msg->len < 1) {
BT_ERR("Zero-length SDU not allowed");

View File

@@ -1199,7 +1199,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg,
uint8_t aid = 0U;
int err = 0;
BT_DBG("TransSend");
BT_DBG("transcend");
if (msg->len < 1) {
BT_ERR("Zero-length SDU not allowed");
@@ -2220,7 +2220,6 @@ static struct seg_rx *seg_rx_alloc(struct bt_mesh_net_rx *net_rx,
{
int err = 0;
<<<<<<< HEAD
/* By default, traditional seg_rx is used for allocation.
* If the first segment received is the last segment of
* the long packet, and its length is the length of the traditional packet,
@@ -2240,12 +2239,8 @@ static struct seg_rx *seg_rx_alloc(struct bt_mesh_net_rx *net_rx,
for (size_t i = 0; i < rx_buf_size; i++) {
struct seg_rx *rx = &seg_rx_buf[i];
=======
BT_DBG("SegRxAlloc, SegN %u", seg_n);
for (size_t i = 0; i < ARRAY_SIZE(seg_rx); i++) {
struct seg_rx *rx = &seg_rx[i];
>>>>>>> 7652269a401 (feat(ble_mesh): Miscellaneous log enhancement for BLE Mesh)
BT_DBG("SegRxAlloc, SegN %u", seg_n);
if (rx->in_use) {
continue;
@@ -2474,20 +2469,14 @@ found_rx:
/* Set the expected final buffer length */
rx->buf.len = seg_n * seg_len(&si) + buf->len;
<<<<<<< HEAD
BT_DBG("Target len %u * %u + %u = %u", seg_n, seg_len(&si),
buf->len, rx->buf.len);
=======
BT_DBG("Target len %u * %u + %u = %u",
seg_n, seg_len(rx->ctl), buf->len, rx->buf.len);
>>>>>>> 7652269a401 (feat(ble_mesh): Miscellaneous log enhancement for BLE Mesh)
/* This should not happen, since we have made sure the whole
* SDU could be received while handling the first segment.
* But if the peer device sends the segments of a segmented
* message with different CTL, then the following could happen.
*/
<<<<<<< HEAD
if ((!rx->ext && rx->buf.len > CONFIG_BLE_MESH_RX_SDU_MAX)
#if CONFIG_BLE_MESH_LONG_PACKET
|| (rx->ext && rx->buf.len > BLE_MESH_EXT_RX_SDU_MAX)
@@ -2495,11 +2484,6 @@ found_rx:
) {
BT_ERR("Too large SDU len %u/%u", rx->buf.len,
CONFIG_BLE_MESH_RX_SDU_MAX);
=======
if (rx->buf.len > CONFIG_BLE_MESH_RX_SDU_MAX) {
BT_ERR("Too large SDU len %u/%u",
rx->buf.len, CONFIG_BLE_MESH_RX_SDU_MAX);
>>>>>>> 7652269a401 (feat(ble_mesh): Miscellaneous log enhancement for BLE Mesh)
send_ack(net_rx->sub, net_rx->ctx.recv_dst,
net_rx->ctx.addr, net_rx->ctx.send_ttl,