Skip to content

Commit 8129cdd

Browse files
committed
Bluetooth: Mesh: Blob Server considers friendship
If friendship is established, then max possible chunk size for transfer is reported according to friend's queue size. ChunkSize = (FndQ sz * Bytes per seg (12)) - Opcode(1) - Chunk_Num (2)- 8 byte MIC (max) = (FndQ sz * 12) - 11 This allows all segments of Chunk_Transfer messages to fit in a friend queue. If this is not done, friend queue keeps overflowing systematically causing unstable PULL_MODE transfers. Signed-off-by: Omkar Kulkarni <[email protected]>
1 parent 366d45f commit 8129cdd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

subsys/bluetooth/mesh/blob_srv.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,25 @@ static int handle_info_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_c
821821
net_buf_simple_add_u8(&rsp, BLOB_BLOCK_SIZE_LOG_MIN);
822822
net_buf_simple_add_u8(&rsp, BLOB_BLOCK_SIZE_LOG_MAX);
823823
net_buf_simple_add_le16(&rsp, CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX);
824+
825+
#if defined(CONFIG_BT_MESH_LOW_POWER)
826+
/* If friendship is established, then chunk size is according to friend's queue size.
827+
* Chunk size = (Queue size * Bytes per segment) - Opcode - Chunk Number - 8 byte MIC (max)
828+
*/
829+
if (bt_mesh.lpn.established && bt_mesh.lpn.queue_size > 0) {
830+
uint16_t chunk_size = (bt_mesh.lpn.queue_size * 12) - 11;
831+
chunk_size = MIN(chunk_size, BLOB_RX_CHUNK_SIZE);
832+
net_buf_simple_add_le16(&rsp, chunk_size);
833+
if (bt_mesh.lpn.queue_size <= 2) {
834+
LOG_WRN("FndQ too small %u", bt_mesh.lpn.queue_size);
835+
}
836+
} else {
837+
net_buf_simple_add_le16(&rsp, BLOB_RX_CHUNK_SIZE);
838+
}
839+
#else
824840
net_buf_simple_add_le16(&rsp, BLOB_RX_CHUNK_SIZE);
841+
#endif
842+
825843
net_buf_simple_add_le32(&rsp, CONFIG_BT_MESH_BLOB_SIZE_MAX);
826844
net_buf_simple_add_le16(&rsp, MTU_SIZE_MAX);
827845
net_buf_simple_add_u8(&rsp, BT_MESH_BLOB_XFER_MODE_ALL);

0 commit comments

Comments
 (0)