Fixed incorrect path hash parsing

This commit is contained in:
2026-03-10 18:54:53 +01:00
parent e388a55575
commit dee5e1cb9e
3 changed files with 13 additions and 8 deletions

View File

@@ -32,10 +32,15 @@ _Packet {
routeType: 1, routeType: 1,
payloadVersion: 0, payloadVersion: 0,
payloadType: 1, payloadType: 1,
pathHashCount: 1, pathHashCount: 10,
pathHashSize: 10, pathHashSize: 1,
pathHashBytes: 10, pathHashBytes: 10,
pathHashes: [ 'a50e2cb0336db67bbf78' ] pathHashes: [
'a5', '0e', '2c',
'b0', '33', '6d',
'b6', '7b', 'bf',
'78'
]
} }
*/ */
``` ```

View File

@@ -1,6 +1,6 @@
{ {
"name": "@hamradio/meshcore", "name": "@hamradio/meshcore",
"version": "1.1.2", "version": "1.1.3",
"description": "MeshCore protocol support for Typescript", "description": "MeshCore protocol support for Typescript",
"keywords": [ "keywords": [
"MeshCore", "MeshCore",

View File

@@ -52,13 +52,13 @@ export class Packet implements IPacket {
this.payloadVersion = (header >> 6) & 0x03; this.payloadVersion = (header >> 6) & 0x03;
this.payloadType = (header >> 2) & 0x0f; this.payloadType = (header >> 2) & 0x0f;
this.pathHashCount = (pathLength >> 6) + 1; this.pathHashSize = (pathLength >> 6) + 1;
this.pathHashSize = pathLength & 0x3f; this.pathHashCount = pathLength & 0x3f;
this.pathHashBytes = this.pathHashCount * this.pathHashSize; this.pathHashBytes = this.pathHashCount * this.pathHashSize;
this.pathHashes = []; this.pathHashes = [];
for (let i = 0; i < this.pathHashCount; i++) { for (let i = 0; i < this.pathHashBytes; i += this.pathHashSize) {
const hashBytes = this.path.slice(i * this.pathHashSize, (i + 1) * this.pathHashSize); const hashBytes = this.path.slice(i, i + this.pathHashSize);
const hashHex = bytesToHex(hashBytes); const hashHex = bytesToHex(hashBytes);
this.pathHashes.push(hashHex); this.pathHashes.push(hashHex);
} }