@bits-innovate/react-native-vstarcam 1.0.58 → 1.0.59

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +39 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bits-innovate/react-native-vstarcam",
3
- "version": "1.0.58",
3
+ "version": "1.0.59",
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
@@ -345,6 +345,45 @@ class VStarCamClient {
345
345
  return VStarCamModule.clientWriteCgi(this.clientPtr, cgi, timeout);
346
346
  }
347
347
 
348
+ /**
349
+ * Get camera status/capabilities by sending get_status.cgi
350
+ * Returns parsed key-value pairs from the camera response.
351
+ * Includes fields like MaxZoomMultiple, support_WhiteLed_Ctrl, haveMotor, etc.
352
+ */
353
+ async getStatus(): Promise<Record<string, string> | null> {
354
+ if (!this.clientPtr) return null;
355
+
356
+ const success = await this.sendCommand("get_status.cgi?");
357
+ if (!success) return null;
358
+
359
+ return new Promise((resolve) => {
360
+ const timeoutId = setTimeout(() => {
361
+ this.removeCommandListener(handler);
362
+ console.warn("[VStarCam] getStatus timed out");
363
+ resolve(null);
364
+ }, 8000);
365
+
366
+ const handler: CommandEventListener = (_, cmd, data) => {
367
+ // cmd 24577 = status response (same as login response)
368
+ if (cmd === 24577 || cmd === 24785) {
369
+ clearTimeout(timeoutId);
370
+ this.removeCommandListener(handler);
371
+ try {
372
+ const str = typeof data === "string" ? data : new TextDecoder().decode(data);
373
+ const parsed = this.parseResponse(str);
374
+ console.log("[VStarCam] getStatus response keys:", Object.keys(parsed).join(", "));
375
+ resolve(parsed);
376
+ } catch (e) {
377
+ console.error("[VStarCam] getStatus parse error:", e);
378
+ resolve(null);
379
+ }
380
+ }
381
+ };
382
+
383
+ this.addCommandListener(handler);
384
+ });
385
+ }
386
+
348
387
  /**
349
388
  * Scan for available WiFi networks
350
389
  */