node — API Reference¶
app¶
node.app.create_app()
¶
Source code in node/app.py
routers.sensors¶
node.routers.sensors
¶
get_sensor(sensor_id, request)
async
¶
Return the latest reading from a sensor, or null if not yet available.
Source code in node/routers/sensors.py
list_sensors(request)
async
¶
List all configured sensors with their type and enabled status.
Source code in node/routers/sensors.py
sensor_frames(websocket, sensor_id)
async
¶
Binary frame stream for high-rate array/image sensors (thermal, pressure grids). Each message is one raw binary frame whose layout is sensor-defined (see the sensor's README / viewer). Use this instead of the JSON /ws lane when per-frame payloads are large and arrive tens of times per second — it avoids json.dumps on the server and a parse + GC of a big array on the client. Sensors without produces_frames are rejected with 4003.
Source code in node/routers/sensors.py
sensor_stream(sensor_id, request)
async
¶
Server-sent events stream for a sensor. Each event is a JSON-encoded SensorReading. A keepalive comment is sent every 25 s when no reading is available.
Source code in node/routers/sensors.py
sensor_ws(websocket, sensor_id)
async
¶
WebSocket stream — sends the same JSON payload as the SSE stream.
Source code in node/routers/sensors.py
routers.devices¶
node.routers.devices
¶
Device tier introspection — health with gating awareness.
A device behind a switched-off power rail is gated, not failed: the cut is a
deliberate body state commanded through a power_rail effector that lists the
device in its members. This router is the surface that tells the two apart,
so fleet tooling and dashboards never report an intentional power-down as a
fault. Reads request.app.state (never module-level registries).
list_devices(request)
async
¶
All devices with health + gating: healthy | gated | down.
Source code in node/routers/devices.py
routers.effectors¶
node.routers.effectors
¶
Effector control routes — the efferent dual of the sensor routes.
Two lanes, chosen by the effector type (not a universal verb): • request — POST /effectors/{id} with a type-defined body (e.g. pwm levels). • stream — WS /effectors/{id}/stream, binary frames fed continuously. Node-implicit and logical; the backing device is metadata, never a path segment.
drive_effector(effector_id, request, payload=Body(...))
async
¶
Request-lane drive. Body schema is defined by the effector's type.
Source code in node/routers/effectors.py
stream_effector(websocket, effector_id)
async
¶
Stream-lane drive: binary frames fed to the effector (audio, LED animation).
Source code in node/routers/effectors.py
routers.policies¶
node.routers.policies
¶
Policy routes — inspect and toggle the node's control loops.
A policy maps observations (relay signals) to actions (effector channels). These routes expose its wiring and current obs/action, and let an operator (or an upstream cortex) enable/disable it. Hot-swapping a policy's behavior is a later addition; the interface is the seam.
routers.camera¶
node.routers.camera.CameraThread(config)
¶
Reads raw MJPEG bytes from V4L2 without decode/re-encode. CAP_PROP_CONVERT_RGB=0 tells OpenCV to return the compressed frame the camera already produced in hardware.
Source code in node/routers/camera.py
node.routers.camera.start_camera(config)
¶
Source code in node/routers/camera.py
node.routers.camera.stop_camera()
¶
routers.i2c¶
node.routers.i2c
¶
scan_i2c_buses()
¶
Run i2cdetect on every /dev/i2c-* bus. Returns {bus_num: [addrs] | {"error": str}}.