function encodeCommandBody
encodeCommandBody<C extends Command>(
command: C,
body: CommandBody<C>
): string

Writes a command body as XML. Parameters missing from body are left out; an empty body gives an empty string, which the firmware treats as "use the current values" rather than as an empty <body/>.

Examples

An empty body stays empty

import { assertEquals } from "@std/assert";
import { command, encodeCommandBody } from "@hertzg/reolink-api/protocol/command";

assertEquals(encodeCommandBody(command(23, "REBOOT_V20", []), {}), "");

Type Parameters

C extends Command

Parameters

command: C

The command whose parameters to write.

The parameter values, by element name.

Return Type

string

The body XML, or "" when no parameter is given.

Usage

import { encodeCommandBody } from "protocol/command.ts";