QuantumEntangledAndy / neolink

An RTSP bridge to Reolink IP cameras
GNU Affero General Public License v3.0
322 stars 44 forks source link

Battery message and requests #42

Closed QuantumEntangledAndy closed 1 year ago

QuantumEntangledAndy commented 1 year ago

This adds two battery commands.

One registers neolink camera to listen for battery messages from the camera. This is registeration is always done by default. Neolink will listen for these messages and print log messages when they are recieved. The camera appears to send them one certain events occur such as when charge status changes.

Two a command to request current battery info from the camera.

dkerr64 commented 1 year ago

I get a panic when parsing battery info. I am guessing it's because the "current" field is a negative number?

See further comments in #41

[2023-03-01T13:19:21Z DEBUG neolink_core::bc::xml] Struct: start to parse "body"
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched StartElement(body, {"": "", "xml": "http://www.w3.org/XML/1998/namespace", "xmlns": "http://www.w3.org/2000/xmlns/"})
[2023-03-01T13:19:21Z DEBUG neolink_core::bc::xml] Struct: start to parse "BatteryList"
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched StartElement(BatteryList, {"": "", "xml": "http://www.w3.org/XML/1998/namespace", "xmlns": "http://www.w3.org/2000/xmlns/"}, [version -> 1.1])
[2023-03-01T13:19:21Z DEBUG neolink_core::bc::xml] Struct: start to parse "BatteryInfo"
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched StartElement(BatteryInfo, {"": "", "xml": "http://www.w3.org/XML/1998/namespace", "xmlns": "http://www.w3.org/2000/xmlns/"})
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched StartElement(channelId, {"": "", "xml": "http://www.w3.org/XML/1998/namespace", "xmlns": "http://www.w3.org/2000/xmlns/"})
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched Characters(0)
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched EndElement(channelId)
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched StartElement(chargeStatus, {"": "", "xml": "http://www.w3.org/XML/1998/namespace", "xmlns": "http://www.w3.org/2000/xmlns/"})
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched Characters(none)
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched EndElement(chargeStatus)
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched StartElement(adapterStatus, {"": "", "xml": "http://www.w3.org/XML/1998/namespace", "xmlns": "http://www.w3.org/2000/xmlns/"})
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched Characters(none)
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched EndElement(adapterStatus)
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched StartElement(voltage, {"": "", "xml": "http://www.w3.org/XML/1998/namespace", "xmlns": "http://www.w3.org/2000/xmlns/"})
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched Characters(4029)
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched EndElement(voltage)
[2023-03-01T13:19:21Z DEBUG yaserde::de] Fetched StartElement(current, {"": "", "xml": "http://www.w3.org/XML/1998/namespace", "xmlns": "http://www.w3.org/2000/xmlns/"})
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', crates/core/src/bc/xml.rs:485:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace