ble_mesh: Update client message timeout calculation
Since the behavior of sending segmented messages has been changed properly, the calculation of timeout value which will be used when sending an acknowledged message by a client model also needs to be updated.
This commit is contained in:
parent
5e59233cc0
commit
9d7adc3e1b
3 changed files with 18 additions and 14 deletions
|
@ -191,9 +191,9 @@ struct bt_mesh_model_op {
|
|||
#define BLE_MESH_MODEL_NONE ((struct bt_mesh_model []){})
|
||||
|
||||
/** Length of a short Mesh MIC. */
|
||||
#define BLE_MESH_MIC_SHORT 4
|
||||
#define BLE_MESH_MIC_SHORT 4
|
||||
/** Length of a long Mesh MIC. */
|
||||
#define BLE_MESH_MIC_LONG 8
|
||||
#define BLE_MESH_MIC_LONG 8
|
||||
|
||||
/** @def BLE_MESH_MODEL_OP_LEN
|
||||
*
|
||||
|
|
|
@ -167,10 +167,16 @@ u8_t bt_mesh_get_seg_retrans_num(void)
|
|||
|
||||
s32_t bt_mesh_get_seg_retrans_timeout(u8_t ttl)
|
||||
{
|
||||
/* This function will be used when a client model sending an
|
||||
* acknowledged message. And if the dst of a message is not
|
||||
* a unicast address, the function will not be invoked.
|
||||
* So we can directly use the SEG_RETRANSMIT_TIMEOUT_UNICAST
|
||||
* macro here.
|
||||
*/
|
||||
struct seg_tx tx = {
|
||||
.ttl = ttl,
|
||||
};
|
||||
return SEG_RETRANSMIT_TIMEOUT(&tx);
|
||||
return SEG_RETRANSMIT_TIMEOUT_UNICAST(&tx);
|
||||
}
|
||||
|
||||
void bt_mesh_set_hb_sub_dst(u16_t addr)
|
||||
|
|
|
@ -185,7 +185,8 @@ static s32_t bt_mesh_client_calc_timeout(struct bt_mesh_msg_ctx *ctx,
|
|||
need_seg = true; /* Needs segmentation */
|
||||
}
|
||||
|
||||
mic_size = (need_seg && net_buf_simple_tailroom(msg) >= 8U) ? 8U : 4U;
|
||||
mic_size = (need_seg && net_buf_simple_tailroom(msg) >= BLE_MESH_MIC_LONG) ?
|
||||
BLE_MESH_MIC_LONG : BLE_MESH_MIC_SHORT;
|
||||
|
||||
if (need_seg) {
|
||||
/* Based on the message length, calculate how many segments are needed.
|
||||
|
@ -201,17 +202,14 @@ static s32_t bt_mesh_client_calc_timeout(struct bt_mesh_msg_ctx *ctx,
|
|||
* messages, but if there are other messages between any two retrans-
|
||||
* missions of the same segmented messages, then the whole time will
|
||||
* be longer.
|
||||
*
|
||||
* Since the transport behavior has been changed, i.e. start retransmit
|
||||
* timer after the last segment is sent, so we can simplify the timeout
|
||||
* calculation here. And the retransmit timer will be started event if
|
||||
* the attempts reaches ZERO when the dst is a unicast address.
|
||||
*/
|
||||
if (duration + HCI_TIME_FOR_START_ADV < seg_retrans_to) {
|
||||
s32_t seg_duration = seg_count * (duration + HCI_TIME_FOR_START_ADV);
|
||||
time = (seg_duration + seg_retrans_to) * (seg_retrans_num - 1) + seg_duration;
|
||||
} else {
|
||||
/* If the duration is bigger than the segment retransmit timeout
|
||||
* value. In this situation, the segment retransmit timeout value
|
||||
* may need to be optimized based on the "Network Transmit" value.
|
||||
*/
|
||||
time = seg_count * (duration + HCI_TIME_FOR_START_ADV) * seg_retrans_num;
|
||||
}
|
||||
s32_t seg_duration = seg_count * (duration + HCI_TIME_FOR_START_ADV);
|
||||
time = (seg_duration + seg_retrans_to) * seg_retrans_num;
|
||||
|
||||
BT_INFO("Original timeout %dms, calculated timeout %dms", timeout, time);
|
||||
|
||||
|
|
Loading…
Reference in a new issue