mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Refactor timeout calculations for repeater and login frames to ensure minimum message size is respected; remove obsolete widget test file.
This commit is contained in:
parent
b2ce82fe7e
commit
01bd8243da
6 changed files with 22 additions and 21 deletions
|
|
@ -261,9 +261,12 @@ class _RepeaterStatusScreenState extends State<RepeaterStatusScreen> {
|
|||
await connector.sendFrame(frame);
|
||||
|
||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
||||
final messageBytes = frame.length >= _statusResponseBytes
|
||||
var messageBytes = frame.length >= _statusResponseBytes
|
||||
? frame.length
|
||||
: _statusResponseBytes;
|
||||
if (messageBytes < maxFrameSize) {
|
||||
messageBytes = maxFrameSize;
|
||||
}
|
||||
final timeoutMs = connector.calculateTimeout(
|
||||
pathLength: pathLengthValue,
|
||||
messageBytes: messageBytes,
|
||||
|
|
|
|||
|
|
@ -121,9 +121,12 @@ class _TelemetryScreenState extends State<TelemetryScreen> {
|
|||
await connector.sendFrame(frame);
|
||||
|
||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
||||
final messageBytes = frame.length >= _statusResponseBytes
|
||||
var messageBytes = frame.length >= _statusResponseBytes
|
||||
? frame.length
|
||||
: _statusResponseBytes;
|
||||
if (messageBytes < maxFrameSize) {
|
||||
messageBytes = maxFrameSize;
|
||||
}
|
||||
final timeoutMs = connector.calculateTimeout(
|
||||
pathLength: pathLengthValue,
|
||||
messageBytes: messageBytes,
|
||||
|
|
|
|||
|
|
@ -70,11 +70,6 @@ class RepeaterCommandService {
|
|||
_pendingByPrefix[prefix] = commandId;
|
||||
final framedCommand = '$prefix$command';
|
||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
||||
final timeoutMs = _connector.calculateTimeout(
|
||||
pathLength: pathLengthValue,
|
||||
messageBytes: framedCommand.length,
|
||||
);
|
||||
final timeoutSeconds = (timeoutMs / 1000).ceil();
|
||||
final timestampSeconds = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
_connector.trackRepeaterAck(
|
||||
contact: repeater,
|
||||
|
|
@ -89,6 +84,12 @@ class RepeaterCommandService {
|
|||
attempt: attempt,
|
||||
timestampSeconds: timestampSeconds,
|
||||
);
|
||||
final responseBytes = frame.length > maxFrameSize ? frame.length : maxFrameSize;
|
||||
final timeoutMs = _connector.calculateTimeout(
|
||||
pathLength: pathLengthValue,
|
||||
messageBytes: responseBytes,
|
||||
);
|
||||
final timeoutSeconds = (timeoutMs / 1000).ceil();
|
||||
await _connector.sendFrame(frame);
|
||||
_commandTimeouts[commandId]?.cancel();
|
||||
_commandTimeouts[commandId] = Timer(
|
||||
|
|
|
|||
|
|
@ -91,9 +91,12 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
|||
final selection = await _connector.preparePathForContactSend(repeater);
|
||||
final loginFrame = buildSendLoginFrame(repeater.publicKey, password);
|
||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
||||
final responseBytes = loginFrame.length > maxFrameSize
|
||||
? loginFrame.length
|
||||
: maxFrameSize;
|
||||
final timeoutMs = _connector.calculateTimeout(
|
||||
pathLength: pathLengthValue,
|
||||
messageBytes: loginFrame.length,
|
||||
messageBytes: responseBytes,
|
||||
);
|
||||
final timeoutSeconds = (timeoutMs / 1000).ceil();
|
||||
final timeout = Duration(milliseconds: timeoutMs);
|
||||
|
|
|
|||
|
|
@ -91,9 +91,12 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
|||
final selection = await _connector.preparePathForContactSend(room);
|
||||
final loginFrame = buildSendLoginFrame(room.publicKey, password);
|
||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
||||
final responseBytes = loginFrame.length > maxFrameSize
|
||||
? loginFrame.length
|
||||
: maxFrameSize;
|
||||
final timeoutMs = _connector.calculateTimeout(
|
||||
pathLength: pathLengthValue,
|
||||
messageBytes: loginFrame.length,
|
||||
messageBytes: responseBytes,
|
||||
);
|
||||
final timeoutSeconds = (timeoutMs / 1000).ceil();
|
||||
final timeout = Duration(milliseconds: timeoutMs);
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('App loads successfully', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const MeshCoreApp());
|
||||
|
||||
// Verify that the app title appears
|
||||
expect(find.text('MeshCore Open'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue