PTZ (pan, tilt, zoom) requests.

cmd 18,  ptzControlXml  ->  empty status-200 reply; moves until "Stop"
cmd 19,  ptzPresetXml   ->  empty status-200 reply
cmd 190, no body        ->  <PtzPreset><presetList><preset>...</preset>
cmd 433, no body        ->  <ptzCurPos><pPos>...</pPos><tPos>...</tPos>

Cameras that push no PTZ state can only tell a move has finished by polling cmd 433 until the position stops changing.

All three address the channel through the message extension.

Examples

Pan left, then stop

import { assertStringIncludes } from "@std/assert";
import { PTZ_COMMAND, ptzControlXml } from "@hertzg/reolink-api/protocol/ptz";

assertStringIncludes(
  ptzControlXml({ channel: 0, command: PTZ_COMMAND.LEFT, speed: 32 }),
  "<command>Left</command>",
);
assertStringIncludes(
  ptzControlXml({ channel: 0, command: PTZ_COMMAND.STOP }),
  "<command>Stop</command>",
);

Functions

f
parsePtzPosition(xml: string): PtzPosition

Reads the current position from the reply to a cmd 433 request.

f
parsePtzPresets(xml: string): PtzPreset[]

Reads the saved presets from the reply to a cmd 190 request.

f
ptzControlXml(request: PtzControlRequest): string

Builds the body of a PTZ move (cmd 18).

f
ptzPresetXml(request: { channel: number; id: number; }): string

Builds the body of a request that moves to a saved preset (cmd 19).

Type Aliases

T
PtzControlRequest = { channel: number; command: PtzCommand; speed?: number; }

What ptzControlXml asks the camera to do.

T
PtzPosition = { pan: number; tilt: number; }

Where the camera points, in the camera's own motor units.

T
PtzPreset = { id: number; name: string; }

A saved PTZ position.

Variables