Implemented Packet structure decoding
This commit is contained in:
47
README.md
47
README.md
@@ -45,6 +45,53 @@ _Packet {
|
||||
*/
|
||||
```
|
||||
|
||||
## Packet structure parsing
|
||||
|
||||
The parser can also be instructed to generate a packet structure, useful for debugging or
|
||||
printing packet details:
|
||||
|
||||
```ts
|
||||
import { Packet } from '@hamradio/meshcore';
|
||||
|
||||
const raw = new Uint8Array(Buffer.from("050AA50E2CB0336DB67BBF78928A3BB9BF7A8B677C83B6EC0716F9DD10002A06", "hex"));
|
||||
const packet = Packet.fromBytes(raw);
|
||||
const { structure } = packet.decode(true);
|
||||
console.log(structure);
|
||||
|
||||
/*
|
||||
[
|
||||
{
|
||||
name: 'header',
|
||||
data: Uint8Array(12) [
|
||||
5, 10, 165, 14, 44,
|
||||
176, 51, 109, 182, 123,
|
||||
191, 120
|
||||
],
|
||||
fields: [
|
||||
{ name: 'flags', type: 0, size: 1, bits: [Array] },
|
||||
{ name: 'path length', type: 1, size: 1, bits: [Array] },
|
||||
{ name: 'path hashes', type: 6, size: 10 }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'response payload',
|
||||
data: Uint8Array(20) [
|
||||
146, 138, 59, 185, 191, 122,
|
||||
139, 103, 124, 131, 182, 236,
|
||||
7, 22, 249, 221, 16, 0,
|
||||
42, 6
|
||||
],
|
||||
fields: [
|
||||
{ name: 'destination hash', type: 1, size: 1, value: 146 },
|
||||
{ name: 'source hash', type: 1, size: 1, value: 138 },
|
||||
{ name: 'cipher MAC', type: 6, size: 2, value: [Uint8Array] },
|
||||
{ name: 'cipher text', type: 6, size: 16, value: [Uint8Array] }
|
||||
]
|
||||
}
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
## Identities
|
||||
|
||||
The package supports:
|
||||
|
||||
Reference in New Issue
Block a user