mirror of
https://github.com/jwetzell/acn-js.git
synced 2026-08-12 02:03:42 +00:00
rlp header should be hex string
This commit is contained in:
@@ -16,6 +16,6 @@ export type ACNPacket<PreambleType, PDUBlockType, PostambleType> = {
|
||||
|
||||
export type RootLayerPDU = {
|
||||
vector: number;
|
||||
header: Uint8Array;
|
||||
header: string;
|
||||
data: Uint8Array;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { RootLayerPDU } from '../models';
|
||||
import { toHex } from '../utils';
|
||||
|
||||
function decode(bytes: Uint8Array): RootLayerPDU {
|
||||
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||
@@ -43,7 +44,8 @@ function decode(bytes: Uint8Array): RootLayerPDU {
|
||||
const vector = view.getUint32(vectorOffset);
|
||||
const headerOffset = vectorOffset + 4;
|
||||
|
||||
const header = bytes.subarray(headerOffset, headerOffset + 16);
|
||||
const header = toHex(bytes.subarray(headerOffset, headerOffset + 16));
|
||||
|
||||
const dataOffset = headerOffset + 16;
|
||||
// NOTE(jwetzell): flags/lengthH + lengthL + lengthX + vector + header
|
||||
const dataLength = length - (1 + 1 + (lengthFlag ? 1 : 0) + 4 + 16);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export function toHex(bytes: Uint8Array): string{
|
||||
let hex = '';
|
||||
bytes.forEach((byte)=>{
|
||||
hex += byte.toString(16).padStart(2,'0')
|
||||
})
|
||||
return hex;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ const goodTests = [
|
||||
},
|
||||
pduBlock: {
|
||||
vector: 1,
|
||||
header: new Uint8Array([176, 171, 216, 42, 32, 210, 66, 64, 167, 205, 62, 73, 217, 153, 164, 229]),
|
||||
header: 'b0abd82a20d24240a7cd3e49d999a4e5',
|
||||
data: new Uint8Array([
|
||||
112, 50, 4, 73, 136, 131, 52, 255, 255, 74, 69, 176, 66, 102, 183, 33, 235, 216, 155, 0, 1, 244, 136, 0, 0, 0,
|
||||
0, 244, 136, 0, 0, 244, 136, 1, 67, 216, 239, 192, 220, 207, 5, 0, 0, 2, 0, 10, 0, 20, 1, 44,
|
||||
|
||||
Reference in New Issue
Block a user