Compare commits

..
Author SHA1 Message Date
QuantumEntangledAndy 5cec02e3c2 Use a central UID system for push notifications 2023-10-29 17:24:21 +07:00
QuantumEntangledAndy 4a94a2ddb2 README.md 2023-10-28 12:20:11 +07:00
QuantumEntangledAndy 459c9255ad v0.6.3-rc.1 2023-10-28 12:17:23 +07:00
8 changed files with 47 additions and 10 deletions

No files matched your search

Generated
+2 -2
View File
@@ -1663,7 +1663,7 @@ dependencies = [
[[package]]
name = "neolink"
version = "0.6.2"
version = "0.6.3-rc.1"
dependencies = [
"anyhow",
"async-stream",
@@ -1701,7 +1701,7 @@ dependencies = [
[[package]]
name = "neolink_core"
version = "0.6.2"
version = "0.6.3-rc.1"
dependencies = [
"aes",
"assert_matches",
+2 -2
View File
@@ -1,7 +1,7 @@
[package]
name = "neolink"
description = "A standards-compliant bridge to Reolink IP cameras"
version = "0.6.2"
version = "0.6.3-rc.1"
authors = ["George Hilliard <thirtythreeforty@gmail.com>", "Andrew King <sheepchaan@gmail.com>"]
edition = "2018"
license = "AGPL-3.0-or-later"
@@ -31,7 +31,7 @@ heck = "0.4.1"
lazy_static = "1.4.0"
log = { version = "0.4.17", features = [ "release_max_level_debug" ] }
md5 = "0.7.0"
neolink_core = { path = "crates/core", version = "0.6.2" }
neolink_core = { path = "crates/core", version = "0.6.3-rc.1" }
regex = "1.7.3"
rumqttc = "0.22.0"
serde = { version = "1.0.160", features = ["derive"] }
+1
View File
@@ -371,6 +371,7 @@ Avaliable features are:
- `pt`: This adds a selection of buttons to control the pan and tilt of the
camera
- `battery`: This adds a battery level sensor to home assistant
- `siren`: Adds a siren button to home assistant
### Pause
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
name = "neolink_core"
description = "Core services and structure for Reolink IP cameras"
version = "0.6.2"
version = "0.6.3-rc.1"
authors = ["George Hilliard <thirtythreeforty@gmail.com>", "Andrew King <sheepchaan@gmail.com>"]
edition = "2018"
license = "AGPL-3.0-or-later"
+1 -1
View File
@@ -12,7 +12,7 @@ env_logger = "0.10.0"
fcm-push-listener = "2.0.1"
lazy_static = "1.4.0"
log = { version = "0.4.17", features = [ "release_max_level_debug" ] }
neolink_core = { path = "../core", version = "0.6.2" }
neolink_core = { path = "../core", version = "0.6.3-rc.1" }
regex = "1.8.1"
serde = "1.0.163"
tokio = { version = "1.28.1", features = ["full"] }
+9 -3
View File
@@ -261,10 +261,16 @@ impl NeoInstance {
Ok(instance_rx.await?)
}
pub(crate) async fn push_notifications(&self) -> Result<WatchReceiver<Option<PushNoti>>> {
let uid = self
.run_task(|cam| Box::pin(async move { Ok(cam.uid().await?) }))
pub(crate) async fn uid(&self) -> Result<String> {
let (reply_tx, reply_rx) = oneshot();
self.camera_control
.send(NeoCamCommand::GetUid(reply_tx))
.await?;
Ok(reply_rx.await?)
}
pub(crate) async fn push_notifications(&self) -> Result<WatchReceiver<Option<PushNoti>>> {
let uid = self.uid().await?;
let (instance_tx, instance_rx) = oneshot();
self.camera_control
.send(NeoCamCommand::PushNoti(instance_tx))
+30
View File
@@ -41,6 +41,7 @@ pub(crate) enum NeoCamCommand {
State(OneshotSender<NeoCamThreadState>),
GetPermit(OneshotSender<Permit>),
PushNoti(OneshotSender<WatchReceiver<Option<PushNoti>>>),
GetUid(OneshotSender<String>),
}
/// The underlying camera binding
pub(crate) struct NeoCam {
@@ -62,6 +63,7 @@ impl NeoCam {
let (stream_request_tx, stream_request_rx) = mpsc(100);
let (md_request_tx, md_request_rx) = mpsc(100);
let (state_tx, state_rx) = watch(NeoCamThreadState::Connected);
let (uid_tx, uid_rx) = watch(config.camera_uid.clone());
let set = JoinSet::new();
let users = UseCounter::new().await;
@@ -175,6 +177,14 @@ impl NeoCam {
}
).await?;
},
NeoCamCommand::GetUid(sender) => {
let mut uid_rx = uid_rx.clone();
tokio::task::spawn(async move {
let uid = uid_rx.wait_for(|v| v.is_some()).await?.clone().unwrap();
let _ = sender.send(uid);
AnyResult::Ok(())
});
},
}
}
log::debug!("Control thread Senders dropped");
@@ -275,6 +285,26 @@ impl NeoCam {
}
});
// This thread will update the UID by asking the camera.
// We cache this in the uid_rx
let uid_instance = instance.clone();
let uid_cancel = me.cancel.clone();
me.set.spawn(async move {
tokio::select! {
_ = uid_cancel.cancelled() => {
AnyResult::Ok(())
},
v = async {
let uid = uid_instance.run_task(|cam| Box::pin(async move {
let uid = cam.uid().await?;
Ok(uid)
})).await?;
uid_tx.send_replace(Some(uid));
AnyResult::Ok(())
} => v,
}
});
// Handles push notifications
let pn_root_instance = instance.subscribe().await?;
let pn_cancel = me.cancel.clone();
+1 -1
View File
@@ -565,7 +565,7 @@ async fn listen_on_camera(camera: NeoInstance, mqtt_instance: MqttInstance) -> R
} => v,
// Handle the floodlight task activation
v = async {
let flt_status = camera_floodlight_tasks.run_task(|cam| Box::pin(async move {
let flt_status = camera_floodlight_tasks.run_passive_task(|cam| Box::pin(async move {
Ok(cam.is_flightlight_tasks_enabled().await?)
})).await;
if flt_status.is_err() {