function xmlParam
xmlParam<N extends string, F extends XmlFields>(
name: N,
fields: F
): XmlParam<N, XmlFieldsValue<F>>

Describes a parameter element and its fields.

Examples

Describe the PTZ serial settings pushed as cmd 79

import { assertEquals } from "@std/assert";
import { parse } from "@std/xml";
import { int, oneOf, text, xmlParam } from "@hertzg/reolink-api/protocol/xml";

const serial = xmlParam("Serial", {
  channelId: int(),
  baudRate: int(),
  parity: oneOf("none", "odd", "even"),
  controlProtocol: text(),
});

const root = parse(
  '<Serial version="1.1"><channelId>0</channelId><baudRate>9600</baudRate>' +
    "<parity>none</parity><controlProtocol>PELCO_D</controlProtocol></Serial>",
).root;

assertEquals(serial.decode(root), {
  channelId: 0,
  baudRate: 9600,
  parity: "none",
  controlProtocol: "PELCO_D",
});

Type Parameters

N extends string
F extends XmlFields

Parameters

name: N

The element name, exactly as the firmware writes it.

fields: F

The field codecs, in the firmware's serializer order.

Return Type

The parameter codec.

Usage

import { xmlParam } from "protocol/xml.ts";