@apocaliss92/nodelink-js 0.4.32 → 0.4.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import {
3
3
  BaichuanRtspServer,
4
4
  ReolinkBaichuanApi,
5
5
  autoDetectDeviceType
6
- } from "../chunk-5Z7NVPV6.js";
6
+ } from "../chunk-OZL6C2YJ.js";
7
7
  import "../chunk-AHY4L7JI.js";
8
8
  import {
9
9
  __require
package/dist/index.cjs CHANGED
@@ -20199,6 +20199,21 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
20199
20199
  // check every 10s
20200
20200
  simpleEventWatchdogSilenceThresholdMs = 5 * 6e4;
20201
20201
  // 5 min without events
20202
+ /**
20203
+ * Whether the silence-based resubscribe path of the watchdog is
20204
+ * enabled. On UDP (battery cameras) silence is the *normal* state
20205
+ * while the device sleeps — firing `ensureSimpleEventSubscribed`
20206
+ * every 5 minutes wakes the camera on every tick, drains the
20207
+ * battery, and is observably wrong because the cam emits a
20208
+ * sleep/awake push when it actually wakes for motion.
20209
+ *
20210
+ * Defaults: `false` on UDP, `true` on TCP / `auto`. The subscription-
20211
+ * failed recovery path (Case 2) stays active regardless — it only
20212
+ * runs when the connection is alive, doesn't wake anyone, and is
20213
+ * useful on every transport when the initial subscribe call lost
20214
+ * the response packet.
20215
+ */
20216
+ eventWatchdogSilenceResubscribeEnabled = true;
20202
20217
  statePollingInterval;
20203
20218
  udpSleepInferenceInterval;
20204
20219
  udpLastInferredSleepStateByChannel = /* @__PURE__ */ new Map();
@@ -21156,6 +21171,12 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
21156
21171
  } else {
21157
21172
  this.eventResubscribeEnabled = opts.transport !== "udp";
21158
21173
  }
21174
+ const explicitWatchdogResubscribe = opts.enableEventWatchdogSilenceResubscribe;
21175
+ if (typeof explicitWatchdogResubscribe === "boolean") {
21176
+ this.eventWatchdogSilenceResubscribeEnabled = explicitWatchdogResubscribe;
21177
+ } else {
21178
+ this.eventWatchdogSilenceResubscribeEnabled = opts.transport !== "udp";
21179
+ }
21159
21180
  const maxSessions = opts.maxDedicatedSessionsBeforeReboot;
21160
21181
  if (typeof maxSessions === "number" && Number.isFinite(maxSessions) && maxSessions > 0) {
21161
21182
  this.maxDedicatedSessionsBeforeReboot = Math.floor(maxSessions);
@@ -21978,6 +21999,14 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
21978
21999
  if (this.simpleEventSubscribed && this.simpleEventLastReceivedAt > 0) {
21979
22000
  const silence = now - this.simpleEventLastReceivedAt;
21980
22001
  if (silence < this.simpleEventWatchdogSilenceThresholdMs) return;
22002
+ if (!this.eventWatchdogSilenceResubscribeEnabled) {
22003
+ this.logger.debug?.(
22004
+ `[ReolinkBaichuanApi] event watchdog: silence-based resubscribe disabled (UDP / battery), skipping`,
22005
+ { host: this.host, silenceMs: silence }
22006
+ );
22007
+ this.simpleEventLastReceivedAt = now;
22008
+ return;
22009
+ }
21981
22010
  (this.logger.warn ?? this.logger.log).call(
21982
22011
  this.logger,
21983
22012
  `[ReolinkBaichuanApi] event watchdog: no events for ${Math.round(silence / 6e4)} min, forcing resubscribe`,