@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.
@@ -19064,6 +19064,25 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
19064
19064
  simpleEventResubscribeTimer;
19065
19065
  simpleEventResubscribeInFlight;
19066
19066
  simpleEventResubscribeIntervalMs = 5 * 6e4;
19067
+ /**
19068
+ * Default `true` for non-UDP transports (TCP / `auto`), `false` for UDP.
19069
+ *
19070
+ * On TCP the periodic 5-min `subscribeEvents` renewal is cheap belt-and-
19071
+ * braces for firmwares that silently drop the push subscription.
19072
+ *
19073
+ * On UDP (battery cameras) every renewal sends cmd_id 31 which wakes
19074
+ * the device, driving an exact-5-minute sleep/awake cycle visible
19075
+ * downstream in MQTT / Home Assistant (continuation of issue #18). The
19076
+ * reactive `simpleEventWatchdog` (10s tick, 5 min silence threshold)
19077
+ * already recovers silent-drop cases without periodic wakes, so the
19078
+ * renewal is disabled by default for UDP.
19079
+ *
19080
+ * `startSimpleEventResubscribeTimer` also re-checks the live transport
19081
+ * before arming the timer, so callers that pick `transport: "auto"` and
19082
+ * end up on UDP at runtime get the safer behaviour even if the flag
19083
+ * was left default-on.
19084
+ */
19085
+ eventResubscribeEnabled = true;
19067
19086
  // Event watchdog: auto-recovery when events stop flowing or subscription fails
19068
19087
  simpleEventWatchdogTimer;
19069
19088
  simpleEventLastReceivedAt = 0;
@@ -20024,6 +20043,12 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
20024
20043
  debugConfig: generalClient.getDebugConfig?.()
20025
20044
  });
20026
20045
  this.sessionGuardEnabled = opts.enableSessionGuard === true;
20046
+ const explicitResubscribe = opts.enableEventResubscribe;
20047
+ if (typeof explicitResubscribe === "boolean") {
20048
+ this.eventResubscribeEnabled = explicitResubscribe;
20049
+ } else {
20050
+ this.eventResubscribeEnabled = opts.transport !== "udp";
20051
+ }
20027
20052
  const maxSessions = opts.maxDedicatedSessionsBeforeReboot;
20028
20053
  if (typeof maxSessions === "number" && Number.isFinite(maxSessions) && maxSessions > 0) {
20029
20054
  this.maxDedicatedSessionsBeforeReboot = Math.floor(maxSessions);
@@ -20743,6 +20768,8 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
20743
20768
  startSimpleEventResubscribeTimer() {
20744
20769
  if (this.simpleEventResubscribeTimer) return;
20745
20770
  if (this.simpleEventListeners.size === 0) return;
20771
+ if (!this.eventResubscribeEnabled) return;
20772
+ if (this.client.getTransport?.() === "udp") return;
20746
20773
  this.simpleEventResubscribeTimer = setInterval(() => {
20747
20774
  void this.renewSimpleEventSubscription();
20748
20775
  }, this.simpleEventResubscribeIntervalMs);