@apocaliss92/nodelink-js 0.4.20 → 0.4.21

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-XUL2Y2AL.js";
6
+ } from "../chunk-EZ7WNPLB.js";
7
7
  import "../chunk-S2UTGNFN.js";
8
8
  import {
9
9
  __require
package/dist/index.cjs CHANGED
@@ -19685,6 +19685,25 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
19685
19685
  simpleEventResubscribeTimer;
19686
19686
  simpleEventResubscribeInFlight;
19687
19687
  simpleEventResubscribeIntervalMs = 5 * 6e4;
19688
+ /**
19689
+ * Default `true` for non-UDP transports (TCP / `auto`), `false` for UDP.
19690
+ *
19691
+ * On TCP the periodic 5-min `subscribeEvents` renewal is cheap belt-and-
19692
+ * braces for firmwares that silently drop the push subscription.
19693
+ *
19694
+ * On UDP (battery cameras) every renewal sends cmd_id 31 which wakes
19695
+ * the device, driving an exact-5-minute sleep/awake cycle visible
19696
+ * downstream in MQTT / Home Assistant (continuation of issue #18). The
19697
+ * reactive `simpleEventWatchdog` (10s tick, 5 min silence threshold)
19698
+ * already recovers silent-drop cases without periodic wakes, so the
19699
+ * renewal is disabled by default for UDP.
19700
+ *
19701
+ * `startSimpleEventResubscribeTimer` also re-checks the live transport
19702
+ * before arming the timer, so callers that pick `transport: "auto"` and
19703
+ * end up on UDP at runtime get the safer behaviour even if the flag
19704
+ * was left default-on.
19705
+ */
19706
+ eventResubscribeEnabled = true;
19688
19707
  // Event watchdog: auto-recovery when events stop flowing or subscription fails
19689
19708
  simpleEventWatchdogTimer;
19690
19709
  simpleEventLastReceivedAt = 0;
@@ -20645,6 +20664,12 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
20645
20664
  debugConfig: generalClient.getDebugConfig?.()
20646
20665
  });
20647
20666
  this.sessionGuardEnabled = opts.enableSessionGuard === true;
20667
+ const explicitResubscribe = opts.enableEventResubscribe;
20668
+ if (typeof explicitResubscribe === "boolean") {
20669
+ this.eventResubscribeEnabled = explicitResubscribe;
20670
+ } else {
20671
+ this.eventResubscribeEnabled = opts.transport !== "udp";
20672
+ }
20648
20673
  const maxSessions = opts.maxDedicatedSessionsBeforeReboot;
20649
20674
  if (typeof maxSessions === "number" && Number.isFinite(maxSessions) && maxSessions > 0) {
20650
20675
  this.maxDedicatedSessionsBeforeReboot = Math.floor(maxSessions);
@@ -21364,6 +21389,8 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
21364
21389
  startSimpleEventResubscribeTimer() {
21365
21390
  if (this.simpleEventResubscribeTimer) return;
21366
21391
  if (this.simpleEventListeners.size === 0) return;
21392
+ if (!this.eventResubscribeEnabled) return;
21393
+ if (this.client.getTransport?.() === "udp") return;
21367
21394
  this.simpleEventResubscribeTimer = setInterval(() => {
21368
21395
  void this.renewSimpleEventSubscription();
21369
21396
  }, this.simpleEventResubscribeIntervalMs);