baichuanHeader(): Coder<BaichuanHeader>
Creates a coder for a BaichuanHeader.
headerLength of messageClass picks the layout: 24-byte headers
decode to status and payloadOffset, 20-byte ones to encryption.
Encoding expects the fields that match the class. Decoding throws when the
first four bytes are not the magic, encoding always writes it.
Decode a 24-byte reply header
Decode a 24-byte reply header
import { assertEquals } from "@std/assert"; import { decodeHex } from "@std/encoding/hex"; import { baichuanHeader } from "@hertzg/reolink-api/encoding/header"; const [header, bytesRead] = baichuanHeader().decode( decodeHex("f0debc0a1f00000000000000fb030000c800146400000000"), ); assertEquals(header.cmdId, 31); assertEquals(header.status, 200); assertEquals(bytesRead, 24);
Coder<BaichuanHeader>
A coder for a BaichuanHeader.