fix(#395): correct BLE writable floor in effectiveMaxFrameSize (Gemini review)

Gemini adversarial review flagged the getter's clamp: the floor used the
ATT_MTU minimum (23) where it should use the writable minimum (20 = 23-3),
overstating the cap by 3 for tiny MTUs; and an unknown MTU defaulted to
maxFrameSize (172), the wrong direction for a safety cap. Floor at 20 and
default an unknown MTU conservatively. No behaviour change on radios that
grant MTU >= 175 (they hit the maxFrameSize short-circuit).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix/395-dm-channel-send-wedge
Strycher 4 months ago
parent 3463c1fb57
commit 3f7ddfebf9

@ -442,10 +442,15 @@ class MeshCoreConnector extends ChangeNotifier {
return maxFrameSize;
}
final mtu = _device?.mtuNow ?? 0;
if (mtu <= 0) return maxFrameSize;
// ATT_MTU 23 is the BLE minimum; a single write then carries 23 - 3 = 20
// bytes. An unknown MTU must fall back to that floor, never [maxFrameSize] —
// defaulting an unknown link to the largest size would authorize an
// oversized write (#395 review).
const minWritable = 20;
if (mtu <= 0) return minWritable;
final writable = mtu - 3;
if (writable >= maxFrameSize) return maxFrameSize;
return writable < 23 ? 23 : writable;
return writable < minWritable ? minWritable : writable;
}
String? get deviceId => _deviceId;

Loading…
Cancel
Save

Powered by TurnKey Linux.