createMessage(options: CreateMessageOptions): BaichuanMessage
Builds a request message, filling in the header from the options.
Class LEGACY gets the 12 dc encryption marker and the 20-byte header.
Class MODERN_WITH_OFFSET gets status 0 and a payload offset of the
extension's length, 0 without one.
Build the nonce request
Build the nonce request
import { assertEquals } from "@std/assert"; import { BAICHUAN_MESSAGE_CLASS } from "@hertzg/reolink-api/encoding/header"; import { BAICHUAN_CHANNEL, BAICHUAN_CMD, createMessage, } from "@hertzg/reolink-api/protocol/message"; const message = createMessage({ cmdId: BAICHUAN_CMD.LOGIN, channelId: BAICHUAN_CHANNEL.HOST, messageId: 1, messageClass: BAICHUAN_MESSAGE_CLASS.LEGACY, }); assertEquals(message.header.encryption, 0xdc12); assertEquals(message.header.payloadOffset, undefined);
options: CreateMessageOptions
The command, ids, class and encrypted body.
A message ready for the encode stream.