Add Baichuan fallback for GetOsd/SetOsd - #183
Open
andrewvenson wants to merge 2 commits into
Open
Conversation
…ings map to Baichuan topLeftX/topLeftY via OSD_POS_HTTP_TO_BC, derived empirically by cycling all 6 HTTP OSD positions and reading back the resulting coordinates over Baichuan.
Populate _osd_settings from the Baichuan XML response and add a Baichuan SetOsd command so Host.set_osd() also works when bc_only=True (no HTTP(s)API available). OSD positions are exposed over Baichuan as raw topLeftX/topLeftY coordinates instead of the HTTP API's named positions ("Upper Left", "Bottom Center", etc), so OSD_POS_HTTP_TO_BC/ OSD_POS_BC_TO_HTTP translate between the two. The coordinate mapping was derived empirically by cycling all 6 HTTP OSD positions and reading back the resulting Baichuan coordinates, and confirmed to match across two different device types (Reolink E1 Pro, Reolink Video Doorbell Wifi).
Owner
|
Why do you need this fallback? |
Author
The hope is to limit the amount of attack vectors on my network. I would rather use the baicuan protocol to update settings on my cameras rather than temporarily opening up http/s ports to make changes. Sometimes after power outages the osd settings are erased. I have a cron that targets this branch to set the osd on the cams on a daily basis. |
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
GetOsd/SetOsdsoHost.set_osd()also works on devices that are only reachable over the Baichuan protocol (bc_only=True, i.e. no HTTP(s) API available).GetOsdnow decodes the Baichuan XML response into the same_osd_settings[channel]shape the HTTP JSON API produces, soHost.set_osd()itself needed no changes — it works transparently regardless of which protocol is in use underneath.SetOsdBaichuan command (cmd_id 45) that fetches the current OSD XML (cmd_id 44), patches only the fields being changed, and writes it back.Position encoding
The HTTP JSON API expresses OSD position as a string (
"Upper Left","Bottom Center", etc, seevalidate_osd_pos), but Baichuan expresses it as rawtopLeftX/topLeftYintegers. There's no official documentation for this encoding, so I derived it empirically by cycling through all 6 HTTP positions and reading back the resulting Baichuan XML values:Confirmed identical across two different device types:
v3.1.0.4417_2412122130)v3.0.0.4662_2508071282)Usage
No API changes required — existing code works unmodified, including on
bc_onlyhosts:Testing
bc_only=True: enable/disable, name text, position, and watermark toggle all round-trip correctly and were cross-checked against the raw Baichuan XML readback.black,isort,flake8, andpylint(10.00/10) all pass on the changed file;mypyreports no issues.