An ES module library and the camera-control command-line client for Camera
Control protocol version 4. It supports status, idempotent single capture, and
cancellable time-lapse operation over verified TLS. Status polling reconnects
with bounded exponential backoff when Wi-Fi or the server connection is
interrupted.
- Node.js 18.17 or newer
- Camera Control's TLS-only WebSocket API enabled and running
- The verified local CA certificate shown by the phone app
cd node
npm install
npm link # optional: puts `camera-control` on PATHSet the password without exposing it in process arguments:
export CAMERA_CONTROL_PASSWORD='your password'If this variable isn't present, the CLI prompts without echoing the password.
Read camera, device, capture-session, and reliability status:
node bin/camera-control.js status wss://192.168.1.50:8080/ws \
--ca camera-control-local-ca.crtCapture and save one JPEG through the idempotent job API:
node bin/camera-control.js capture wss://192.168.1.50:8080/ws \
--ca camera-control-local-ca.crt \
--camera 1 --resolution high --flash off \
--jpeg-quality 90 --rotation 90 --output photo.jpgRotation accepts 0, 90, 180, or 270 clockwise degrees. Omit the flag
to keep the current app setting; use --rotation 0 to reset it. The app starts
at 0°. Rotation applies to new photos and live previews; existing gallery
photos keep their orientation. Library callers pass "rotation": 90 in the
existing controls map. Check status.capabilities.rotation for support.
Start a 5-second time lapse, stopping after 20 photos:
node bin/camera-control.js time-lapse wss://192.168.1.50:8080/ws \
--ca camera-control-local-ca.crt \
--interval 5 --count 20Omit --count to run until Ctrl+C, or use --duration SECONDS. The client
polls session status, reconnects between polls, and requests server-side
cancellation when stopped.
import { writeFile } from 'node:fs/promises';
import { CameraControlClient, decodePhoto } from 'camera-control-client';
const camera = new CameraControlClient(
'wss://192.168.1.50:8080/ws',
process.env.CAMERA_CONTROL_PASSWORD,
'camera-control-local-ca.crt',
);
await camera.connect();
try {
console.log(await camera.status());
const job = await camera.captureJob({ requestId: 'document-page-42' });
await writeFile('photo.jpg', decodePhoto(job.result.photo));
} finally {
camera.close();
}captureJob retries reuse the same semantic requestId, allowing the running
app process to deduplicate an ambiguous reconnect. Do not deliberately reuse a
request ID with different capture settings. If the phone app itself restarts,
its in-memory idempotency history is lost; verify status before replaying an
ambiguous capture.
Download the CA from the URL shown by the app, then compare its SHA-256 fingerprint with the phone before trusting it:
curl --insecure --output camera-control-local-ca.crt \
https://192.168.1.50:8080/ca.crt
openssl x509 -in camera-control-local-ca.crt -noout -fingerprint -sha256--insecure is only for the initial CA download. The library passes the CA to
ws as the only trusted root, so certificate verification stays on.
Run tests with:
npm testSee ../api.md for the command and event summary.