@bits-innovate/react-native-vstarcam 1.0.38 → 1.0.40

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.
@@ -80,7 +80,6 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
80
80
  put("ACAE", "EEGDFHBLKGJIGEJLEKGOFMEDHAMHHJNAGGFABMCOBGJOLHLJDFAFCPPHGILKIKLMANNHKEDKOINIBNCPJOMK:vstarcam2018"); // Try VSTH params
81
81
  put("ACDG", "EEGDFHBLKGJIGEJLEKGOFMEDHAMHHJNAGGFABMCOBGJOLHLJDFAFCPPHGILKIKLMANNHKEDKOINIBNCPJOMK:vstarcam2018"); // Same as ACAE/VSTH
82
82
  put("ACAQ", "EEGDFHBLKGJIGEJLEKGOFMEDHAMHHJNAGGFABMCOBGJOLHLJDFAFCPPHGILKIKLMANNHKEDKOINIBNCPJOMK:vstarcam2018"); // Same as ACAE/VSTH
83
- put("ACAG", "EEGDFHBLKGJIGEJLEKGOFMEDHAMHHJNAGGFABMCOBGJOLHLJDFAFCPPHGILKIKLMANNHKEDKOINIBNCPJOMK:vstarcam2018"); // Same as ACAE/VSTH
84
83
  // Fallback for unknown prefixes
85
84
  put("DEFAULT", "EBGBEMBMKGJMGAJPEIGIFKEGHBMCHMNFGKEGBFCBBMJELILDCJADCIOLHHLLJBKEAMMBLCDGONMDBJCJJPNFJP");
86
85
  }};
@@ -155,7 +154,7 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
155
154
 
156
155
  // Client tracking - maps our clientPtr to actual SDK client handle
157
156
  // Made static so VStarCamVideoView can access SDK pointers
158
- private static Map<Integer, ClientInfo> clients = new java.util.concurrent.ConcurrentHashMap<>();
157
+ private static Map<Integer, ClientInfo> clients = new HashMap<>();
159
158
  private boolean isNativeLibraryLoaded = false;
160
159
  private boolean isP2PInitialized = false;
161
160
 
@@ -461,8 +460,8 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
461
460
  return;
462
461
  }
463
462
 
464
- // Generate a unique internal client ID
465
- int ourClientPtr = nextClientPtr.getAndIncrement();
463
+ // Generate our own client ID (hash of deviceId) and store mapping
464
+ int ourClientPtr = Math.abs(deviceId.hashCode());
466
465
 
467
466
  ClientInfo clientInfo = new ClientInfo();
468
467
  clientInfo.deviceId = deviceId;
@@ -580,23 +579,11 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
580
579
 
581
580
  Log.d(TAG, "Calling JNIApi.login(" + clientInfo.sdkClientPtr + ", " + username + ", ***)");
582
581
 
583
- boolean loginResult = false;
582
+ boolean loginSuccess = false;
584
583
  try {
585
- Object result = loginMethod.invoke(null, clientInfo.sdkClientPtr, username, password);
586
- Log.d(TAG, "JNIApi.login result: " + result);
587
- // result is likely boolean based on signature log
588
- if (result instanceof Boolean) {
589
- loginResult = (Boolean) result;
590
- } else if (result instanceof Integer) {
591
- int res = (Integer) result;
592
- Log.d(TAG, "JNIApi.login integer result: " + res);
593
- // If it's a handle or 0 (success), treat as true
594
- loginResult = (res >= 0 || res < -2); // Permissive: only reject -1, -2 as common errors
595
- } else if (result != null) {
596
- loginResult = true; // Non-null result usually means success
597
- } else {
598
- loginResult = true; // result == null (void return) means success if no exception
599
- }
584
+ loginMethod.invoke(null, clientInfo.sdkClientPtr, username, password);
585
+ Log.d(TAG, "JNIApi.login returned normally");
586
+ loginSuccess = true;
600
587
  } catch (java.lang.reflect.InvocationTargetException ite) {
601
588
  Throwable cause = ite.getCause();
602
589
  Log.e(TAG, "JNIApi.login threw exception: " + cause, cause);
@@ -608,14 +595,14 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
608
595
  return;
609
596
  }
