la_mojo cameras: track PTZ health and re-initialise a failed PTZ protocol #14

Merged
ClaudeAI merged 1 commits from feature/camera-ptz-health into master 20 minutes ago
Collaborator

Summary

Each camera now tracks the health of its PTZ control. The PTZ status bit sent to the remote server reflects that health, and a failed PTZ protocol is re-initialised automatically.

Depends on #13 (pOnvif compliance), which this branch contains. Merge #13 first; this PR then shows only its own commit.

PTZ health (deviceNodeCamera)

  • PTZ_HEALTH_INFO holds:

    • the state (NONE / INIT / OK / FAILED);
    • failure and recovery counters, and consecutive failed initialisations;
    • the times of the last state change and the last failure, and the next retry;
    • the text of the last error.

    getPtzHealth() returns a copy and is safe to call from any thread.

  • getPtzStatus() is already sent to the server as CAMERA_STATUS_PTZ_OK. It now returns 1 only when PTZ is OK, or when the camera has no PTZ protocol. Before, it returned 1 as soon as the state machine left CAM_WS_INIT.

Detection and re-initialisation

  • While idle (CAM_WS_READY):
    • validate() is checked on every loop;
    • the new protocolPTZ::probe() runs every 30 s. For ONVIF it is a GetStatus request: a SOAP Fault still means reachable, and only a communication error marks the camera lost.
  • On failure the PTZ protocol is recreated through CAM_WS_INIT. The first attempt is immediate, then the delay is 5, 10, 20, 40 and 60 s (capped). Before, a failed start-up was retried in a tight loop.
  • A failed target-driven goAbsolute/goPreset no longer ends the camera thread (CAM_WS_END used to rebuild the whole node):
    • ONVIF with the connection still OK: the camera rejected the command, so only that ROI is dropped;
    • anything else: the PTZ protocol is re-initialised.
  • Serial protocols (Pelco, VISCA): the default probe() is the protocol's own validate(), so they cannot detect a lost connection. A failed move re-initialises the protocol instead of rebuilding the node.

Testing

  • g++ -fsyntax-only on the changed files and the users of getPtzStatus(): no new warnings.
  • ONVIF probe() and re-initialisation against the simulated camera:
    • camera up: the probe succeeds;
    • camera gone: the probe fails and validate() is false;
    • re-init while the camera is down: create() fails;
    • re-init once the camera is back: create() and the probe succeed.
  • Not run: the camera state machine (backoff, state changes, status bit) needs the database. On the device:
    • disconnect a camera from the network;
    • check the PTZ FAILED and PTZ recovered log lines;
    • check the PTZ bit in the server status.

Generated with Claude Code

https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16

## Summary Each camera now tracks the health of its PTZ control. The PTZ status bit sent to the remote server reflects that health, and a failed PTZ protocol is re-initialised automatically. **Depends on #13** (pOnvif compliance), which this branch contains. Merge #13 first; this PR then shows only its own commit. ## PTZ health (`deviceNodeCamera`) - **`PTZ_HEALTH_INFO`** holds: - the state (`NONE` / `INIT` / `OK` / `FAILED`); - failure and recovery counters, and consecutive failed initialisations; - the times of the last state change and the last failure, and the next retry; - the text of the last error. `getPtzHealth()` returns a copy and is safe to call from any thread. - **`getPtzStatus()`** is already sent to the server as `CAMERA_STATUS_PTZ_OK`. It now returns 1 only when PTZ is OK, or when the camera has no PTZ protocol. Before, it returned 1 as soon as the state machine left `CAM_WS_INIT`. ## Detection and re-initialisation - **While idle** (`CAM_WS_READY`): - `validate()` is checked on every loop; - the new `protocolPTZ::probe()` runs every 30 s. For ONVIF it is a GetStatus request: a SOAP Fault still means reachable, and only a communication error marks the camera lost. - **On failure** the PTZ protocol is recreated through `CAM_WS_INIT`. The first attempt is immediate, then the delay is 5, 10, 20, 40 and 60 s (capped). Before, a failed start-up was retried in a tight loop. - **A failed target-driven goAbsolute/goPreset** no longer ends the camera thread (`CAM_WS_END` used to rebuild the whole node): - ONVIF with the connection still OK: the camera rejected the command, so only that ROI is dropped; - anything else: the PTZ protocol is re-initialised. - **Serial protocols (Pelco, VISCA):** the default `probe()` is the protocol's own `validate()`, so they cannot detect a lost connection. A failed move re-initialises the protocol instead of rebuilding the node. ## Testing - `g++ -fsyntax-only` on the changed files and the users of `getPtzStatus()`: no new warnings. - ONVIF `probe()` and re-initialisation against the simulated camera: - camera up: the probe succeeds; - camera gone: the probe fails and `validate()` is false; - re-init while the camera is down: `create()` fails; - re-init once the camera is back: `create()` and the probe succeed. - **Not run:** the camera state machine (backoff, state changes, status bit) needs the database. On the device: - disconnect a camera from the network; - check the `PTZ FAILED` and `PTZ recovered` log lines; - check the PTZ bit in the server status. Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
ClaudeAI added 2 commits 23 minutes ago
3d4a1f243d
la_mojo pOnvif: ONVIF compliance fixes (report points 1-6)
926b077b93
la_mojo cameras: track PTZ health and re-initialise a failed PTZ protocol
ClaudeAI merged commit d1f3d8f57a into master 20 minutes ago
The pull request has been merged as d1f3d8f57a.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.