mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-20 15:51:01 +10:00
Merge pull request #2 from ericszimmermann/ez_snr_multibyte2.1
Forgot the bytewise reverse of the outgoing path
This commit is contained in:
@@ -33,29 +33,35 @@ class ChannelMessagePathScreen extends StatelessWidget {
|
|||||||
return Consumer<MeshCoreConnector>(
|
return Consumer<MeshCoreConnector>(
|
||||||
builder: (context, connector, _) {
|
builder: (context, connector, _) {
|
||||||
final l10n = context.l10n;
|
final l10n = context.l10n;
|
||||||
final primaryPathTmp = _selectPrimaryPath(
|
final primaryPath = _selectPrimaryPath(
|
||||||
message.pathBytes,
|
message.pathBytes,
|
||||||
message.pathVariants,
|
message.pathVariants,
|
||||||
);
|
);
|
||||||
|
|
||||||
final primaryPath = !channelMessage && !message.isOutgoing
|
final hashByteWidth =
|
||||||
? Uint8List.fromList(primaryPathTmp.reversed.toList())
|
(message.pathHashWidth ?? connector.pathHashByteWidth)
|
||||||
: primaryPathTmp;
|
.clamp(1, 4)
|
||||||
final hashByteWidth = (message.pathHashWidth ?? connector.pathHashByteWidth)
|
.toInt();
|
||||||
.clamp(1, 4)
|
final hops = _buildPathHops(
|
||||||
.toInt();
|
primaryPath,
|
||||||
final hops = _buildPathHops(primaryPath, connector, l10n, hashByteWidth);
|
connector,
|
||||||
|
l10n,
|
||||||
|
hashByteWidth,
|
||||||
|
);
|
||||||
final hasHopDetails = primaryPath.isNotEmpty;
|
final hasHopDetails = primaryPath.isNotEmpty;
|
||||||
|
|
||||||
// Convert observed path byte length to hop count using the packet width.
|
// Convert observed path byte length to hop count using the packet width.
|
||||||
// Legacy messages fall back to the current connector width.
|
// Legacy messages fall back to the current connector width.
|
||||||
// Reported path length (V3+) is already stored as a hop count; preserve
|
// Reported path length (V3+) is already stored as a hop count; preserve
|
||||||
// the negative flood sentinel when present.
|
// the negative flood sentinel when present.
|
||||||
final observedHopCount = _hopCountFromBytes(primaryPath.length, hashByteWidth);
|
final observedHopCount = _hopCountFromBytes(
|
||||||
|
primaryPath.length,
|
||||||
|
hashByteWidth,
|
||||||
|
);
|
||||||
final reportedHopCount = message.pathLength;
|
final reportedHopCount = message.pathLength;
|
||||||
final effectiveHopCount = observedHopCount > 0
|
final effectiveHopCount = observedHopCount > 0
|
||||||
? observedHopCount
|
? observedHopCount
|
||||||
: reportedHopCount;
|
: reportedHopCount;
|
||||||
|
|
||||||
final observedLabel = _formatObservedHops(
|
final observedLabel = _formatObservedHops(
|
||||||
observedHopCount,
|
observedHopCount,
|
||||||
@@ -77,8 +83,7 @@ class ChannelMessagePathScreen extends StatelessWidget {
|
|||||||
title: context.l10n.contacts_repeaterPathTrace,
|
title: context.l10n.contacts_repeaterPathTrace,
|
||||||
path: primaryPath,
|
path: primaryPath,
|
||||||
flipPathAround: true,
|
flipPathAround: true,
|
||||||
reversePathAround:
|
reversePathAround: false,
|
||||||
!(!channelMessage && !message.isOutgoing),
|
|
||||||
pathHashByteWidth: hashByteWidth,
|
pathHashByteWidth: hashByteWidth,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -226,7 +231,7 @@ class ChannelMessagePathScreen extends StatelessWidget {
|
|||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
hop.hasLocation
|
hop.hasLocation
|
||||||
? '${hop.position!.latitude.toStringAsFixed(5)}, '
|
? '${hop.position!.latitude.toStringAsFixed(5)}, '
|
||||||
'${hop.position!.longitude.toStringAsFixed(5)}'
|
'${hop.position!.longitude.toStringAsFixed(5)}'
|
||||||
: l10n.channelPath_noLocationData,
|
: l10n.channelPath_noLocationData,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -476,23 +481,17 @@ class _ChannelMessagePathMapScreenState
|
|||||||
widget.message.pathVariants,
|
widget.message.pathVariants,
|
||||||
);
|
);
|
||||||
final isDesktop = _isDesktopPlatform(defaultTargetPlatform);
|
final isDesktop = _isDesktopPlatform(defaultTargetPlatform);
|
||||||
final selectedPathTmp = _resolveSelectedPath(
|
final selectedPath = _resolveSelectedPath(
|
||||||
_selectedPath,
|
_selectedPath,
|
||||||
observedPaths,
|
observedPaths,
|
||||||
primaryPath,
|
primaryPath,
|
||||||
);
|
);
|
||||||
|
|
||||||
final selectedPath =
|
|
||||||
((!widget.message.isOutgoing && !widget.channelMessage) ||
|
|
||||||
(widget.message.isOutgoing && widget.channelMessage))
|
|
||||||
? Uint8List.fromList(selectedPathTmp.reversed.toList())
|
|
||||||
: selectedPathTmp;
|
|
||||||
|
|
||||||
final width =
|
final width =
|
||||||
(widget.message.pathHashWidth ?? connector.pathHashByteWidth)
|
(widget.message.pathHashWidth ?? connector.pathHashByteWidth)
|
||||||
.clamp(1, 4)
|
.clamp(1, 4)
|
||||||
.toInt();
|
.toInt();
|
||||||
final selectedIndex = _indexForPath(selectedPathTmp, observedPaths);
|
final selectedIndex = _indexForPath(selectedPath, observedPaths);
|
||||||
final hops = _buildPathHops(
|
final hops = _buildPathHops(
|
||||||
selectedPath,
|
selectedPath,
|
||||||
connector,
|
connector,
|
||||||
@@ -941,7 +940,10 @@ class _PathHop {
|
|||||||
|
|
||||||
String get displayLabel {
|
String get displayLabel {
|
||||||
final prefixLabel = hopBytes != null && hopBytes!.isNotEmpty
|
final prefixLabel = hopBytes != null && hopBytes!.isNotEmpty
|
||||||
? hopBytes!.map((b) => b.toRadixString(16).padLeft(2, '0')).join('').toUpperCase()
|
? hopBytes!
|
||||||
|
.map((b) => b.toRadixString(16).padLeft(2, '0'))
|
||||||
|
.join('')
|
||||||
|
.toUpperCase()
|
||||||
: _formatPrefix(prefix);
|
: _formatPrefix(prefix);
|
||||||
return '($prefixLabel) ${_resolveName(contact, l10n)}';
|
return '($prefixLabel) ${_resolveName(contact, l10n)}';
|
||||||
}
|
}
|
||||||
@@ -1070,9 +1072,10 @@ String _formatPrefix(int prefix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _formatPathPrefixes(Uint8List pathBytes, int hashByteWidth) {
|
String _formatPathPrefixes(Uint8List pathBytes, int hashByteWidth) {
|
||||||
return PathHelper.splitPathBytes(pathBytes, hashByteWidth)
|
return PathHelper.splitPathBytes(
|
||||||
.map(PathHelper.formatHopHex)
|
pathBytes,
|
||||||
.join(',');
|
hashByteWidth,
|
||||||
|
).map(PathHelper.formatHopHex).join(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
int _hopCountFromBytes(int byteCount, int hashByteWidth) {
|
int _hopCountFromBytes(int byteCount, int hashByteWidth) {
|
||||||
@@ -1081,7 +1084,11 @@ int _hopCountFromBytes(int byteCount, int hashByteWidth) {
|
|||||||
return (byteCount + width - 1) ~/ width;
|
return (byteCount + width - 1) ~/ width;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _formatHopCount(int byteCount, int hashByteWidth, AppLocalizations l10n) {
|
String _formatHopCount(
|
||||||
|
int byteCount,
|
||||||
|
int hashByteWidth,
|
||||||
|
AppLocalizations l10n,
|
||||||
|
) {
|
||||||
return l10n.chat_hopsCount(_hopCountFromBytes(byteCount, hashByteWidth));
|
return l10n.chat_hopsCount(_hopCountFromBytes(byteCount, hashByteWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user