From f863a1b32855d37471b5e985752a90b5a30a853f Mon Sep 17 00:00:00 2001 From: lly Date: Tue, 26 May 2020 11:15:51 +0800 Subject: [PATCH 1/2] ble_mesh: Friend with unknown appkey [Zephyr] Ensures that friend messages are enqueued, even if the packet is received with an appkey is unknown to the friend. Previously, sdu_recv would return EINVAL if the appkey was unknown, which would prevent the lower transport layer from adding the packet to the friend queue. This is irrelevant for the logic in lower transport, and should not be returned as an error. --- components/bt/esp_ble_mesh/mesh_core/transport.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.c b/components/bt/esp_ble_mesh/mesh_core/transport.c index 432145595b..bc3d69bd17 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.c +++ b/components/bt/esp_ble_mesh/mesh_core/transport.c @@ -837,9 +837,11 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, return 0; } - BT_WARN("%s, No matching AppKey", __func__); + if (rx->local_match) { + BT_WARN("%s, No matching AppKey", __func__); + } bt_mesh_free_buf(sdu); - return -EINVAL; + return 0; } static struct seg_tx *seg_tx_lookup(u16_t seq_zero, u8_t obo, u16_t addr) From 0cfb6c138bf91ee8ee4e65122c9fc0ab28e78a86 Mon Sep 17 00:00:00 2001 From: lly Date: Tue, 26 May 2020 11:42:10 +0800 Subject: [PATCH 2/2] ble_mesh: Transport tx fields overflow [Zephyr] The transport segmented TX nack and seg_pending fields must be at least 6 bits to avoid overflow for 32 segment messages. This change rearranges the seg_tx fields to gather all state flag fields in one byte, while making the counter fields whole bytes. --- components/bt/esp_ble_mesh/mesh_core/transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.c b/components/bt/esp_ble_mesh/mesh_core/transport.c index bc3d69bd17..b69caccc57 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.c +++ b/components/bt/esp_ble_mesh/mesh_core/transport.c @@ -80,8 +80,8 @@ static struct seg_tx { new_key:1; /* New/old key */ u8_t nack_count; /* Number of unacked segs */ u8_t ttl; - u8_t seg_pending:5, /* Number of segments pending */ - attempts:3; + u8_t seg_pending; /* Number of segments pending */ + u8_t attempts; /* Transmit attempts */ const struct bt_mesh_send_cb *cb; void *cb_data; struct k_delayed_work retransmit; /* Retransmit timer */