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

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.
@@ -580,23 +580,11 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
580
580
 
581
581
  Log.d(TAG, "Calling JNIApi.login(" + clientInfo.sdkClientPtr + ", " + username + ", ***)");
582
582
 
583
- boolean loginResult = false;
583
+ boolean loginSuccess = false;
584
584
  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
- }
585
+ loginMethod.invoke(null, clientInfo.sdkClientPtr, username, password);
586
+ Log.d(TAG, "JNIApi.login returned normally");
587
+ loginSuccess = true;
600
588
  } catch (java.lang.reflect.InvocationTargetException ite) {
601
589
  Throwable cause = ite.getCause();
602
590
  Log.e(TAG, "JNIApi.login threw exception: " + cause, cause);
@@ -608,14 +596,14 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
608
596
  return;
609
597
  }
610
598
 
611
- if (loginResult) {
599
+ if (loginSuccess) {
612
600
  clientInfo.isLoggedIn = true;
613
601
  clientInfo.username = username;
614
602
  clientInfo.password = password;
615
603
  }
616
604
 
617
- Log.d(TAG, "JNIApi.login completed with result: " + loginResult);
618
- promise.resolve(loginResult);
605
+ Log.d(TAG, "JNIApi.login completed with result: " + loginSuccess);
606
+ promise.resolve(loginSuccess);
619
607
  } catch (Exception e) {
620
608
  Log.e(TAG, "clientLogin failed", e);
621
609
  promise.reject("LOGIN_ERROR", e.getMessage());
@@ -740,6 +728,42 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
740
728
  });
741
729
  }
742
730
 
731
+ /**
732
+ * Get device information
733
+ */
734
+ @ReactMethod
735
+ public void clientGetDeviceInfo(int clientPtr, Promise promise) {
736
+ executor.execute(() -> {
737
+ try {
738
+ ClientInfo clientInfo = clients.get(clientPtr);
739
+ if (clientInfo == null) {
740
+ promise.reject("E_CLIENT_NOT_FOUND", "Client not found");
741
+ return;
742
+ }
743
+
744
+ WritableMap result = Arguments.createMap();
745
+ result.putString("serialNumber", clientInfo.deviceId);
746
+ result.putString("model", "VStarCam");
747
+ result.putString("firmware", "Unknown");
748
+ result.putString("manufacturer", "VStarCam");
749
+ result.putBoolean("responsive", clientInfo.isConnected);
750
+
751
+ WritableMap features = Arguments.createMap();
752
+ features.putBoolean("ptz", true);
753
+ features.putBoolean("audio", true);
754
+ features.putBoolean("twoWayAudio", true);
755
+ features.putBoolean("nightVision", true);
756
+ features.putBoolean("motionDetection", true);
757
+ features.putBoolean("wifi", true);
758
+ result.putMap("features", features);
759
+
760
+ promise.resolve(result);
761
+ } catch (Exception e) {
762
+ promise.reject("E_GET_INFO_FAILED", e.getMessage());
763
+ }
764
+ });
765
+ }
766
+
743
767
  /**
744
768
  * Start video stream by sending livestream.cgi command
745
769
  * Resolution: 1=high, 2=general, 4=low, 100=superHD
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.39",
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)