@apocaliss92/scrypted-reolink-native 0.1.6 → 0.1.7
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.
- package/dist/main.nodejs.js +1 -1
- package/dist/plugin.zip +0 -0
- package/logs.txt +7361 -0
- package/package.json +1 -1
- package/src/common.ts +27 -2
package/package.json
CHANGED
package/src/common.ts
CHANGED
|
@@ -3,7 +3,7 @@ import sdk, { BinarySensor, Brightness, Camera, Device, DeviceProvider, Intercom
|
|
|
3
3
|
import { StorageSettings } from "@scrypted/sdk/storage-settings";
|
|
4
4
|
import type { UrlMediaStreamOptions } from "../../scrypted/plugins/rtsp/src/rtsp";
|
|
5
5
|
import { createBaichuanApi, normalizeUid, type BaichuanTransport } from "./connect";
|
|
6
|
-
import { convertDebugLogsToApiOptions, DebugLogOption, getApiRelevantDebugLogs, getDebugLogChoices } from "./debug-options";
|
|
6
|
+
import { convertDebugLogsToApiOptions, DebugLogDisplayNames, DebugLogOption, getApiRelevantDebugLogs, getDebugLogChoices } from "./debug-options";
|
|
7
7
|
import { ReolinkBaichuanIntercom } from "./intercom";
|
|
8
8
|
import ReolinkNativePlugin from "./main";
|
|
9
9
|
import { ReolinkNativeNvrDevice } from "./nvr";
|
|
@@ -486,6 +486,7 @@ export abstract class CommonCameraMixin extends ScryptedDeviceBase implements Vi
|
|
|
486
486
|
protected baichuanApi: ReolinkBaichuanApi | undefined;
|
|
487
487
|
protected ensureClientPromise: Promise<ReolinkBaichuanApi> | undefined;
|
|
488
488
|
protected connectionTime: number | undefined;
|
|
489
|
+
private closeListener?: () => void;
|
|
489
490
|
protected readonly protocol: BaichuanTransport;
|
|
490
491
|
private debugLogsResetTimeout: NodeJS.Timeout | undefined;
|
|
491
492
|
|
|
@@ -877,7 +878,7 @@ export abstract class CommonCameraMixin extends ScryptedDeviceBase implements Vi
|
|
|
877
878
|
|
|
878
879
|
isEventLogsEnabled(): boolean {
|
|
879
880
|
const debugLogs = this.storageSettings.values.debugLogs || [];
|
|
880
|
-
return debugLogs.includes(DebugLogOption.EventLogs);
|
|
881
|
+
return debugLogs.includes(DebugLogDisplayNames[DebugLogOption.EventLogs]);
|
|
881
882
|
}
|
|
882
883
|
|
|
883
884
|
// BinarySensor interface implementation (for doorbell)
|
|
@@ -1341,6 +1342,17 @@ export abstract class CommonCameraMixin extends ScryptedDeviceBase implements Vi
|
|
|
1341
1342
|
|
|
1342
1343
|
// Only tear down previous session if it exists and is not connected
|
|
1343
1344
|
if (this.baichuanApi) {
|
|
1345
|
+
// Remove close listener from old client
|
|
1346
|
+
if (this.closeListener) {
|
|
1347
|
+
try {
|
|
1348
|
+
this.baichuanApi.client.off("close", this.closeListener);
|
|
1349
|
+
}
|
|
1350
|
+
catch {
|
|
1351
|
+
// ignore
|
|
1352
|
+
}
|
|
1353
|
+
this.closeListener = undefined;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1344
1356
|
const isConnected = this.baichuanApi.client.isSocketConnected();
|
|
1345
1357
|
if (!isConnected) {
|
|
1346
1358
|
// Socket is closed, clean up
|
|
@@ -1408,6 +1420,19 @@ export abstract class CommonCameraMixin extends ScryptedDeviceBase implements Vi
|
|
|
1408
1420
|
this.baichuanApi = api;
|
|
1409
1421
|
this.connectionTime = Date.now();
|
|
1410
1422
|
|
|
1423
|
+
// Listen for socket disconnection to reset client state
|
|
1424
|
+
// This ensures ensureClient() will create a new connection on next call
|
|
1425
|
+
this.closeListener = () => {
|
|
1426
|
+
const logger = this.getLogger();
|
|
1427
|
+
if (this.baichuanApi === api) {
|
|
1428
|
+
logger.log(`[BaichuanClient] Socket closed, resetting client state for reconnection`);
|
|
1429
|
+
this.baichuanApi = undefined;
|
|
1430
|
+
this.ensureClientPromise = undefined;
|
|
1431
|
+
this.closeListener = undefined;
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
api.client.on("close", this.closeListener);
|
|
1435
|
+
|
|
1411
1436
|
// Re-attach event handler if enabled
|
|
1412
1437
|
if (this.isEventDispatchEnabled?.() && this.onSimpleEvent) {
|
|
1413
1438
|
try {
|