@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.
@@ -19522,6 +19522,21 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
19522
19522
  // check every 10s
19523
19523
  simpleEventWatchdogSilenceThresholdMs = 5 * 6e4;
19524
19524
  // 5 min without events
19525
+ /**
19526
+ * Whether the silence-based resubscribe path of the watchdog is
19527
+ * enabled. On UDP (battery cameras) silence is the *normal* state
19528
+ * while the device sleeps — firing `ensureSimpleEventSubscribed`
19529
+ * every 5 minutes wakes the camera on every tick, drains the
19530
+ * battery, and is observably wrong because the cam emits a
19531
+ * sleep/awake push when it actually wakes for motion.
19532
+ *
19533
+ * Defaults: `false` on UDP, `true` on TCP / `auto`. The subscription-
19534
+ * failed recovery path (Case 2) stays active regardless — it only
19535
+ * runs when the connection is alive, doesn't wake anyone, and is
19536
+ * useful on every transport when the initial subscribe call lost
19537
+ * the response packet.
19538
+ */
19539
+ eventWatchdogSilenceResubscribeEnabled = true;
19525
19540
  statePollingInterval;
19526
19541
  udpSleepInferenceInterval;
19527
19542
  udpLastInferredSleepStateByChannel = /* @__PURE__ */ new Map();
@@ -20479,6 +20494,12 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
20479
20494
  } else {
20480
20495
  this.eventResubscribeEnabled = opts.transport !== "udp";
20481
20496
  }
20497
+ const explicitWatchdogResubscribe = opts.enableEventWatchdogSilenceResubscribe;
20498
+ if (typeof explicitWatchdogResubscribe === "boolean") {
20499
+ this.eventWatchdogSilenceResubscribeEnabled = explicitWatchdogResubscribe;
20500
+ } else {
20501
+ this.eventWatchdogSilenceResubscribeEnabled = opts.transport !== "udp";
20502
+ }
20482
20503
  const maxSessions = opts.maxDedicatedSessionsBeforeReboot;
20483
20504
  if (typeof maxSessions === "number" && Number.isFinite(maxSessions) && maxSessions > 0) {
20484
20505
  this.maxDedicatedSessionsBeforeReboot = Math.floor(maxSessions);
@@ -21301,6 +21322,14 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
21301
21322
  if (this.simpleEventSubscribed && this.simpleEventLastReceivedAt > 0) {
21302
21323
  const silence = now - this.simpleEventLastReceivedAt;
21303
21324
  if (silence < this.simpleEventWatchdogSilenceThresholdMs) return;
21325
+ if (!this.eventWatchdogSilenceResubscribeEnabled) {
21326
+ this.logger.debug?.(
21327
+ `[ReolinkBaichuanApi] event watchdog: silence-based resubscribe disabled (UDP / battery), skipping`,
21328
+ { host: this.host, silenceMs: silence }
21329
+ );
21330
+ this.simpleEventLastReceivedAt = now;
21331
+ return;
21332
+ }
21304
21333
  (this.logger.warn ?? this.logger.log).call(
21305
21334
  this.logger,
21306
21335
  `[ReolinkBaichuanApi] event watchdog: no events for ${Math.round(silence / 6e4)} min, forcing resubscribe`,