Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eefe3dfa71 | ||
|
|
6e8fc3ee5b | ||
|
|
17e8ab0f37 | ||
|
|
0d2f0c3e6f |
No files matched your search
Generated
+1
-1
@@ -1425,7 +1425,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "neolink"
|
||||
version = "0.5.16"
|
||||
version = "0.5.17"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.21.2",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "neolink"
|
||||
description = "A standards-compliant bridge to Reolink IP cameras"
|
||||
version = "0.5.16"
|
||||
version = "0.5.17"
|
||||
authors = ["George Hilliard <thirtythreeforty@gmail.com>", "Andrew King <sheepchaan@gmail.com>"]
|
||||
edition = "2018"
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
@@ -564,6 +564,9 @@ pub struct AlarmEvent {
|
||||
pub channel_id: u8,
|
||||
/// Motion status. Known values are `"MD"` or `"none"`
|
||||
pub status: String,
|
||||
/// AI status. Known values are `"people"` or `"none"`
|
||||
#[yaserde(rename = "AItype")]
|
||||
pub ai_type: Option<String>,
|
||||
/// The recording status. Known values `0` or `1`
|
||||
pub recording: i32,
|
||||
/// The timestamp associated with the recording. `0` if not recording
|
||||
|
||||
@@ -85,8 +85,6 @@ pub struct BcCameraOpt {
|
||||
pub protocol: ConnectionProtocol,
|
||||
/// Discovery method to allow
|
||||
pub discovery: DiscoveryMethods,
|
||||
/// Printing format for auxilaary data such as battery levels
|
||||
pub aux_printing: PrintFormat,
|
||||
/// Credentials for login
|
||||
pub credentials: Credentials,
|
||||
}
|
||||
@@ -343,9 +341,6 @@ impl BcCamera {
|
||||
abilities: Default::default(),
|
||||
};
|
||||
me.keepalive().await?;
|
||||
if let Err(e) = me.monitor_battery(options.aux_printing).await {
|
||||
warn!("Could not monitor battery: {:?}", e);
|
||||
}
|
||||
Ok(me)
|
||||
}
|
||||
|
||||
|
||||
@@ -232,10 +232,16 @@ impl BcCamera {
|
||||
let mut result = MotionStatus::NoChange(Instant::now());
|
||||
for alarm_event in &alarm_event_list.alarm_events {
|
||||
if alarm_event.channel_id == channel_id {
|
||||
if alarm_event.status == "MD" {
|
||||
if alarm_event.status != "none"
|
||||
|| alarm_event
|
||||
.ai_type
|
||||
.as_ref()
|
||||
.map(|ai_type| ai_type != "none")
|
||||
.unwrap_or(false)
|
||||
{
|
||||
result = MotionStatus::Start(Instant::now());
|
||||
break;
|
||||
} else if alarm_event.status == "none" {
|
||||
} else {
|
||||
result = MotionStatus::Stop(Instant::now());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
use clap::Parser;
|
||||
|
||||
/// The battery command will dump the battery status to XML
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct Opt {
|
||||
/// The name of the camera. Must be a name in the config
|
||||
pub camera: String,
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
///
|
||||
/// # Neolink Battery
|
||||
///
|
||||
/// This module handles the printing of the Battery status
|
||||
/// in xml format
|
||||
///
|
||||
/// # Usage
|
||||
///
|
||||
/// ```bash
|
||||
/// neolink battery --config=config.toml CameraName
|
||||
/// ```
|
||||
///
|
||||
use anyhow::{Context, Result};
|
||||
|
||||
mod cmdline;
|
||||
|
||||
use super::config::Config;
|
||||
use crate::utils::find_and_connect;
|
||||
pub(crate) use cmdline::Opt;
|
||||
|
||||
/// Entry point for the battery subcommand
|
||||
///
|
||||
/// Opt is the command line options
|
||||
pub(crate) async fn main(opt: Opt, config: Config) -> Result<()> {
|
||||
let camera = find_and_connect(&config, &opt.camera).await?;
|
||||
|
||||
let state = camera
|
||||
.battery_info()
|
||||
.await
|
||||
.context("Unable to get camera Battery state")?;
|
||||
let ser = String::from_utf8(
|
||||
yaserde::ser::serialize_with_writer(&state, vec![], &Default::default())
|
||||
.expect("Should Ser the struct"),
|
||||
)
|
||||
.expect("Should be UTF8");
|
||||
println!("{}", ser);
|
||||
|
||||
let _ = camera.logout().await;
|
||||
camera.disconnect().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -25,4 +25,5 @@ pub enum Command {
|
||||
Talk(super::talk::Opt),
|
||||
Mqtt(super::mqtt::Opt),
|
||||
Image(super::image::Opt),
|
||||
Battery(super::battery::Opt),
|
||||
}
|
||||
@@ -29,6 +29,7 @@ use log::*;
|
||||
use std::fs;
|
||||
use validator::Validate;
|
||||
|
||||
mod battery;
|
||||
mod cmdline;
|
||||
mod config;
|
||||
mod image;
|
||||
@@ -115,6 +116,9 @@ async fn main() -> Result<()> {
|
||||
Some(Command::Image(opts)) => {
|
||||
image::main(opts, config).await?;
|
||||
}
|
||||
Some(Command::Battery(opts)) => {
|
||||
battery::main(opts, config).await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -198,6 +198,10 @@ impl EventCamThread {
|
||||
.context("Failed to login to the camera")??;
|
||||
info!("{}: Connected and logged in", camera_config.name);
|
||||
|
||||
if let Err(e) = camera.monitor_battery(camera_config.print_format).await {
|
||||
warn!("Could not monitor battery: {:?}", e);
|
||||
}
|
||||
|
||||
self.tx.send(Messages::Login).await?;
|
||||
|
||||
// Shararble cameras
|
||||
|
||||
@@ -44,5 +44,9 @@ pub(crate) async fn main(opt: Opt, config: Config) -> Result<()> {
|
||||
.expect("Should be UTF8");
|
||||
println!("{}", pir_ser);
|
||||
}
|
||||
|
||||
let _ = camera.logout().await;
|
||||
camera.disconnect().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -90,5 +90,9 @@ pub(crate) async fn main(opt: Opt, config: Config) -> Result<()> {
|
||||
.context("Unable to execute PTZ move command")?;
|
||||
}
|
||||
};
|
||||
|
||||
let _ = camera.logout().await;
|
||||
camera.disconnect().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -29,5 +29,8 @@ pub(crate) async fn main(opt: Opt, config: Config) -> Result<()> {
|
||||
.reboot()
|
||||
.await
|
||||
.context("Could not send reboot command to the camera")?;
|
||||
|
||||
camera.disconnect().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -30,6 +30,16 @@ impl Camera<Connected> {
|
||||
};
|
||||
|
||||
timeout(self.state.camera.login_with_maxenc(max_encryption)).await??;
|
||||
|
||||
if let Err(e) = self
|
||||
.state
|
||||
.camera
|
||||
.monitor_battery(self.shared.config.print_format)
|
||||
.await
|
||||
{
|
||||
log::warn!("Could not monitor battery: {:?}", e);
|
||||
}
|
||||
|
||||
Ok(Camera {
|
||||
shared: self.shared,
|
||||
state: LoggedIn {
|
||||
|
||||
@@ -33,5 +33,9 @@ pub(crate) async fn main(opt: Opt, config: Config) -> Result<()> {
|
||||
.led_light_set(opt.on)
|
||||
.await
|
||||
.context("Unable to set camera light state")?;
|
||||
|
||||
let _ = camera.logout().await;
|
||||
camera.disconnect().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -86,5 +86,8 @@ pub(crate) async fn main(opt: Opt, config: Config) -> Result<()> {
|
||||
.await
|
||||
.context("Talk stream ended early")?;
|
||||
|
||||
let _ = camera.logout().await;
|
||||
camera.disconnect().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -93,7 +93,6 @@ impl AddressOrUid {
|
||||
uid: camera_config.camera_uid.clone(),
|
||||
protocol: ConnectionProtocol::TcpUdp,
|
||||
discovery: camera_config.discovery,
|
||||
aux_printing: camera_config.print_format,
|
||||
credentials: Credentials {
|
||||
username: camera_config.username.clone(),
|
||||
password: camera_config.password.clone(),
|
||||
|
||||
Reference in new issue
Block a user