Skip to main content

Module protocol

Module protocol 

Source
Expand description

Ryu Hardware Protocol (RHP) v1 — Rust mirror of the wire contract.

This is the node-side implementation of the SAME contract defined in apps/hardware/PROTOCOL.md §3. The WebSocket handler (apps/core/src/server/hardware_ws.rs, wired in a later phase) (de)serializes these types on each TEXT frame; BINARY frames carry Opus/JPEG payloads and are not modeled here.

Keep this in lockstep with the two sibling implementations:

  • C (firmware): apps/hardware/firmware/shared/protocol/include/rhp_protocol.h
  • TS (relay): packages/protocol/src/hardware.ts

Message type strings and field names are NORMATIVE. The serde attributes below are chosen so the emitted JSON matches the spec exactly:

  • #[serde(tag = "type", rename_all = "snake_case")] makes the enum a { "type": "..." }-tagged union; snake_case yields camera_meta, hello_ack, tts_start, chat_delta, etc.
  • Stt renames to stt, TtsStart/TtsEnd to tts_start/tts_end.

Structs§

AudioFormat
Audio format descriptor (mic uplink in hello, TTS downlink in hello_ack).
Caps
Capability profile a device advertises in hello.
DeviceListItem
One entry in GET /api/hardware/devices.
DeviceUpdate
PATCH /api/hardware/devices/:id request body.
PairRequest
POST /api/hardware/pair request body.
PairResponse
POST /api/hardware/pair response body.

Enums§

DeviceType
Physical device class. Wire: watch | necklace | desk.
Emotion
Face/emotion state driving the “Island eyes” renderer. Wire: neutral | listening | thinking | happy | sad | surprised | speaking.
ListenState
Chat-turn boundary marker. Wire: start | stop.
Mode
Device operating mode. Wire: idle | chat | ambient.
RhpClientMsg
Every control message a device/relay sends to the node, tagged on type.
RhpServerMsg
Every control message the node sends to a device/relay, tagged on type.
Surface
Display surface a display message targets. Wire: eink | lcd.

Functions§

device_type_str
Wire string for a DeviceType (mirrors C rhp_device_type_str). Used by the SQLite registry, which stores the device class as its wire token rather than re-deriving it via serde.
parse_device_type
Parse a DeviceType from its wire string (mirrors C rhp_device_type_parse). Returns None for any unrecognized value.