@bits-innovate/react-native-vstarcam 1.0.58 → 1.0.60
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.
|
Binary file
|
|
@@ -304,8 +304,10 @@ public class VStarCamModule extends ReactContextBaseJavaModule implements Lifecy
|
|
|
304
304
|
@Override
|
|
305
305
|
public void commandListener(long clientPtr, byte[] data, int length) {
|
|
306
306
|
try {
|
|
307
|
-
Log.d(TAG, "Command callback: clientPtr=" + clientPtr + ", dataLen=" + (data != null ? data.length : 0));
|
|
308
|
-
|
|
307
|
+
Log.d(TAG, "Command callback: clientPtr=" + clientPtr + ", cmd=" + length + ", dataLen=" + (data != null ? data.length : 0));
|
|
308
|
+
// Mind blowing discovery: the parameter named 'length' in the AAR interface
|
|
309
|
+
// is actually the command ID (cmd) from the underlying C++ SDK!
|
|
310
|
+
VStarCamModule.handleCommandReceive(clientPtr, length, data);
|
|
309
311
|
} catch (Exception e) {
|
|
310
312
|
Log.e(TAG, "Error in commandListener callback", e);
|
|
311
313
|
}
|
package/package.json
CHANGED
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
|
*/
|