Fixed incorrect path hash parsing
This commit is contained in:
11
README.md
11
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'
|
||||
]
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hamradio/meshcore",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"description": "MeshCore protocol support for Typescript",
|
||||
"keywords": [
|
||||
"MeshCore",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user