From 630606acdcca1f0a71334590e54541deb6f696d1 Mon Sep 17 00:00:00 2001 From: Winston Lowe Date: Mon, 23 Mar 2026 08:14:46 -0700 Subject: [PATCH] Update byte skipping logic and improve clarity in MeshCoreConnector and ChannelMessage --- lib/connector/meshcore_connector.dart | 3 ++- lib/models/channel_message.dart | 2 +- lib/services/message_retry_service.dart | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 5dc660e5..04e95837 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -4323,7 +4323,8 @@ class MeshCoreConnector extends ChangeNotifier { routeType == _routeTransportFlood || routeType == _routeTransportDirect; if (hasTransport) { - reader.skipBytes(2); // Skip reserved bytes in transport header + // Skip reserved bytes in transport header made up of two u16 fields + reader.skipBytes(4); } final pathLenRaw = reader.readByte(); final pathByteLen = _decodePathByteLen(pathLenRaw); diff --git a/lib/models/channel_message.dart b/lib/models/channel_message.dart index 98a8f1d4..0f0a5b4f 100644 --- a/lib/models/channel_message.dart +++ b/lib/models/channel_message.dart @@ -129,11 +129,11 @@ class ChannelMessage { if (code == respCodeChannelMsgRecvV3) { reader.skipBytes(1); // Skip SNR final flags = reader.readByte(); + final hasPath = (flags & 0x01) != 0; reader.skipBytes(1); // Skip reserved byte channelIdx = reader.readByte(); pathLen = reader.readByte(); txtType = reader.readByte(); - final hasPath = (flags & 0x01) != 0; if (hasPath && pathLen > 0) { reader.rewind(); // Rewind to read path length again for pathBytes pathBytes = reader.readBytes(pathLen); diff --git a/lib/services/message_retry_service.dart b/lib/services/message_retry_service.dart index 94f3caf4..c8e89aa8 100644 --- a/lib/services/message_retry_service.dart +++ b/lib/services/message_retry_service.dart @@ -678,7 +678,7 @@ class MessageRetryService extends ChangeNotifier { } } - String? getContactKeyForAckHash(Uint8List ackHash) { + String? getContactKeyForAckHash(int ackHash) { for (var entry in _pendingMessages.entries) { final message = entry.value; if (message.expectedAckHash != null &&