bleWriteSize function
Returns the largest ATT write value, at most maxWrite bytes, that exactly
fills whole link-layer packets (251k - 7 bytes: 244, 495, ...). A write
that overruns a packet boundary by a few bytes spends a whole extra packet
of airtime on them. Returns maxWrite when not even one packet fits.
Implementation
int bleWriteSize(int maxWrite) {
final packets = (maxWrite + _attWriteOverhead) ~/ _llPduPayload;
if (packets == 0) {
return maxWrite;
}
return packets * _llPduPayload - _attWriteOverhead;
}