@apocaliss92/scrypted-reolink-native 0.1.23 → 0.1.25
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/camera-battery.ts +10 -3
- package/src/camera.ts +9 -5
- package/src/common.ts +48 -38
- package/src/connect.ts +2 -2
- package/src/main.ts +4 -3
- package/src/multiFocal.ts +371 -0
- package/src/nvr.ts +0 -4
- package/src/multifocal.ts +0 -463
package/src/multifocal.ts
DELETED
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
import type { DeviceInfoResponse, ReolinkBaichuanApi, ReolinkCgiApi, ReolinkSimpleEvent } from "@apocaliss92/reolink-baichuan-js" with { "resolution-mode": "import" };
|
|
2
|
-
import sdk, { AdoptDevice, Device, DeviceDiscovery, DeviceProvider, DiscoveredDevice, Reboot, ScryptedDeviceBase, ScryptedDeviceType, ScryptedInterface, Setting, Settings, SettingValue } from "@scrypted/sdk";
|
|
3
|
-
import { StorageSettings } from "@scrypted/sdk/storage-settings";
|
|
4
|
-
import { BaseBaichuanClass, type BaichuanConnectionConfig, type BaichuanConnectionCallbacks } from "./baichuan-base";
|
|
5
|
-
import { ReolinkNativeCamera } from "./camera";
|
|
6
|
-
import { ReolinkNativeBatteryCamera } from "./camera-battery";
|
|
7
|
-
import { normalizeUid, type BaichuanTransport } from "./connect";
|
|
8
|
-
import ReolinkNativePlugin from "./main";
|
|
9
|
-
import { getDeviceInterfaces, updateDeviceInfo } from "./utils";
|
|
10
|
-
|
|
11
|
-
export class ReolinkNativeMultiFocalDevice extends BaseBaichuanClass implements Settings, DeviceDiscovery, DeviceProvider, Reboot {
|
|
12
|
-
storageSettings = new StorageSettings(this, {
|
|
13
|
-
debugEvents: {
|
|
14
|
-
title: 'Debug Events',
|
|
15
|
-
type: 'boolean',
|
|
16
|
-
immediate: true,
|
|
17
|
-
},
|
|
18
|
-
ipAddress: {
|
|
19
|
-
title: 'IP address',
|
|
20
|
-
type: 'string',
|
|
21
|
-
onPut: async () => await this.reinit()
|
|
22
|
-
},
|
|
23
|
-
username: {
|
|
24
|
-
title: 'Username',
|
|
25
|
-
placeholder: 'admin',
|
|
26
|
-
defaultValue: 'admin',
|
|
27
|
-
type: 'string',
|
|
28
|
-
onPut: async () => await this.reinit()
|
|
29
|
-
},
|
|
30
|
-
password: {
|
|
31
|
-
title: 'Password',
|
|
32
|
-
type: 'password',
|
|
33
|
-
onPut: async () => await this.reinit()
|
|
34
|
-
},
|
|
35
|
-
uid: {
|
|
36
|
-
title: 'UID',
|
|
37
|
-
description: 'Reolink UID (required for UDP/battery multi-focal devices)',
|
|
38
|
-
type: 'string',
|
|
39
|
-
hide: true,
|
|
40
|
-
onPut: async () => await this.reinit()
|
|
41
|
-
},
|
|
42
|
-
diagnosticsRun: {
|
|
43
|
-
subgroup: 'Diagnostics',
|
|
44
|
-
title: 'Run Diagnostics',
|
|
45
|
-
description: 'Collect diagnostics and display results in logs.',
|
|
46
|
-
type: 'button',
|
|
47
|
-
immediate: true,
|
|
48
|
-
onPut: async () => {
|
|
49
|
-
await this.runDiagnostics();
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
plugin: ReolinkNativePlugin;
|
|
54
|
-
protected readonly protocol: BaichuanTransport;
|
|
55
|
-
discoveredDevices = new Map<string, {
|
|
56
|
-
device: Device;
|
|
57
|
-
description: string;
|
|
58
|
-
rtspChannel: number;
|
|
59
|
-
deviceData: DeviceInfoResponse;
|
|
60
|
-
}>();
|
|
61
|
-
cameraNativeMap = new Map<string, ReolinkNativeCamera | ReolinkNativeBatteryCamera>();
|
|
62
|
-
private channelToNativeIdMap = new Map<number, string>();
|
|
63
|
-
processing = false;
|
|
64
|
-
private syncInProgress = false;
|
|
65
|
-
private syncPromise: Promise<void> | undefined;
|
|
66
|
-
private initReinitTimeout: NodeJS.Timeout | undefined;
|
|
67
|
-
|
|
68
|
-
constructor(nativeId: string, plugin: ReolinkNativePlugin, transport: BaichuanTransport = 'tcp') {
|
|
69
|
-
super(nativeId);
|
|
70
|
-
this.plugin = plugin;
|
|
71
|
-
this.protocol = transport;
|
|
72
|
-
|
|
73
|
-
this.scheduleInit();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async reboot(): Promise<void> {
|
|
77
|
-
const api = await this.ensureBaichuanClient();
|
|
78
|
-
await api.reboot();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// BaseBaichuanClass abstract methods implementation
|
|
82
|
-
protected getConnectionConfig(): BaichuanConnectionConfig {
|
|
83
|
-
const { ipAddress, username, password, uid } = this.storageSettings.values;
|
|
84
|
-
if (!ipAddress || !username || !password) {
|
|
85
|
-
throw new Error('Missing device credentials');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const normalizedUid = this.protocol === 'udp' ? normalizeUid(uid) : undefined;
|
|
89
|
-
|
|
90
|
-
if (this.protocol === 'udp' && !normalizedUid) {
|
|
91
|
-
throw new Error('UID is required for UDP multi-focal devices (BCUDP)');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
host: ipAddress,
|
|
96
|
-
username,
|
|
97
|
-
password,
|
|
98
|
-
uid: normalizedUid,
|
|
99
|
-
transport: this.protocol,
|
|
100
|
-
logger: this.console,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
protected getConnectionCallbacks(): BaichuanConnectionCallbacks {
|
|
105
|
-
return {
|
|
106
|
-
onError: undefined, // Use default error handling
|
|
107
|
-
onClose: async () => {
|
|
108
|
-
// Reinit after cleanup
|
|
109
|
-
await this.reinit();
|
|
110
|
-
},
|
|
111
|
-
onSimpleEvent: (ev) => this.forwardNativeEvent(ev),
|
|
112
|
-
getEventSubscriptionEnabled: () => true,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
protected isDebugEnabled(): boolean {
|
|
117
|
-
return this.storageSettings.values.debugEvents;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
protected getDeviceName(): string {
|
|
121
|
-
return this.name || 'Multi-Focal Device';
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async reinit(): Promise<void> {
|
|
125
|
-
// Cancel any pending init/reinit
|
|
126
|
-
if (this.initReinitTimeout) {
|
|
127
|
-
clearTimeout(this.initReinitTimeout);
|
|
128
|
-
this.initReinitTimeout = undefined;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Schedule reinit with debounce
|
|
132
|
-
this.scheduleInit(true);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private scheduleInit(isReinit: boolean = false): void {
|
|
136
|
-
// Cancel any pending init/reinit
|
|
137
|
-
if (this.initReinitTimeout) {
|
|
138
|
-
clearTimeout(this.initReinitTimeout);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.initReinitTimeout = setTimeout(async () => {
|
|
142
|
-
const logger = this.getBaichuanLogger();
|
|
143
|
-
if (isReinit) {
|
|
144
|
-
logger.log('Reinitializing multi-focal device...');
|
|
145
|
-
await this.cleanupBaichuanApi();
|
|
146
|
-
}
|
|
147
|
-
await this.init();
|
|
148
|
-
this.initReinitTimeout = undefined;
|
|
149
|
-
}, isReinit ? 500 : 2000);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async init(): Promise<void> {
|
|
153
|
-
const logger = this.getBaichuanLogger();
|
|
154
|
-
try {
|
|
155
|
-
// Update UID setting visibility based on transport
|
|
156
|
-
this.storageSettings.settings.uid.hide = this.protocol === 'tcp';
|
|
157
|
-
|
|
158
|
-
logger.debug('Initializing: ensuring Baichuan client...');
|
|
159
|
-
await this.ensureBaichuanClient();
|
|
160
|
-
|
|
161
|
-
logger.debug('Initializing: updating device info...');
|
|
162
|
-
await this.updateDeviceInfo();
|
|
163
|
-
|
|
164
|
-
logger.debug('Initializing: subscribing to events...');
|
|
165
|
-
await this.subscribeToEvents();
|
|
166
|
-
|
|
167
|
-
logger.debug('Initializing: discovering devices...');
|
|
168
|
-
await this.discoverDevices(true);
|
|
169
|
-
|
|
170
|
-
logger.log('Initialization completed successfully');
|
|
171
|
-
} catch (e) {
|
|
172
|
-
logger.error('Failed to initialize multi-focal device', e);
|
|
173
|
-
// Log more details about the error
|
|
174
|
-
if (e instanceof Error) {
|
|
175
|
-
logger.error(`Error message: ${e.message}`);
|
|
176
|
-
logger.error(`Error stack: ${e.stack}`);
|
|
177
|
-
} else {
|
|
178
|
-
logger.error(`Error details: ${JSON.stringify(e)}`);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
async updateDeviceInfo(): Promise<void> {
|
|
184
|
-
const logger = this.getBaichuanLogger();
|
|
185
|
-
try {
|
|
186
|
-
const api = await this.ensureBaichuanClient();
|
|
187
|
-
const deviceData = await api.getInfo();
|
|
188
|
-
|
|
189
|
-
await updateDeviceInfo({
|
|
190
|
-
device: this,
|
|
191
|
-
deviceData,
|
|
192
|
-
ipAddress: this.storageSettings.values.ipAddress,
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
logger.log(`Device info updated: ${JSON.stringify(deviceData)}`);
|
|
196
|
-
} catch (e) {
|
|
197
|
-
logger.warn('Failed to fetch device info', e);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
async syncEntitiesFromRemote() {
|
|
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
|
-
}
|
|
209
|
-
|
|
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 {
|
|
217
|
-
// const channelsInfo = await api.getNvrChannelsInfo();
|
|
218
|
-
// const deviceInfo = await api.getInfo();
|
|
219
|
-
const { support, abilities, features, capabilities } = await api.getDeviceCapabilities();
|
|
220
|
-
const channelNum = support?.channelNum ?? 1;
|
|
221
|
-
logger.log(`Sync entities from remote for ${channelNum} channels`);
|
|
222
|
-
const channels = Array.from({ length: channelNum }, (_, i) => i + 1);
|
|
223
|
-
|
|
224
|
-
const multifocalInfo = await api.getDualLensChannelInfo();
|
|
225
|
-
|
|
226
|
-
logger.log(`Multichannel info: ${JSON.stringify({ multifocalInfo, abilities, features, capabilities })}`);
|
|
227
|
-
|
|
228
|
-
// if (channelNum === 2) {
|
|
229
|
-
|
|
230
|
-
// }
|
|
231
|
-
|
|
232
|
-
for (const channel of channels) {
|
|
233
|
-
// try {
|
|
234
|
-
// const name = deviceInfo?.name || `Channel ${channel}`;
|
|
235
|
-
// const uid = deviceInfo?.uid;
|
|
236
|
-
// const isBattery = !!(abilities?.battery?.ver ?? 0);
|
|
237
|
-
|
|
238
|
-
// const nativeId = this.buildNativeId(channel, uid, isBattery);
|
|
239
|
-
// const interfaces = [ScryptedInterface.VideoCamera];
|
|
240
|
-
// if (isBattery) {
|
|
241
|
-
// interfaces.push(ScryptedInterface.Battery);
|
|
242
|
-
// }
|
|
243
|
-
// const type = abilities.supportDoorbellLight ? ScryptedDeviceType.Doorbell : ScryptedDeviceType.Camera;
|
|
244
|
-
|
|
245
|
-
// const device: Device = {
|
|
246
|
-
// nativeId,
|
|
247
|
-
// name,
|
|
248
|
-
// providerNativeId: this.nativeId,
|
|
249
|
-
// interfaces,
|
|
250
|
-
// type,
|
|
251
|
-
// info: {
|
|
252
|
-
// manufacturer: 'Reolink',
|
|
253
|
-
// model: channelInfo?.typeInfo,
|
|
254
|
-
// serialNumber: uid,
|
|
255
|
-
// }
|
|
256
|
-
// };
|
|
257
|
-
|
|
258
|
-
// this.channelToNativeIdMap.set(channel, nativeId);
|
|
259
|
-
|
|
260
|
-
// if (sdk.deviceManager.getNativeIds().includes(nativeId)) {
|
|
261
|
-
// continue;
|
|
262
|
-
// }
|
|
263
|
-
|
|
264
|
-
// if (this.discoveredDevices.has(nativeId)) {
|
|
265
|
-
// continue;
|
|
266
|
-
// }
|
|
267
|
-
|
|
268
|
-
// this.discoveredDevices.set(nativeId, {
|
|
269
|
-
// device,
|
|
270
|
-
// description: `${name} (Channel ${channel})`,
|
|
271
|
-
// rtspChannel: channel,
|
|
272
|
-
// deviceData: devicesData[channel],
|
|
273
|
-
// });
|
|
274
|
-
|
|
275
|
-
// logger.debug(`Discovered channel ${channel}: ${name}`);
|
|
276
|
-
// } catch (e: any) {
|
|
277
|
-
// logger.debug(`Error processing channel ${channel}: ${e?.message || String(e)}`);
|
|
278
|
-
// }
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// logger.log(`Channel discovery completed. ${JSON.stringify({ devicesData, channels })}`);
|
|
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;
|
|
294
|
-
}
|
|
295
|
-
})();
|
|
296
|
-
|
|
297
|
-
await this.syncPromise;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
async discoverDevices(scan?: boolean): Promise<DiscoveredDevice[]> {
|
|
301
|
-
if (scan) {
|
|
302
|
-
await this.syncEntitiesFromRemote();
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return [...this.discoveredDevices.values()].map(d => ({
|
|
306
|
-
...d.device,
|
|
307
|
-
description: d.description,
|
|
308
|
-
}));
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
async adoptDevice(adopt: AdoptDevice): Promise<string> {
|
|
312
|
-
const entry = this.discoveredDevices.get(adopt.nativeId);
|
|
313
|
-
|
|
314
|
-
if (!entry)
|
|
315
|
-
throw new Error('device not found');
|
|
316
|
-
|
|
317
|
-
await this.onDeviceEvent(ScryptedInterface.DeviceDiscovery, await this.discoverDevices());
|
|
318
|
-
|
|
319
|
-
const isBattery = entry.device.interfaces.includes(ScryptedInterface.Battery);
|
|
320
|
-
const { channelStatus } = entry.deviceData;
|
|
321
|
-
|
|
322
|
-
const { ReolinkBaichuanApi } = await import("@apocaliss92/reolink-baichuan-js");
|
|
323
|
-
const transport = this.protocol;
|
|
324
|
-
const uid = channelStatus?.uid || this.storageSettings.values.uid;
|
|
325
|
-
// For battery cameras or UDP transport, use UID if available
|
|
326
|
-
const normalizedUid = (isBattery || transport === 'udp') && uid ? normalizeUid(uid) : undefined;
|
|
327
|
-
const baichuanApi = new ReolinkBaichuanApi({
|
|
328
|
-
host: this.storageSettings.values.ipAddress,
|
|
329
|
-
username: this.storageSettings.values.username,
|
|
330
|
-
password: this.storageSettings.values.password,
|
|
331
|
-
transport,
|
|
332
|
-
channel: entry.rtspChannel,
|
|
333
|
-
...(normalizedUid ? { uid: normalizedUid } : {}),
|
|
334
|
-
});
|
|
335
|
-
await baichuanApi.login();
|
|
336
|
-
const { capabilities, objects, presets } = await baichuanApi.getDeviceCapabilities(entry.rtspChannel);
|
|
337
|
-
const { interfaces, type } = getDeviceInterfaces({
|
|
338
|
-
capabilities,
|
|
339
|
-
logger: this.console,
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
const actualDevice: Device = {
|
|
343
|
-
...entry.device,
|
|
344
|
-
interfaces,
|
|
345
|
-
type
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
await sdk.deviceManager.onDeviceDiscovered(actualDevice);
|
|
349
|
-
|
|
350
|
-
const device = await this.getDevice(adopt.nativeId);
|
|
351
|
-
if (device instanceof ReolinkNativeCamera || device instanceof ReolinkNativeBatteryCamera) {
|
|
352
|
-
device.storageSettings.values.ipAddress = this.storageSettings.values.ipAddress;
|
|
353
|
-
device.storageSettings.values.username = this.storageSettings.values.username;
|
|
354
|
-
device.storageSettings.values.password = this.storageSettings.values.password;
|
|
355
|
-
device.storageSettings.values.rtspChannel = entry.rtspChannel;
|
|
356
|
-
// Set multiFocalDevice reference through options (similar to how NVR does it)
|
|
357
|
-
(device).options = { ...(device).options, multiFocalDevice: this, nvrDevice: undefined };
|
|
358
|
-
device.classes = objects;
|
|
359
|
-
device.presets = presets;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
return adopt.nativeId;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
async getDevice(nativeId: string): Promise<ReolinkNativeCamera | ReolinkNativeBatteryCamera> {
|
|
366
|
-
if (this.cameraNativeMap.has(nativeId)) {
|
|
367
|
-
return this.cameraNativeMap.get(nativeId)!;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
const entry = this.discoveredDevices.get(nativeId);
|
|
371
|
-
if (!entry) {
|
|
372
|
-
throw new Error(`Device ${nativeId} not found`);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
const isBattery = entry.device.interfaces.includes(ScryptedInterface.Battery);
|
|
376
|
-
const cameraNativeId = entry.device.nativeId;
|
|
377
|
-
const camera = isBattery
|
|
378
|
-
? new ReolinkNativeBatteryCamera(cameraNativeId, this.plugin, { type: 'battery', multiFocalDevice: this, nvrDevice: undefined })
|
|
379
|
-
: new ReolinkNativeCamera(cameraNativeId, this.plugin, { type: 'regular', multiFocalDevice: this, nvrDevice: undefined });
|
|
380
|
-
|
|
381
|
-
this.cameraNativeMap.set(nativeId, camera);
|
|
382
|
-
return camera;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
async getSettings(): Promise<Setting[]> {
|
|
386
|
-
const settings = await this.storageSettings.getSettings();
|
|
387
|
-
return settings;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
async putSetting(key: string, value: SettingValue): Promise<void> {
|
|
391
|
-
return this.storageSettings.putSetting(key, value);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
async releaseDevice(id: string, nativeId: string) {
|
|
395
|
-
this.cameraNativeMap.delete(nativeId);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
buildNativeId(channel: number, uid?: string, isBattery?: boolean): string {
|
|
399
|
-
const serialNumber = uid || this.storageSettings.values.ipAddress || 'unknown';
|
|
400
|
-
const suffix = isBattery ? '-battery-cam' : '-cam';
|
|
401
|
-
return `${serialNumber}-channel${channel}${suffix}`;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
forwardNativeEvent(ev: ReolinkSimpleEvent): void {
|
|
405
|
-
if (this.processing) {
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
const logger = this.getBaichuanLogger();
|
|
410
|
-
const channel = ev?.channel;
|
|
411
|
-
|
|
412
|
-
if (channel === undefined) {
|
|
413
|
-
logger.debug('Event missing channel, ignoring');
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
const nativeId = this.channelToNativeIdMap.get(channel);
|
|
418
|
-
if (!nativeId) {
|
|
419
|
-
logger.debug(`No camera found for channel ${channel}, ignoring event`);
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const camera = this.cameraNativeMap.get(nativeId);
|
|
424
|
-
if (!camera) {
|
|
425
|
-
logger.debug(`Camera ${nativeId} not yet initialized, ignoring event`);
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// Forward event to camera
|
|
430
|
-
if (camera.onSimpleEvent) {
|
|
431
|
-
camera.onSimpleEvent(ev);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
async subscribeToAllEvents(): Promise<void> {
|
|
436
|
-
const logger = this.getBaichuanLogger();
|
|
437
|
-
logger.log('Subscribed to all events for multi-focal device cameras');
|
|
438
|
-
await this.subscribeToEvents();
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
private async runDiagnostics(): Promise<void> {
|
|
442
|
-
const logger = this.getBaichuanLogger();
|
|
443
|
-
logger.log(`Starting Multifocal diagnostics...`);
|
|
444
|
-
|
|
445
|
-
try {
|
|
446
|
-
const { ipAddress, username, password } = this.storageSettings.values;
|
|
447
|
-
if (!ipAddress || !username || !password) {
|
|
448
|
-
throw new Error('Missing device credentials');
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const api = await this.ensureBaichuanClient();
|
|
452
|
-
|
|
453
|
-
const multifocalDiagnostics = await api.collectMultifocalDiagnostics(logger);
|
|
454
|
-
|
|
455
|
-
logger.log(`NVR diagnostics completed successfully.`);
|
|
456
|
-
logger.log(JSON.stringify(multifocalDiagnostics));
|
|
457
|
-
} catch (e) {
|
|
458
|
-
logger.error('Failed to run NVR diagnostics', e);
|
|
459
|
-
throw e;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|