@bits-innovate/react-native-vstarcam 1.0.49 → 1.0.50
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/package.json +1 -1
- package/src/index.ts +13 -5
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -213,6 +213,8 @@ export type VideoFrameListener = (
|
|
|
213
213
|
*/
|
|
214
214
|
class VStarCamClient {
|
|
215
215
|
private clientPtr: number = 0;
|
|
216
|
+
private currentUsername: string = "admin";
|
|
217
|
+
private currentPassword: string = "888888";
|
|
216
218
|
private eventEmitter: NativeEventEmitter;
|
|
217
219
|
private connectionListeners: Set<ConnectionEventListener> = new Set();
|
|
218
220
|
private commandListeners: Set<CommandEventListener> = new Set();
|
|
@@ -328,6 +330,8 @@ class VStarCamClient {
|
|
|
328
330
|
password: string = "888888"
|
|
329
331
|
): Promise<boolean> {
|
|
330
332
|
if (!this.clientPtr) return false;
|
|
333
|
+
this.currentUsername = username;
|
|
334
|
+
this.currentPassword = password;
|
|
331
335
|
return VStarCamModule.clientLogin(this.clientPtr, username, password);
|
|
332
336
|
}
|
|
333
337
|
|
|
@@ -458,28 +462,32 @@ class VStarCamClient {
|
|
|
458
462
|
/**
|
|
459
463
|
* PTZ Control - Move camera
|
|
460
464
|
*/
|
|
465
|
+
private getPtzBaseParams(): string {
|
|
466
|
+
return `loginuse=${encodeURIComponent(this.currentUsername)}&loginpas=${encodeURIComponent(this.currentPassword)}`;
|
|
467
|
+
}
|
|
468
|
+
|
|
461
469
|
async ptzUp(continuous: boolean = false): Promise<boolean> {
|
|
462
470
|
const cmd = continuous ? "command=0&onestep=0" : "command=0&onestep=1";
|
|
463
|
-
return this.sendCommand(`decoder_control.cgi?${cmd}&`);
|
|
471
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&${cmd}&`);
|
|
464
472
|
}
|
|
465
473
|
|
|
466
474
|
async ptzDown(continuous: boolean = false): Promise<boolean> {
|
|
467
475
|
const cmd = continuous ? "command=2&onestep=0" : "command=2&onestep=1";
|
|
468
|
-
return this.sendCommand(`decoder_control.cgi?${cmd}&`);
|
|
476
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&${cmd}&`);
|
|
469
477
|
}
|
|
470
478
|
|
|
471
479
|
async ptzLeft(continuous: boolean = false): Promise<boolean> {
|
|
472
480
|
const cmd = continuous ? "command=4&onestep=0" : "command=5&onestep=1";
|
|
473
|
-
return this.sendCommand(`decoder_control.cgi?${cmd}&`);
|
|
481
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&${cmd}&`);
|
|
474
482
|
}
|
|
475
483
|
|
|
476
484
|
async ptzRight(continuous: boolean = false): Promise<boolean> {
|
|
477
485
|
const cmd = continuous ? "command=6&onestep=0" : "command=7&onestep=1";
|
|
478
|
-
return this.sendCommand(`decoder_control.cgi?${cmd}&`);
|
|
486
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&${cmd}&`);
|
|
479
487
|
}
|
|
480
488
|
|
|
481
489
|
async ptzStop(): Promise<boolean> {
|
|
482
|
-
return this.sendCommand(
|
|
490
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&command=1&onestep=0&`);
|
|
483
491
|
}
|
|
484
492
|
|
|
485
493
|
/**
|