mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-01 06:40:08 +00:00
nimble/ll: Enforce minimum payload length for coded phy
Lower bound of connEffectiveMaxTxTime depends on current phy but it is always at least the time required to send 27 bytes of payload. This patch enforces this. Without this fix we were sending control packets with no payload after phy has changed from uncoded to coded which had really strange results. X-Original-Commit: 5344b77d4e5f3663c239d13b2f2d7a7f8ad80ad1
This commit is contained in:
@@ -1283,9 +1283,20 @@ ble_ll_pdu_max_tx_octets_get(uint32_t usecs, int phy_mode)
|
||||
|
||||
header_tx_time = g_ble_ll_pdu_header_tx_time[phy_mode];
|
||||
|
||||
/*
|
||||
* Current conn max tx time can be too short to even send a packet header
|
||||
* and this can happen if we changed connection form uncoded to coded phy.
|
||||
* However, the lower bound for conn max tx time (all of them) depends on
|
||||
* current phy (uncoded/coded) but it always allows to send at least 27
|
||||
* bytes of payload thus we alwyas return at least 27 from here.
|
||||
*
|
||||
* Reference:
|
||||
* Core v5.0, Vol 6, Part B, section 4.5.10
|
||||
* see connEffectiveMaxTxTime and connEffectiveMaxRxTime definitions
|
||||
*/
|
||||
|
||||
if (usecs < header_tx_time) {
|
||||
// XXX: this is obviously incorrect, what should we do?
|
||||
return 0;
|
||||
return 27;
|
||||
}
|
||||
|
||||
usecs -= header_tx_time;
|
||||
@@ -1306,7 +1317,8 @@ ble_ll_pdu_max_tx_octets_get(uint32_t usecs, int phy_mode)
|
||||
assert(0);
|
||||
}
|
||||
|
||||
return octets;
|
||||
/* see comment at the beginning */
|
||||
return max(27, octets);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user