Bump timeout to 5 seconds and remove config option
This, combined with auto time set, should completely fix #14.
This commit is contained in:
1 parent
e603699e45
commit
051887a7c3
5 files changed
+15
-27
No files matched your search
@@ -31,17 +31,7 @@ _This is the most reliable setup since Neolink cannot autodetect when a camera's
|
||||
|
||||
_You will have to reconnect to the camera once you have changed the IP address_
|
||||
|
||||
### 3. Set the camera's time to your local network time and disable Auto Reboot
|
||||
_When a camera reboots, it loses its date and time settings. If the camera's time is not set, Neolink will recursively "time out" every one second and will not stream video. Setting the time and disabling auto reboot on the camera is a workaround for [issue #14](https://github.com/thirtythreeforty/neolink/issues/14)._
|
||||
1. In the Reolink PC app, login to your camera.
|
||||
2. Click "Device Settings" -> "System General" -> "Synchronize Local Time."
|
||||
3. Click "Ok."
|
||||
|
||||
4. Click "Device Settings" -> "Maintenance."
|
||||
|
||||
5. Uncheck "Enable Auto Reboot."
|
||||
|
||||
### 4. Set a Password
|
||||
### 3. Set a Password
|
||||
_It's recommended that you set a password for each of your cameras. If you want to use the Reolink Mobile App, it makes you set a password for each camera anyway._
|
||||
1. In the Reolink PC app, login to your camera.
|
||||
2. Click "Device Settings" -> "Manage User."
|
||||
|
||||
+7
-11
@@ -17,13 +17,14 @@ pub struct BcCamera {
|
||||
address: SocketAddr,
|
||||
connection: Option<BcConnection>,
|
||||
logged_in: bool,
|
||||
rx_timeout: Duration,
|
||||
}
|
||||
|
||||
use crate::Never;
|
||||
|
||||
type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
const RX_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error(display = "Communication error")]
|
||||
@@ -71,16 +72,11 @@ impl BcCamera {
|
||||
address,
|
||||
connection: None,
|
||||
logged_in: false,
|
||||
rx_timeout: Duration::from_secs(1),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_rx_timeout(&mut self, timeout: Duration) {
|
||||
self.rx_timeout = timeout;
|
||||
}
|
||||
|
||||
pub fn connect(&mut self) -> Result<()> {
|
||||
self.connection = Some(BcConnection::new(self.address, self.rx_timeout)?);
|
||||
self.connection = Some(BcConnection::new(self.address, RX_TIMEOUT)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -127,7 +123,7 @@ impl BcCamera {
|
||||
|
||||
sub_login.send(legacy_login)?;
|
||||
|
||||
let legacy_reply = sub_login.rx.recv_timeout(self.rx_timeout)?;
|
||||
let legacy_reply = sub_login.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
let nonce;
|
||||
match legacy_reply.body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
@@ -181,7 +177,7 @@ impl BcCamera {
|
||||
);
|
||||
|
||||
sub_login.send(modern_login)?;
|
||||
let modern_reply = sub_login.rx.recv_timeout(self.rx_timeout)?;
|
||||
let modern_reply = sub_login.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
|
||||
let device_info;
|
||||
match modern_reply.body {
|
||||
@@ -238,7 +234,7 @@ impl BcCamera {
|
||||
|
||||
sub_ping.send(ping)?;
|
||||
|
||||
sub_ping.rx.recv_timeout(self.rx_timeout)?;
|
||||
sub_ping.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -272,7 +268,7 @@ impl BcCamera {
|
||||
|
||||
loop {
|
||||
trace!("Getting video message...");
|
||||
let msg = sub_video.rx.recv_timeout(self.rx_timeout)?;
|
||||
let msg = sub_video.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
binary: Some(binary),
|
||||
..
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{BcCamera, Error, Result};
|
||||
use super::{BcCamera, Error, Result, RX_TIMEOUT};
|
||||
use crate::bc::{model::*, xml::*};
|
||||
use time::{date, Date, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset};
|
||||
|
||||
@@ -20,7 +20,7 @@ impl BcCamera {
|
||||
};
|
||||
|
||||
sub_get_general.send(get)?;
|
||||
let msg = sub_get_general.rx.recv_timeout(self.rx_timeout)?;
|
||||
let msg = sub_get_general.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
xml:
|
||||
@@ -105,7 +105,7 @@ impl BcCamera {
|
||||
);
|
||||
|
||||
sub_set_general.send(set)?;
|
||||
let msg = sub_set_general.rx.recv_timeout(self.rx_timeout)?;
|
||||
let msg = sub_set_general.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ pub struct CameraConfig {
|
||||
pub username: String,
|
||||
pub password: Option<String>,
|
||||
|
||||
// no longer used, but still here so we can warn users:
|
||||
pub timeout: Option<Duration>,
|
||||
|
||||
#[validate(regex(
|
||||
|
||||
+3
-2
@@ -195,8 +195,9 @@ fn camera_main(
|
||||
let mut connected = false;
|
||||
(|| {
|
||||
let mut camera = BcCamera::new_with_addr(camera_config.camera_addr)?;
|
||||
if let Some(timeout) = camera_config.timeout {
|
||||
camera.set_rx_timeout(timeout);
|
||||
if let Some(_) = camera_config.timeout {
|
||||
warn!("The undocumented `timeout` config option has been removed and is no longer needed.");
|
||||
warn!("Please update your config file.");
|
||||
}
|
||||
|
||||
info!(
|
||||
|
||||
Reference in new issue
Block a user