feat: add initial Matter camera driver#222
Conversation
- Add camera.sbmd with session lifecycle resources (createSession, stream, takePicture, destroySession, sessionStatus) - Add Output operation type to SBMD execute pipeline for local-only mappers that return a value without Matter interaction - Add SessionManager to sbmd-utils.js for per-device session tracking - Add Response.output() helper for returning output from execute mappers - Add chip-camera-app to Dockerfile for integration testing - Add unit tests for Output type and SessionManager functionality Refs: BARTON-380
|
@Copilot review this |
| } | ||
|
|
||
| // Check for 'invoke' operation (command invocation) - the only valid operation for execute | ||
| // Check for 'output' operation (local-only, no Matter interaction) |
There was a problem hiding this comment.
This 'output' operation stuff was just a kludge to enable execute resource commands to return a response to the caller that doesn't change the resource value (since it's not a write resource command). I'm not married to it, I just needed it initially. It may be replaced by the work Raiyan is doing for standardizing the return types.
There was a problem hiding this comment.
Pull request overview
Adds an initial Matter camera driver scaffold. Introduces a new Output execute-mapper result type so SBMD scripts can return values without performing a Matter operation, a JS-side SessionManager keyed per device UUID, a camera.sbmd spec describing the session lifecycle (createSession/stream/takePicture/destroySession/sessionStatus), Docker support for chip-camera-app/chip-camera-controller, and unit tests for the new behaviors.
Changes:
- Add
Outputoperation type toScriptWriteResultwith handling inMatterDevice::HandleResourceExecuteand the mquickjsMapExecutebackend. - Add
Response.output()helper and a per-deviceSessionManagerinsbmd-utils.js, consumed by the newcamera.sbmd. - Extend Docker image with GStreamer/FFmpeg deps and Matter camera sample apps; bump docker version to 2.10.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| core/deviceDrivers/matter/sbmd/SbmdScript.h | Adds Output enum value and std::optional<std::string> output field on ScriptWriteResult. |
| core/deviceDrivers/matter/sbmd/mquickjs/SbmdScriptImpl.cpp | Recognizes {output: ...} execute results in the mquickjs backend (quickjs backend not updated). |
| core/deviceDrivers/matter/MatterDevice.cpp | Short-circuits execute pipeline for Output results, writing the string to the response out-param. |
| core/deviceDrivers/matter/sbmd/scriptCommon/sbmd-utils.js | Adds Response.output, SessionManager, and per-device registry; reformats existing Response helpers. |
| core/deviceDrivers/matter/sbmd/specs/camera.sbmd | New camera spec with session lifecycle execute mappers and a sessionStatus event resource. |
| core/test/src/SbmdScriptTest.cpp | Adds Output and SessionManager tests inside the mquickjs-only #if block. |
| docker/Dockerfile | Adds GStreamer/FFmpeg packages and builds/copies chip-camera-app and chip-camera-controller. |
| docker/version | Bumps image version 2.9 → 2.10. |
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
- Add Output operation handling to quickjs backend (parity with mquickjs) - Add SessionManager.removeForDevice() for cleanup on device removal - Normalize SessionManager keys to String(id) for unambiguous lookups - Add icWarn when Output value cannot be delivered (null response ptr) - Move Output/SessionManager tests outside #if BCORE_USE_MQUICKJS guard - Update docs/SBMD.md with output form documentation - Update sbmd-script.d.ts with SbmdUtils, SessionManager, and output types
- Add JS_IsException check on output property access in both engines - Wire SessionManager.removeForDevice() into SbmdScriptImpl destructors to clean up per-device session state on device removal - Convert SbmdCommandResult to discriminated union type in d.ts - Fix SBMD.md output example to use valid JS literal instead of <string>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
core/deviceDrivers/matter/sbmd/scriptCommon/sbmd-utils.js:988
- The new Response helper formatting switches to inline brace style (e.g.,
var Response = {andinvoke: function(...) {), but the rest of this file consistently uses braces on the next line (e.g., Tlv.decode at sbmd-utils.js:798). Please keep a consistent style within this shared script bundle (or run the project’s formatter/linter if one exists for JS).
var Response = {
/**
* Create an invoke (command) response
* @param {number} clusterId - Matter cluster ID
* @param {number} commandId - Matter command ID
- JSON-escape deviceId in destructor cleanup scripts to prevent injection - Treat JS_ToCString failure on output as hard error (return false) in both mquickjs and quickjs engines instead of silently returning empty - Use Object.create(null) for sessionManagers registry to avoid prototype pollution with special keys like __proto__/constructor
Refs: BARTON-380