@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.
@@ -11331,6 +11331,25 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
11331
11331
  simpleEventResubscribeTimer;
11332
11332
  simpleEventResubscribeInFlight;
11333
11333
  simpleEventResubscribeIntervalMs = 5 * 6e4;
11334
+ /**
11335
+ * Default `true` for non-UDP transports (TCP / `auto`), `false` for UDP.
11336
+ *
11337
+ * On TCP the periodic 5-min `subscribeEvents` renewal is cheap belt-and-
11338
+ * braces for firmwares that silently drop the push subscription.
11339
+ *
11340
+ * On UDP (battery cameras) every renewal sends cmd_id 31 which wakes
11341
+ * the device, driving an exact-5-minute sleep/awake cycle visible
11342
+ * downstream in MQTT / Home Assistant (continuation of issue #18). The
11343
+ * reactive `simpleEventWatchdog` (10s tick, 5 min silence threshold)
11344
+ * already recovers silent-drop cases without periodic wakes, so the
11345
+ * renewal is disabled by default for UDP.
11346
+ *
11347
+ * `startSimpleEventResubscribeTimer` also re-checks the live transport
11348
+ * before arming the timer, so callers that pick `transport: "auto"` and
11349
+ * end up on UDP at runtime get the safer behaviour even if the flag
11350
+ * was left default-on.
11351
+ */
11352
+ eventResubscribeEnabled = true;
11334
11353
  // Event watchdog: auto-recovery when events stop flowing or subscription fails
11335
11354
  simpleEventWatchdogTimer;
11336
11355
  simpleEventLastReceivedAt = 0;
@@ -12291,6 +12310,12 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
12291
12310
  debugConfig: generalClient.getDebugConfig?.()
12292
12311
  });
12293
12312
  this.sessionGuardEnabled = opts.enableSessionGuard === true;
12313
+ const explicitResubscribe = opts.enableEventResubscribe;
12314
+ if (typeof explicitResubscribe === "boolean") {
12315
+ this.eventResubscribeEnabled = explicitResubscribe;
12316
+ } else {
12317
+ this.eventResubscribeEnabled = opts.transport !== "udp";
12318
+ }
12294
12319
  const maxSessions = opts.maxDedicatedSessionsBeforeReboot;
12295
12320
  if (typeof maxSessions === "number" && Number.isFinite(maxSessions) && maxSessions > 0) {
12296
12321
  this.maxDedicatedSessionsBeforeReboot = Math.floor(maxSessions);
@@ -13010,6 +13035,8 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
13010
13035
  startSimpleEventResubscribeTimer() {
13011
13036
  if (this.simpleEventResubscribeTimer) return;
13012
13037
  if (this.simpleEventListeners.size === 0) return;
13038
+ if (!this.eventResubscribeEnabled) return;
13039
+ if (this.client.getTransport?.() === "udp") return;
13013
13040
  this.simpleEventResubscribeTimer = setInterval(() => {
13014
13041
  void this.renewSimpleEventSubscription();
13015
13042
  }, this.simpleEventResubscribeIntervalMs);
@@ -23979,4 +24006,4 @@ export {
23979
24006
  isTcpFailureThatShouldFallbackToUdp,
23980
24007
  autoDetectDeviceType
23981
24008
  };
23982
- //# sourceMappingURL=chunk-XUL2Y2AL.js.map
24009
+ //# sourceMappingURL=chunk-EZ7WNPLB.js.map