@apocaliss92/scrypted-reolink-native 0.1.21 → 0.1.22
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/package.json +1 -1
- package/src/multifocal.ts +31 -12
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/multifocal.ts
CHANGED
|
@@ -61,6 +61,8 @@ export class ReolinkNativeMultiFocalDevice extends BaseBaichuanClass implements
|
|
|
61
61
|
cameraNativeMap = new Map<string, ReolinkNativeCamera | ReolinkNativeBatteryCamera>();
|
|
62
62
|
private channelToNativeIdMap = new Map<number, string>();
|
|
63
63
|
processing = false;
|
|
64
|
+
private syncInProgress = false;
|
|
65
|
+
private syncPromise: Promise<void> | undefined;
|
|
64
66
|
private initReinitTimeout: NodeJS.Timeout | undefined;
|
|
65
67
|
|
|
66
68
|
constructor(nativeId: string, plugin: ReolinkNativePlugin, transport: BaichuanTransport = 'tcp') {
|
|
@@ -197,10 +199,21 @@ export class ReolinkNativeMultiFocalDevice extends BaseBaichuanClass implements
|
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
async syncEntitiesFromRemote() {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
+
// If sync is already in progress, wait for it to complete
|
|
203
|
+
if (this.syncInProgress && this.syncPromise) {
|
|
204
|
+
const logger = this.getBaichuanLogger();
|
|
205
|
+
logger.debug('Sync already in progress, waiting for completion...');
|
|
206
|
+
await this.syncPromise;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
202
209
|
|
|
203
|
-
|
|
210
|
+
// Start new sync
|
|
211
|
+
this.syncInProgress = true;
|
|
212
|
+
this.syncPromise = (async () => {
|
|
213
|
+
const api = await this.ensureBaichuanClient();
|
|
214
|
+
const logger = this.getBaichuanLogger();
|
|
215
|
+
|
|
216
|
+
try {
|
|
204
217
|
// const channelsInfo = await api.getNvrChannelsInfo();
|
|
205
218
|
// const deviceInfo = await api.getInfo();
|
|
206
219
|
const { support } = await api.getDeviceCapabilities();
|
|
@@ -266,16 +279,22 @@ export class ReolinkNativeMultiFocalDevice extends BaseBaichuanClass implements
|
|
|
266
279
|
}
|
|
267
280
|
|
|
268
281
|
// logger.log(`Channel discovery completed. ${JSON.stringify({ devicesData, channels })}`);
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
282
|
+
} catch (e) {
|
|
283
|
+
logger.error('Failed to sync entities from remote', e);
|
|
284
|
+
if (e instanceof Error) {
|
|
285
|
+
logger.error(`Error in syncEntitiesFromRemote: ${e.message}`);
|
|
286
|
+
logger.error(`Stack: ${e.stack}`);
|
|
287
|
+
} else {
|
|
288
|
+
logger.error(`Error details: ${JSON.stringify(e)}`);
|
|
289
|
+
}
|
|
290
|
+
throw e;
|
|
291
|
+
} finally {
|
|
292
|
+
this.syncInProgress = false;
|
|
293
|
+
this.syncPromise = undefined;
|
|
276
294
|
}
|
|
277
|
-
|
|
278
|
-
|
|
295
|
+
})();
|
|
296
|
+
|
|
297
|
+
await this.syncPromise;
|
|
279
298
|
}
|
|
280
299
|
|
|
281
300
|
async discoverDevices(scan?: boolean): Promise<DiscoveredDevice[]> {
|