From dee5e1cb9ee14cdcf592ce0e66d46723fa7fa4e8 Mon Sep 17 00:00:00 2001 From: maze Date: Tue, 10 Mar 2026 18:54:53 +0100 Subject: [PATCH] Fixed incorrect path hash parsing --- README.md | 11 ++++++++--- package.json | 2 +- src/packet.ts | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2695849..b4b90a5 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,15 @@ _Packet { routeType: 1, payloadVersion: 0, payloadType: 1, - pathHashCount: 1, - pathHashSize: 10, + pathHashCount: 10, + pathHashSize: 1, pathHashBytes: 10, - pathHashes: [ 'a50e2cb0336db67bbf78' ] + pathHashes: [ + 'a5', '0e', '2c', + 'b0', '33', '6d', + 'b6', '7b', 'bf', + '78' + ] } */ ``` diff --git a/package.json b/package.json index 8957f5a..a0ee468 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hamradio/meshcore", - "version": "1.1.2", + "version": "1.1.3", "description": "MeshCore protocol support for Typescript", "keywords": [ "MeshCore", diff --git a/src/packet.ts b/src/packet.ts index b8978fd..7533a52 100644 --- a/src/packet.ts +++ b/src/packet.ts @@ -52,13 +52,13 @@ export class Packet implements IPacket { this.payloadVersion = (header >> 6) & 0x03; this.payloadType = (header >> 2) & 0x0f; - this.pathHashCount = (pathLength >> 6) + 1; - this.pathHashSize = pathLength & 0x3f; + this.pathHashSize = (pathLength >> 6) + 1; + this.pathHashCount = pathLength & 0x3f; this.pathHashBytes = this.pathHashCount * this.pathHashSize; this.pathHashes = []; - for (let i = 0; i < this.pathHashCount; i++) { - const hashBytes = this.path.slice(i * this.pathHashSize, (i + 1) * this.pathHashSize); + for (let i = 0; i < this.pathHashBytes; i += this.pathHashSize) { + const hashBytes = this.path.slice(i, i + this.pathHashSize); const hashHex = bytesToHex(hashBytes); this.pathHashes.push(hashHex); }