Skip to content

Commit de71cc5

Browse files
committed
Bluetooth: Mesh: Blob Server considers friendship
Fix Max Chunk reporting during Block_Information_Get: 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. Fix Chunk requests: Adapt number of requested chunks according to current friend queue size. If friend queue is too small, at least 1 chunk is requested. Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
1 parent 366d45f commit de71cc5

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

subsys/bluetooth/mesh/blob_srv.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,12 @@ static int pull_req_max(const struct bt_mesh_blob_srv *srv)
151151
BLOB_CHUNK_SDU_LEN(srv->state.xfer.chunk_size),
152152
BT_MESH_APP_SEG_SDU_MAX);
153153

154-
count = MIN(CONFIG_BT_MESH_BLOB_SRV_PULL_REQ_COUNT,
155-
bt_mesh.lpn.queue_size / segments_per_chunk);
154+
/* It is possible that the friend node cannot hold all segments per chunk. In this
155+
* case, we should request only 1 chunk.
156+
*/
157+
count = MAX(1, MIN(CONFIG_BT_MESH_BLOB_SRV_PULL_REQ_COUNT,
158+
bt_mesh.lpn.queue_size / segments_per_chunk));
159+
156160
}
157161
#endif
158162

@@ -821,7 +825,26 @@ static int handle_info_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_c
821825
net_buf_simple_add_u8(&rsp, BLOB_BLOCK_SIZE_LOG_MIN);
822826
net_buf_simple_add_u8(&rsp, BLOB_BLOCK_SIZE_LOG_MAX);
823827
net_buf_simple_add_le16(&rsp, CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX);
828+
829+
#if defined(CONFIG_BT_MESH_LOW_POWER)
830+
/* If friendship is established, then chunk size is according to friend's queue size.
831+
* Chunk size = (Queue size * Bytes per segment) - Opcode - Chunk Number - 8 byte MIC (max)
832+
*/
833+
if (bt_mesh.lpn.established && bt_mesh.lpn.queue_size > 0) {
834+
uint16_t chunk_size = (bt_mesh.lpn.queue_size * 12) - 11;
835+
836+
chunk_size = MIN(chunk_size, BLOB_RX_CHUNK_SIZE);
837+
net_buf_simple_add_le16(&rsp, chunk_size);
838+
if (bt_mesh.lpn.queue_size <= 2) {
839+
LOG_WRN("FndQ too small %u", bt_mesh.lpn.queue_size);
840+
}
841+
} else {
842+
net_buf_simple_add_le16(&rsp, BLOB_RX_CHUNK_SIZE);
843+
}
844+
#else
824845
net_buf_simple_add_le16(&rsp, BLOB_RX_CHUNK_SIZE);
846+
#endif
847+
825848
net_buf_simple_add_le32(&rsp, CONFIG_BT_MESH_BLOB_SIZE_MAX);
826849
net_buf_simple_add_le16(&rsp, MTU_SIZE_MAX);
827850
net_buf_simple_add_u8(&rsp, BT_MESH_BLOB_XFER_MODE_ALL);

0 commit comments

Comments
 (0)