@bits-innovate/react-native-vstarcam 1.0.44 → 1.0.45

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.
@@ -433,13 +433,26 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
433
433
  }
434
434
 
435
435
  private void sendEvent(String eventName, @Nullable WritableMap params) {
436
- if (reactContext.hasActiveReactInstance()) {
436
+ if (reactContext != null && reactContext.hasActiveReactInstance()) {
437
437
  reactContext
438
438
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
439
439
  .emit(eventName, params);
440
440
  }
441
441
  }
442
442
 
443
+ /**
444
+ * Test the bridge connection
445
+ */
446
+ @ReactMethod
447
+ public void testBridge(Promise promise) {
448
+ Log.d(TAG, "testBridge called");
449
+ WritableMap result = Arguments.createMap();
450
+ result.putBoolean("success", true);
451
+ result.putString("message", "Bridge is working");
452
+ result.putDouble("timestamp", (double) System.currentTimeMillis());
453
+ promise.resolve(result);
454
+ }
455
+
443
456
  /**
444
457
  * Create a P2P client for a device
445
458
  * JNIApi.create(String did, String serverParam) -> long
@@ -482,8 +495,8 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
482
495
  return;
483
496
  }
484
497
 
485
- // Generate our own client ID (hash of deviceId) and store mapping
486
- int ourClientPtr = Math.abs(deviceId.hashCode());
498
+ // Generate our own client ID and store mapping
499
+ int ourClientPtr = nextClientPtr.getAndIncrement();
487
500
 
488
501
  ClientInfo clientInfo = new ClientInfo();
489
502
  clientInfo.deviceId = deviceId;
@@ -774,16 +787,20 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
774
787
  */
775
788
  @ReactMethod
776
789
  public void clientGetDeviceInfo(int clientPtr, Promise promise) {
790
+ Log.d(TAG, "clientGetDeviceInfo called for ptr: " + clientPtr);
777
791
  executor.execute(() -> {
778
792
  try {
779
793
  ClientInfo clientInfo = clients.get(clientPtr);
780
794
  if (clientInfo == null) {
795
+ Log.w(TAG, "clientGetDeviceInfo: client not found for ptr " + clientPtr);
781
796
  promise.reject("E_CLIENT_NOT_FOUND", "Client not found");
782
797
  return;
783
798
  }
784
799
 
800
+ Log.d(TAG, "Fetching device info for device: " + clientInfo.deviceId);
801
+
785
802
  WritableMap result = Arguments.createMap();
786
- result.putString("serialNumber", clientInfo.deviceId);
803
+ result.putString("serialNumber", clientInfo.deviceId != null ? clientInfo.deviceId : "Unknown");
787
804
  result.putString("model", "VStarCam");
788
805
  result.putString("firmware", "Unknown");
789
806
  result.putString("manufacturer", "VStarCam");
@@ -798,9 +815,11 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
798
815
  features.putBoolean("wifi", true);
799
816
  result.putMap("features", features);
800
817
 
818
+ Log.d(TAG, "Resolving device info for " + clientInfo.deviceId);
801
819
  promise.resolve(result);
802
- } catch (Exception e) {
803
- promise.reject("E_GET_INFO_FAILED", e.getMessage());
820
+ } catch (Throwable t) {
821
+ Log.e(TAG, "clientGetDeviceInfo crashed: " + t.getMessage(), t);
822
+ promise.reject("E_GET_INFO_FAILED", t.getMessage());
804
823
  }
805
824
  });
806
825
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bits-innovate/react-native-vstarcam",
3
- "version": "1.0.44",
3
+ "version": "1.0.45",
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
@@ -237,6 +237,10 @@ class VStarCamClient {
237
237
  });
238
238
  }
239
239
 
240
+ async testBridge(): Promise<any> {
241
+ return VStarCamModule.testBridge();
242
+ }
243
+
240
244
  /**
241
245
  * Create a P2P client for a device
242
246
  * @param deviceId The device ID (DID) from VStarCam