610
597
 
611
- if (loginResult) {
598
+ if (loginSuccess) {
612
599
  clientInfo.isLoggedIn = true;
613
600
  clientInfo.username = username;
614
601
  clientInfo.password = password;
615
602
  }
616
603
 
617
- Log.d(TAG, "JNIApi.login completed with result: " + loginResult);
618
- promise.resolve(loginResult);
604
+ Log.d(TAG, "JNIApi.login completed with result: " + loginSuccess);
605
+ promise.resolve(loginSuccess);
619
606
  } catch (Exception e) {
620
607
  Log.e(TAG, "clientLogin failed", e);
621
608
  promise.reject("LOGIN_ERROR", e.getMessage());
@@ -740,6 +727,42 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
740
727
  });
741
728
  }
742
729
 
730
+ /**
731
+ * Get device information
732
+ */
733
+ @ReactMethod
734
+ public void clientGetDeviceInfo(int clientPtr, Promise promise) {
735
+ executor.execute(() -> {
736
+ try {
737
+ ClientInfo clientInfo = clients.get(clientPtr);
738
+ if (clientInfo == null) {
739
+ promise.reject("E_CLIENT_NOT_FOUND", "Client not found");
740
+ return;
741
+ }
742
+
743
+ WritableMap result = Arguments.createMap();
744
+ result.putString("serialNumber", clientInfo.deviceId);
745
+ result.putString("model", "VStarCam");
746
+ result.putString("firmware", "Unknown");
747
+ result.putString("manufacturer", "VStarCam");
748
+ result.putBoolean("responsive", clientInfo.isConnected);
749
+
750
+ WritableMap features = Arguments.createMap();
751
+ features.putBoolean("ptz", true);
752
+ features.putBoolean("audio", true);
753
+ features.putBoolean("twoWayAudio", true);
754
+ features.putBoolean("nightVision", true);
755
+ features.putBoolean("motionDetection", true);
756
+ features.putBoolean("wifi", true);
757
+ result.putMap("features", features);
758
+
759
+ promise.resolve(result);
760
+ } catch (Exception e) {
761
+ promise.reject("E_GET_INFO_FAILED", e.getMessage());
762
+ }
763
+ });
764
+ }
765
+
743
766
  /**
744
767
  * Start video stream by sending livestream.cgi command
745
768
  * Resolution: 1=high, 2=general, 4=low, 100=superHD
@@ -842,6 +865,10 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
842
865
  } catch (Exception e) {
843
866
  Log.e(TAG, "checkMode JNI call failed", e);
844
867
  }
868
+ } else {
869
+ Log.w(TAG, "checkMode skipped: clientInfo=" + clientInfo +
870
+ ", jniApiClass=" + (jniApiClass != null) +
871
+ ", sdkPtr=" + (clientInfo != null ? clientInfo.sdkClientPtr : "null"));
845
872
  }
846
873
 
847
874
  // Mode > 0 means connected (1=P2P, 2=Relay, 3=Socket)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bits-innovate/react-native-vstarcam",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "React Native bridge for VStarCam P2P SDK",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/index.ts CHANGED
@@ -279,6 +279,15 @@ class VStarCamClient {
279
279
  };
280
280
  }
281
281
 
282
+ /**
283
+ * Check the current connection mode
284
+ * @returns Mode result including connection type and session handle
285
+ */
286
+ async checkConnectionMode(): Promise<any> {
287
+ if (!this.clientPtr) return { success: false, mode: 0 };
288
+ return VStarCamModule.clientCheckMode(this.clientPtr);
289
+ }
290
+
282
291
  /**
283
292
  * Login to the camera
284
293
  * @param username Camera username (default: admin)