Fix PTZ preset list parsing by making Preset.command optional (#326)#406
Open
Tahutipai wants to merge 1 commit into
Open
Fix PTZ preset list parsing by making Preset.command optional (#326)#406Tahutipai wants to merge 1 commit into
Tahutipai wants to merge 1 commit into
Conversation
…ntangledAndy#326) This commit fixes the issue where the camera would not move to saved PTZ preset positions. Every PTZ preset command was causing a connection loss and reconnect loop, so the pan/tilt command never actually reached the camera. Root cause: the camera's reply to `/query/ptz/preset` lists saved presets with `<id>`, `<name>`, and `<imageName>` only — no `<command>` element. Deserializing this response into the `Preset` struct fails with `Custom("missing field \`command\`")`, which is escalated to `Unable to parse Payload XML`, triggering the reconnect loop. Reproduced on Reolink E1 (basic) with firmware v3.2.0.4858_2508273531, and previously reported on Reolink Argus PT Ultra in QuantumEntangledAndy#326. `command` is still required for the outbound `setPos` / `toPos` requests, so the field stays on the struct. Using `#[serde(default)]` lets it default to an empty string on deserialization and `skip_serializing_if = "String::is_empty"` keeps serialization clean when unset. Same approach used for other optional fields in this file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #326. The camera's reply to
/query/ptz/presetlists saved presets with<id>,<name>, and<imageName>only — it does not include a<command>element. The currentPresetstruct treatscommandas a required field, so deserialization fails withCustom("missing field \command`"). This error cascades toUnable to parse Payload XML`, causes the camera thread to reconnect, and the ongoing PTZ command is lost. The net effect is that PTZ preset calls silently fail: the camera never moves, and the logs fill with reconnect spam.The fix makes
commanddefault to an empty string on deserialization (#[serde(default)]) while still serializing cleanly for outboundsetPos/toPosrequests (skip_serializing_if = "String::is_empty").Root cause
XML returned by the camera for
/query/ptz/preset:Current struct (
crates/core/src/bc/xml.rs):Same
commandfield is still required when neolink sendssetPos/toPoscommands to the camera — those paths are unaffected.Reproduced on
v3.2.0.4858_2508273531v3.0.0.3492_24050816Test plan
cargo build --release)missing field \command`` errors or reconnect loopsmqtt-rtspmode)