From 0fc04551113d8563c8a8b5dd35f32dc0c0171a60 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Tue, 26 Sep 2023 21:14:30 +0700 Subject: [PATCH] Add debug message for push server fails --- .github/workflows/build.yml | 5 ++-- README.md | 50 ++++++++++++++++++++++++++++++++++++- src/common/neocam.rs | 9 ++++++- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f20d031..4a73420 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,9 +50,8 @@ jobs: Add-Content -Path $env:GITHUB_ENV -Value "GSTREAMER_1_0_ROOT_MSVC_X86_64=$env:GSTREAMER_1_0_ROOT_MSVC_X86_64" Add-Content -Path $env:GITHUB_PATH -Value "$env:GSTREAMER_1_0_ROOT_MSVC_X86_64\bin" Add-Content -Path $env:GITHUB_PATH -Value "%GSTREAMER_1_0_ROOT_MSVC_X86_64%\bin" - dir "C:\Program Files\" - dir "C:\Program Files\OpenSSL-Win64" - Add-Content -Path $env:GITHUB_ENV -Value "OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" + $env:OPENSSL_DIR=$env:SYSTEMDRIVE + '\Program Files\OpenSSL-Win64\' + Add-Content -Path $env:GITHUB_ENV -Value "OPENSSL_DIR=$env:OPENSSL_DIR" - if: runner.os == 'macOS' name: Install Gstreamer on macOS run: | diff --git a/README.md b/README.md index 56d4549..97fc675 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,16 @@ sudo apt install \ gstreamer1.0-x \ gstreamer1.0-plugins-base \ gstreamer1.0-plugins-good \ - gstreamer1.0-plugins-bad + gstreamer1.0-plugins-bad \ + libssl ``` +- **Windows**: You may also need to +[install openssl](https://wiki.openssl.org/index.php/Binaries) +- **Macos**: You may also need to +[install openssl](https://wiki.openssl.org/index.php/Binaries) or `brew install openssl@1.1` +- **Ubuntu/Debian**: Install the `libssl` package + Make a config file see below. ## Config/Usage @@ -375,6 +382,47 @@ Then start the rtsp server as usual: ./neolink rtsp --config=neolink.toml ``` +### Idle Disconnects + +To really save battery we need to disconnect the camera when it is idle. + +To acheieve this you can add `idle_disconnect = true` to the `[[cameras]]` +section + +```toml +bind = "0.0.0.0" + +[[cameras]] +name = "Camera01" +username = "admin" +password = "password" +uid = "ABCDEF0123456789" +idle_disconnect = true + [cameras.pause] + on_client = true # Should pause when no rtsp client + timeout = 2.1 # How long to wait after motion stops before pausing +``` + +When `idle_disconnect = true` neolink will disconnect from the camera 30s +after it stops being used. + +Neolink considers it as being used if there is an active stream running, or +if there is motion being detected or an mqtt command being run + +You can make neolink stop active streams when there are no rtsp clients using + +```toml +[cameras.pause] + on_client = true # Should pause when no rtsp client +``` + +Once in the disconnected state. Neolink will stay disconnected until there is a +new requested activation such as a client connecting or an mqtt command + +Neolink will also wake up on push notifications from the camera. These are usually +sent by the camera on motion or PIR alarms. To disable this you can set +`push_notifications = false` in the `[[cameras]]` config + ### Docker [Docker](https://hub.docker.com/r/quantumentangledandy/neolink) builds are also diff --git a/src/common/neocam.rs b/src/common/neocam.rs index 9921aa0..40796eb 100644 --- a/src/common/neocam.rs +++ b/src/common/neocam.rs @@ -279,7 +279,14 @@ impl NeoCam { let r = tokio::select! { // This thread handles the push notfications v = async { - while push_notifier.run(&mut pn_request_rx).await.is_err() {} + while { + if let Err(e) = push_notifier.run(&mut pn_request_rx).await { + log::debug!("Push notification failed restarting: {:?}", e); + true + } else { + false + } + }{} AnyResult::Ok(()) } => v, // Push notification permits