Skip to content

Commit

Permalink
Add visitor to mqtt
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumEntangledAndy committed Jan 24, 2025
1 parent 13081f7 commit 72ca5e5
Show file tree
Hide file tree
Showing 17 changed files with 400 additions and 140 deletions.
25 changes: 3 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ Status Messages:
pir status
- `/status/motion` Contains the motion detection alarm status. `on` for motion
and `off` for still, only published when `enable_moton` is true in the config
- `/status/visitor` Contains the visitor detection status, which occurs when a
doorbell is pressed.
- `/status/ai` Contains the ai detection status, which occurs when a
the camera's internal ai detects something. The value is `person/car/other`
- `/status/ai/person` Contains the ai detection status of the last person,
which occurs when a the camera's internal ai detects a person.
- `/status/ai/car` Contains the ai detection status of the last car, which
occurs when a the camera's internal ai detects a car.
- `/status/ai/other` Contains the ai detection status from the camera, which
occurs when a the camera's internal ai detects something.

(This is a placeholder until I can fiquire out everything that the camera
can detect. If you have list for me please open an issue with it, I don't
have a cam with AI to check myself)
- `/status/ptz/preset` Sent in reply to a `/query/ptz/preset` an XML encoded
version of the PTZ presets
- `/status/preview` a base64 encoded camera image updated every 2s. Not
Expand Down Expand Up @@ -325,6 +339,14 @@ enable_motion = false # motion detection
# (limited battery drain since it
# is a passive listening connection)
#
enable_visitor = false # visitor press for doorbell camera
# (limited battery drain since it
# is a passive listening connection)
#
enable_ai = false # report detected ai by the camera
# (limited battery drain since it
# is a passive listening connection)
#
enable_light = false # flood lights only available on some camera
# (limited battery drain since it
# is a passive listening connection)
Expand Down
6 changes: 2 additions & 4 deletions crates/core/src/bc/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ fn bc_modern_msg<'a>(
E::add_context(input, ctx, E::from_error_kind(input, kind))
}

let ext_len = match header.payload_offset {
Some(off) => off,
_ => 0, // If missing payload_offset treat all as payload
};
// If missing payload_offset treat all as payload
let ext_len = header.payload_offset.unwrap_or_default();

let (buf, ext_buf) = take(ext_len)(buf)?;
let payload_len = header.body_len - ext_len;
Expand Down
9 changes: 1 addition & 8 deletions crates/core/src/bc/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ pub struct BcMeta {
/// When sending a command it is set to `0`. The reply from the camera can be
/// - `200` for OK
/// - `400` for bad request
///
/// A malformed packet will return a `400` code
pub response_code: u16,
/// A message ID is used to match replies with requests. The camera will parrot back
Expand All @@ -213,14 +214,6 @@ pub struct BcMeta {
pub class: u16,
}

/// The components of the Baichuan header that must be filled out after the body is serialized, or
/// is needed for the deserialization of the body (strictly part of the wire format of the message)
#[derive(Debug, PartialEq, Eq)]
pub(super) struct BcSendInfo {
pub body_len: u32,
pub payload_offset: Option<u32>,
}

#[derive(Debug)]
pub(crate) struct BcContext {
pub(crate) credentials: Credentials,
Expand Down
17 changes: 14 additions & 3 deletions crates/core/src/bc/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,18 +633,29 @@ pub struct AlarmEvent {
/// The channel the event occured on. Usually zero unless from an NVR
#[serde(rename = "channelId")]
pub channel_id: u8,
/// Motion status. Known values are `"MD"` or `"none"`
/// Motion status. Known values are `"MD"` or `"none"` or `"visitor"`
pub status: String,
/// AI status. Known values are `"people"` or `"none"`
#[serde(rename = "AItype", skip_serializing_if = "Option::is_none")]
pub ai_type: Option<String>,
#[serde(
rename = "AItype",
default = "ai_type_default",
skip_serializing_if = "ai_type_skip"
)]
pub ai_type: String,
/// The recording status. Known values `0` or `1`
pub recording: i32,
/// The timestamp associated with the recording. `0` if not recording
#[serde(rename = "timeStamp")]
pub timeStamp: i32,
}

fn ai_type_default() -> String {
"none".to_string()
}
fn ai_type_skip(value: &String) -> bool {
value == "none"
}

/// The Ptz messages used to move the camera
#[derive(PartialEq, Default, Debug, Deserialize, Serialize)]
pub struct PtzControl {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/bc_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub use credentials::*;
pub use errors::Error;
pub use ledstate::LightState;
pub use login::MaxEncryption;
pub use motion::{MotionData, MotionStatus};
pub use motion::{AiKind, MotionData, MotionEvents};
pub use pirstate::PirState;
pub use ptz::Direction;
pub use pushinfo::PhoneType;
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/bc_protocol/connection/bcsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub struct BcStream<'a> {
rx: &'a mut ReceiverStream<Result<Bc>>,
}

impl<'a> Unpin for BcStream<'a> {}
impl Unpin for BcStream<'_> {}

impl<'a> Stream for BcStream<'a> {
impl Stream for BcStream<'_> {
type Item = Result<Bc>;

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bc>>> {
Expand Down
Loading

0 comments on commit 72ca5e5

Please sign in to comment.