feat: Stream Deck Studio TCP emulator (Cora protocol)#43
Closed
FlowingSPDG wants to merge 10 commits into
Closed
Conversation
- Convert repository to Cargo workspace; move existing RP2040 firmware into firmware/ crate with its own .cargo/config.toml (thumbv6m target) - Add tcp-emulator/ crate: a std/tokio binary that emulates Stream Deck Studio (VID 0x0fd9 / PID 0x00aa) over TCP using the Cora protocol tcp-emulator features: - Cora message framing with tokio_util Codec (magic sync, LE header) - TCP server accepting multiple concurrent clients - Periodic keepalive (2 s interval) with ACK_NAK handling - Feature Report responses: 0x80 device info, 0x83 firmware, 0x84 serial, 0x85 MAC address, 0x86/0x8a encoder firmware - Gen2 button input events (KEY_DATA_OFFSET=3, 32-button payload) - mDNS advertisement via mdns-sd (_elg._tcp, vid/pid/sn/dt TXT records) - Interactive CLI: press/release/tap/status/quit commands Verified with node-elgato-stream-deck TCP example: - StreamDeckTcpConnectionManager detects device as Stream Deck Studio - Serial, firmware, MAC feature reports return correctly - KEY_DOWN / KEY_UP events fire on tap commands Made-with: Cursor
- Add --firmware CLI argument (default: "6.06.001") for feature report 0x83 - Remove hardcoded "1.00.000" from main.rs; firmware version now flows from CLI - Update DeviceConfig::default() to use "6.06.001" for consistent defaults - Print serial/firmware/mac on startup for easy verification - Real Stream Deck Studio firmware is ~6.x; "1.00.000" was causing "Device firmware is not supported" with the official Elgato software Made-with: Cursor
Log every received/sent message at INFO level with: - flags (hex), hid_op (hex), message_id (hex), payload_len - payload[:64] as hex bytes This makes it possible to diagnose "Device firmware is not supported" by capturing the exact bytes the official Elgato software sends. Made-with: Cursor
…t requests The official Elgato Stream Deck software uses hid_op=WRITE (0x00) with flags=NONE and payload=[0x03, reportId, 0x00...] to request feature reports, instead of hid_op=GET_REPORT (0x02) as used by node-elgato-stream-deck. Previous behaviour: WRITE messages were only logged, no response was sent, causing the official software to time out and disconnect (~600ms). Fix: In the WRITE handler, detect payload[0]==0x03 + !VERBATIM as a feature report request (Studio port pattern), look up the report, and respond with WRITE+flags=NONE carrying the report payload. VERBATIM WRITEs (image data / child device passthrough) are still only logged as before. Made-with: Cursor
…onent) Made-with: Cursor
Made-with: Cursor
Member
Author
|
一応TCPの接続確率は出来るようになったっぽい? |
…rational reports Made-with: Cursor
Made-with: Cursor
Member
Author
|
Studio実機を使ったテストが必要 |
Member
Author
Made-with: Cursor
Member
Author
Member
Author
|
Studioは実機がないのでテストが難しそう |
Member
Author
|
Suspend due to lacking of equipment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
firmware/crate に移動し、ルートを[workspace]定義に変更。ファームウェア固有のビルド設定(thumbv6m-none-eabiターゲット)はfirmware/.cargo/config.tomlに閉じ込め、tcp-emulatorには影響しない構造にした。tcp-emulator/crate を新規追加: Stream Deck Studio (VID=0x0fd9 / PID=0x00aa) を Cora プロトコルで TCP エミュレートする std/tokio バイナリ。実装内容
Cora プロトコル (
cora.rs)tokio_util::codec::Framedで TCP ストリームのバッファリング・フレーム境界検出を処理TCP サーバ / セッション管理 (
server.rs,session.rs)tokio::net::TcpListenerで複数クライアントを並行受付・セッション spawntokio::select!で keepalive タイマー / 受信メッセージ / CLI コマンドを並行処理キープアライブ (
session.rs)[0x01, 0x0a]) を送信ACK_NAKフラグ付きレスポンスを受け取り接続維持Feature Report 応答 (
feature_reports.rs)0x800x830x840x850x86,0x8aボタン入力イベント (
input.rs)[0x01, 0x00, 0x00, 0x00, key0..key31]KEY_DATA_OFFSET=3に準拠 (node-elgato-stream-deck/core の Gen2 入力サービスと互換)mDNS サービス広告 (
discovery.rs)_elg._tcp.local.でサービスを登録vid,pid,sn,dtCLI (
main.rs)Test plan
cargo build -p productiondeck-tcp-emulatorがエラー・警告なしで通ることStreamDeckTcpConnectionManager.connectTo('127.0.0.1', port)→connectedイベント発火getSerialNumber()/getFirmwareVersion()/getMacAddress()が正常な値を返すことtap <key>コマンドで node 側にKEY_DOWN/KEY_UPイベントが届くことStreamDeckTcpDiscoveryServiceが LAN 上でデバイスを検出できること (実機 LAN 環境で確認)Made with Cursor