@bits-innovate/react-native-vstarcam 1.0.27 → 1.0.29

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.
@@ -288,6 +288,12 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
288
288
  } catch (Exception e) {
289
289
  Log.e(TAG, "Error in stateListener callback", e);
290
290
  }
291
+
292
+ // Handle return type
293
+ Class<?> returnType = method.getReturnType();
294
+ if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
295
+ return 0;
296
+ }
291
297
  return null;
292
298
  }
293
299
  }
@@ -321,6 +327,12 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
321
327
  } catch (Exception e) {
322
328
  Log.e(TAG, "Error in commandListener callback", e);
323
329
  }
330
+
331
+ // Handle return type
332
+ Class<?> returnType = method.getReturnType();
333
+ if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
334
+ return 0;
335
+ }
324
336
  return null;
325
337
  }
326
338
  }
@@ -338,6 +350,12 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
338
350
  } catch (Exception e) {
339
351
  Log.e(TAG, "Error in releaseListener callback", e);
340
352
  }
353
+
354
+ // Handle return type
355
+ Class<?> returnType = method.getReturnType();
356
+ if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
357
+ return 0;
358
+ }
341
359
  return null;
342
360
  }
343
361
  }
@@ -883,6 +901,44 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
883
901
  promise.resolve(result);
884
902
  }
885
903
 
904
+ /**
905
+ * Get device info via get_status.cgi
906
+ */
907
+ @ReactMethod
908
+ public void clientGetDeviceInfo(int clientPtr, Promise promise) {
909
+ executor.execute(() -> {
910
+ try {
911
+ ClientInfo clientInfo = clients.get(clientPtr);
912
+ if (clientInfo == null || clientInfo.sdkClientPtr == 0) {
913
+ promise.reject("E_NOT_CONNECTED", "Client not connected");
914
+ return;
915
+ }
916
+
917
+ // Use get_status.cgi to check if camera is responsive on network
918
+ String cgi = "get_status.cgi?loginuse=admin&loginpas=888888";
919
+ if (clientInfo.username != null) {
920
+ cgi = String.format("get_status.cgi?loginuse=%s&loginpas=%s",
921
+ clientInfo.username, clientInfo.password);
922
+ }
923
+
924
+ Method writeCgiMethod = jniApiClass.getMethod("writeCgi", long.class, String.class, int.class);
925
+ Log.d(TAG, "Verifying network: " + cgi);
926
+ Object result = writeCgiMethod.invoke(null, clientInfo.sdkClientPtr, cgi, 5);
927
+
928
+ // If we reach here, the CGI command was at least sent.
929
+ // We'll return a basic object representing success for now.
930
+ WritableMap response = Arguments.createMap();
931
+ response.putString("serialNumber", clientInfo.deviceId);
932
+ response.putString("model", "VStarCam Device");
933
+ response.putBoolean("responsive", true);
934
+ promise.resolve(response);
935
+ } catch (Exception e) {
936
+ Log.e(TAG, "clientGetDeviceInfo failed", e);
937
+ promise.reject("E_GET_INFO_FAILED", e.getMessage());
938
+ }
939
+ });
940
+ }
941
+
886
942
  /**
887
943
  * Get the current Wi-Fi SSID of the Android device
888
944
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bits-innovate/react-native-vstarcam",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "React Native bridge for VStarCam P2P SDK",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",