Fixed incorrect path hash parsing
This commit is contained in:
11
README.md
11
README.md
@@ -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'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user