@bits-innovate/react-native-vstarcam 1.0.33 → 1.0.35
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.
|
@@ -103,6 +103,11 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
103
103
|
if (did == null || did.length() < 4) {
|
|
104
104
|
return SERVICE_PARAM_MAP.get("DEFAULT");
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
// Special case: If it was converted from an ACAE/ACxx virtual UID,
|
|
108
|
+
// it might work better with the vstarcam2018 parameters even if the real prefix is VSTJ/VSTN.
|
|
109
|
+
// However, we'll try prefix-specific first.
|
|
110
|
+
|
|
106
111
|
String prefix = did.substring(0, 4).toUpperCase();
|
|
107
112
|
String param = SERVICE_PARAM_MAP.get(prefix);
|
|
108
113
|
if (param == null) {
|
|
@@ -168,7 +173,7 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
168
173
|
|
|
169
174
|
// Client tracking - maps our clientPtr to actual SDK client handle
|
|
170
175
|
// Made static so VStarCamVideoView can access SDK pointers
|
|
171
|
-
private static Map<Integer, ClientInfo> clients = new
|
|
176
|
+
private static Map<Integer, ClientInfo> clients = new java.util.concurrent.ConcurrentHashMap<>();
|
|
172
177
|
private boolean isNativeLibraryLoaded = false;
|
|
173
178
|
private boolean isP2PInitialized = false;
|
|
174
179
|
|
|
@@ -336,20 +341,11 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
336
341
|
|
|
337
342
|
Log.d(TAG, "ClientCommandListener." + methodName + " called");
|
|
338
343
|
if (methodName.equals("commandListener")) {
|
|
339
|
-
|
|
340
|
-
final long clientPtr = (Long) args[0];
|
|
344
|
+
final long sdkPtr = (Long) args[0];
|
|
341
345
|
final byte[] data = (byte[]) args[1];
|
|
342
346
|
final int length = (Integer) args[2];
|
|
343
|
-
Log.d(TAG, "Command callback:
|
|
344
|
-
|
|
345
|
-
if (reactContext != null) {
|
|
346
|
-
reactContext.runOnUiQueueThread(new Runnable() {
|
|
347
|
-
@Override
|
|
348
|
-
public void run() {
|
|
349
|
-
handleCommandReceive(clientPtr, 0, data);
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
}
|
|
347
|
+
Log.d(TAG, "Command callback: sdkPtr=" + sdkPtr + ", len=" + length);
|
|
348
|
+
handleCommandReceive(sdkPtr, 0, data);
|
|
353
349
|
}
|
|
354
350
|
} catch (Exception e) {
|
|
355
351
|
Log.e(TAG, "Error in commandListener callback", e);
|
|
@@ -378,8 +374,18 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
378
374
|
|
|
379
375
|
Log.d(TAG, "ClientReleaseListener." + methodName + " called");
|
|
380
376
|
if (methodName.equals("releaseListener")) {
|
|
381
|
-
final long
|
|
382
|
-
Log.d(TAG, "Release callback:
|
|
377
|
+
final long sdkPtr = (Long) args[0];
|
|
378
|
+
Log.d(TAG, "Release callback: sdkPtr=" + sdkPtr);
|
|
379
|
+
|
|
380
|
+
// Clean up our reference to this SDK pointer
|
|
381
|
+
for (ClientInfo info : clients.values()) {
|
|
382
|
+
if (info.sdkClientPtr == sdkPtr) {
|
|
383
|
+
Log.d(TAG, "SDK released client: " + info.deviceId + " (clearing sdkClientPtr)");
|
|
384
|
+
info.sdkClientPtr = 0;
|
|
385
|
+
info.isConnected = false;
|
|
386
|
+
info.isLoggedIn = false;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
383
389
|
}
|
|
384
390
|
} catch (Exception e) {
|
|
385
391
|
Log.e(TAG, "Error in releaseListener callback", e);
|
|
@@ -584,6 +590,13 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
584
590
|
try {
|
|
585
591
|
Object result = connectMethod.invoke(null, clientInfo.sdkClientPtr, 15, param, actualConnectType);
|
|
586
592
|
Log.d(TAG, "JNIApi.connect result: " + result);
|
|
593
|
+
|
|
594
|
+
int res = (Integer) result;
|
|
595
|
+
if (res != 0 && res != 1) {
|
|
596
|
+
Log.w(TAG, "JNIApi.connect failed with code: " + res);
|
|
597
|
+
promise.reject("CONNECT_FAILED", "SDK connect error code: " + res);
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
587
600
|
} catch (java.lang.reflect.InvocationTargetException ite) {
|
|
588
601
|
Log.e(TAG, "JNIApi.connect threw exception: " + ite.getCause(), ite.getCause());
|
|
589
602
|
throw ite;
|
|
@@ -966,6 +979,13 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
966
979
|
Log.d(TAG, "Verifying network: " + cgi);
|
|
967
980
|
Object result = writeCgiMethod.invoke(null, clientInfo.sdkClientPtr, cgi, 5);
|
|
968
981
|
|
|
982
|
+
boolean writeSuccess = (result instanceof Boolean) ? (Boolean) result : true;
|
|
983
|
+
if (!writeSuccess) {
|
|
984
|
+
Log.w(TAG, "Network verification failed: writeCgi returned false");
|
|
985
|
+
promise.reject("E_NOT_RESPONSIVE", "Camera not responsive to commands");
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
|
|
969
989
|
// If we reach here, the CGI command was at least sent.
|
|
970
990
|
// We'll return a basic object representing success for now.
|
|
971
991
|
WritableMap response = Arguments.createMap();
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -151,6 +151,7 @@ export interface DeviceInfo {
|
|
|
151
151
|
motionDetection: boolean;
|
|
152
152
|
wifi: boolean;
|
|
153
153
|
};
|
|
154
|
+
responsive?: boolean;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
// Connection result
|
|
@@ -406,35 +407,14 @@ class VStarCamClient {
|
|
|
406
407
|
* Get device information
|
|
407
408
|
*/
|
|
408
409
|
async getDeviceInfo(): Promise<DeviceInfo | null> {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
this.removeCommandListener(handler);
|
|
418
|
-
const params = this.parseResponse(new TextDecoder().decode(data));
|
|
419
|
-
|
|
420
|
-
resolve({
|
|
421
|
-
serialNumber: params["id"] || "",
|
|
422
|
-
model: params["model"] || "",
|
|
423
|
-
firmware: params["sys_ver"] || "",
|
|
424
|
-
manufacturer: "VStarCam",
|
|
425
|
-
features: {
|
|
426
|
-
ptz: params["ptz"] === "1",
|
|
427
|
-
audio: params["haveAudio"] === "1",
|
|
428
|
-
twoWayAudio: params["support_talk"] === "1",
|
|
429
|
-
nightVision: params["haveIR"] === "1",
|
|
430
|
-
motionDetection: params["support_alarm"] === "1",
|
|
431
|
-
wifi: params["haveWifi"] === "1",
|
|
432
|
-
},
|
|
433
|
-
});
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
this.addCommandListener(handler);
|
|
437
|
-
});
|
|
410
|
+
try {
|
|
411
|
+
// The native module handles credentials and basic command sending.
|
|
412
|
+
// It returns a promise that resolves with the device info and responsive: true.
|
|
413
|
+
return await VStarCamModule.clientGetDeviceInfo(this.clientPtr);
|
|
414
|
+
} catch (e) {
|
|
415
|
+
console.error("[VStarCam] getDeviceInfo failed:", e);
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
438
418
|
}
|
|
439
419
|
|
|
440
420
|
/**
|