mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-11 19:17:04 +10:00
fix from copilot review + doc fix
This commit is contained in:
@@ -15,6 +15,7 @@ The device capability determines the hash width (number of bytes per hop):
|
|||||||
| 1 byte | 256 | Single-byte node IDs |
|
| 1 byte | 256 | Single-byte node IDs |
|
||||||
| 2 bytes | 65,536 | Medium meshes |
|
| 2 bytes | 65,536 | Medium meshes |
|
||||||
| 3 bytes | 16.7M | Large networks |
|
| 3 bytes | 16.7M | Large networks |
|
||||||
|
| 4 bytes | 4.3G | Very large meshes / future-proofing |
|
||||||
|
|
||||||
### Device Capability Detection
|
### Device Capability Detection
|
||||||
|
|
||||||
@@ -25,11 +26,11 @@ On device connection, the app reads the firmware capability to set `pathHashByte
|
|||||||
final modeRaw = firmwareBytes.length >= 82
|
final modeRaw = firmwareBytes.length >= 82
|
||||||
? (firmwareBytes[81] & 0xFF)
|
? (firmwareBytes[81] & 0xFF)
|
||||||
: 0;
|
: 0;
|
||||||
final mode = modeRaw.clamp(0, 2);
|
final mode = modeRaw.clamp(0, 3);
|
||||||
_pathHashByteWidth = mode + 1; // 1, 2, or 3 bytes per hop
|
_pathHashByteWidth = mode + 1; // 1, 2, 3, or 4 bytes per hop
|
||||||
```
|
```
|
||||||
|
|
||||||
The current implementation intentionally clamps to modes `0..2`, so the supported hop width is `1..3` bytes. Do not document 4-byte hops unless the connector implementation is widened first.
|
The connector reads a single-mode byte and clamps to `0..3`, so the supported hop width is `1..4` bytes. UI code also clamps widths when rendering (typically to `1..4`) so 4-byte hops are handled end-to-end in the current codebase.
|
||||||
|
|
||||||
### Path Data Structure
|
### Path Data Structure
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class PathHelper {
|
|||||||
/// - 1: Single byte per hop (256 unique nodes)
|
/// - 1: Single byte per hop (256 unique nodes)
|
||||||
/// - 2: Two bytes per hop (65K unique nodes)
|
/// - 2: Two bytes per hop (65K unique nodes)
|
||||||
/// - 3: Three bytes per hop (16M unique nodes)
|
/// - 3: Three bytes per hop (16M unique nodes)
|
||||||
|
/// - 4: Four bytes per hop (4.3G unique nodes)
|
||||||
static String resolvePathNames(
|
static String resolvePathNames(
|
||||||
List<int> pathBytes,
|
List<int> pathBytes,
|
||||||
List<Contact> allContacts,
|
List<Contact> allContacts,
|
||||||
|
|||||||
@@ -47,14 +47,12 @@ class ChannelMessagePathScreen extends StatelessWidget {
|
|||||||
final hops = _buildPathHops(primaryPath, connector, l10n, hashByteWidth);
|
final hops = _buildPathHops(primaryPath, connector, l10n, hashByteWidth);
|
||||||
final hasHopDetails = primaryPath.isNotEmpty;
|
final hasHopDetails = primaryPath.isNotEmpty;
|
||||||
|
|
||||||
// Convert 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
|
||||||
|
// the negative flood sentinel when present.
|
||||||
final observedHopCount = _hopCountFromBytes(primaryPath.length, hashByteWidth);
|
final observedHopCount = _hopCountFromBytes(primaryPath.length, hashByteWidth);
|
||||||
final reportedHopCount = message.pathLength == null
|
final reportedHopCount = message.pathLength;
|
||||||
? null
|
|
||||||
: (message.pathLength! < 0
|
|
||||||
? message.pathLength
|
|
||||||
: _hopCountFromBytes(message.pathLength!, hashByteWidth));
|
|
||||||
final effectiveHopCount = observedHopCount > 0
|
final effectiveHopCount = observedHopCount > 0
|
||||||
? observedHopCount
|
? observedHopCount
|
||||||
: reportedHopCount;
|
: reportedHopCount;
|
||||||
|
|||||||
Reference in New Issue
Block a user