New Protocol - V2 - #848
Conversation
Size Report
|
Deploying rmk-rs with
|
| Latest commit: |
8695c55
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1bfc3c16.rmk-4a2.pages.dev |
| Branch Preview URL: | https://feat-rynk-protocol.rmk-4a2.pages.dev |
|
Iirc this is also used as the protocol between central and peripheral. I can count a sequence number and simply not start the update if a message went missing. Or we need flow control e.g. with a sliding window for rynk. For the latter I would say it's better to have that reusable in the protocols instead of my firmware update cooking up its own flow control. |
In the current design Rynk is not used between central and peripheral, but I hope it can be used in the future. Now it has only a |
What I mean with flow control is basically what I already did for the split protocol in #886. So mostly checking if the data is correct and resending a packet if it isn't. |
1 similar comment
What I mean with flow control is basically what I already did for the split protocol in #886. So mostly checking if the data is correct and resending a packet if it isn't. |
9047ce5 to
8ea6723
Compare
c387d14 to
b78964e
Compare
28b17bd to
9768858
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff7c9c7309
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
38f5948 to
4111105
Compare
Adds new rynk/ protocol module (buffer, cmd, header, fingerprint, mod) with the new wire format. Migrates per-domain modules (combo, encoder, fork, keymap, macro_data, morse, status, system) from the previous rmk/ namespace, and removes the old endpoint/topic snapshot-based layout. Also drops unused derives/imports across rmk-types/src/*.rs. Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Adds GetWpm (0x0805), GetSleepState (0x0806), GetLedIndicator (0x0807) in the Status group. These let the host probe the latest value of the three pure event-stream topics whose state isn't otherwise queryable (layer/connection/battery/ble already have getters). The snapshot source-of-truth lives in pr2; handlers land in pr3.
Drops the `Header` struct + `Header::decode`/`encode_into` in favour of `Frame` (a type alias for `[u8]`) and the `FrameOps` trait that adds in-place wire-header accessors (`cmd`, `seq`, `payload_len`, `payload`, plus their setters). Callers stop parsing a `Header` value out of the bytes and re-encoding it back — they hand the buffer through and access fields via the trait. The trait re-uses `RynkError::InvalidParameter` for "short buffer" / "unknown CMD" instead of a separate `DecodeError`. Wire layout unchanged: `[CMD u16 LE | SEQ u8 | LEN u16 LE | payload]`. Used by pr2's dispatch refactor (single buffer in/out) and the handler signature update in pr3.
Aliases `Result<T, RynkError>` (with `T = ()` default) so handler modules can write `RynkResult` for empty-status responses without re-declaring the alias in every file. Used by pr3's handlers.
Introduces rmk/src/host/rynk/{mod, codec, topics} as the dispatcher
scaffold for the on-device rynk service. Wires it into host/context
and host/mod, exposes channel hooks in src/channel.rs, and updates
src/keymap.rs and src/lib.rs to expose the new entry points.
Handlers and transports land in subsequent PRs.
Signed-off-by: Haobo Gu <haobogu@outlook.com>
These statics are only consumed by the BLE transport added in pr4. Move them out of the service-core PR so pr2 stays free of transport concerns; they'll be re-introduced alongside the BLE transport.
fix: reject zero-layer keymap configurations
fix: fail closed after cancelled Rynk reads
Follow-up to #943. A cancelled read or write poisons the client, but is_alive() still returned true and next_event()'s doc still claimed "Cancel-safe" — both misreport a link that dies on the very next call. - is_alive() now also checks send_in_flight/receive_in_flight, so it reads false the instant an operation is cancelled. - Correct the next_event() doc; drop the stale "for cancel safety" read-loop comment left over from the removed resync path. - Update the cancellation tests that codified the old is_alive() state.
…ency fix: reflect cancellation poison in is_alive and next_event docs
wasm-smoke.ts asserted only get_led_indicator's return type, so a broken descriptor for any other wasm object type would pass. Point tsc at the whole generated rynk_wasm.d.ts instead. Build --dev too: a release build constant-folds a malformed type descriptor into a valid-looking name, so the check only bites on the un-optimized dev output it was meant to guard.
fix: emit valid WASM object type descriptors
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Render every endpoint and topic — id, name, payload types, feature gate, and row docs — into docs/development/rynk_protocol.md from the endpoints!/topics! tables via new ENDPOINT_META/TOPIC_META. An UPDATE_SNAPSHOTS-style rmk-types test regenerates and gates drift, so the reference stays in lockstep with the wire contract. Additive to rmk-types only; no protocol or wire changes.
fix(wasm): show macro storage capacity
fix(wasm): release Web Serial locks on close
docs(rynk): generate the protocol reference from the command tables
Bulk Set/Get handlers decoded/encoded a whole `heapless::Vec<_, BULK_SIZE>` on the stack, held across `.await` in the session future — a second copy of the payload that, for keymap, exceeded `RYNK_BUFFER_SIZE` itself. That RAM cost was the only reason bulk was a separate, opt-in feature. Stream instead: `Get*Bulk` writes the page straight into the response buffer (`RynkMessage::encode_bulk_ok`), and `Set*Bulk` walks the payload one element at a time. The two-pass write (validate-all-decode, then apply) keeps the all-or-nothing guarantee a malformed tail would otherwise break. Peak extra RAM drops from `BULK_SIZE * size_of::<Item>()` to a single element. The six bulk endpoints keep the `Handle<E>` abstraction and uniform dispatch by overriding the provided `handle_message`; `handle` becomes a default so fixed endpoints are unchanged. postcard's sequential encoding makes the streamed bytes identical to the owned-`Vec` form, so hosts interoperate unchanged — the loopback suite (round-trips, row/layer wrap, clamps, rejects) passes as-is. With the RAM cost gone, bulk is always available under `rynk`: the `bulk` feature is removed and `@bulk` now only exempts a row from the buffer-floor fold. Adds an all-or-nothing test for a malformed mid-stream element.
Pull the repeated "decode one element, advance the cursor, map to Malformed" step out of the three Set handlers and validate_bulk_elements into a single take_element helper. Trims the two-pass write loops to one line each and tightens the comments.
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Model fixed and bulk endpoints as two disjoint traits instead of one template-method trait with an Unimplemented default hook: - `Handle<E>`: required `handle(req) -> resp`; forgetting a typed handler is now a compile error, not a runtime Unimplemented. - `HandleBulk<E>`: `handle_bulk(msg)` streams through the session buffer, no Vec materialized. - `Serve<E, Mode>`: the uniform dispatch surface, blanket-derived from either trait. `Fixed`/`Bulk` markers keep the two blanket impls from overlapping (trait bounds alone can't); the mode infers as `_`. Dispatcher arms are uniform `Serve::<command::X, _>::serve(self, msg)`. The 38 fixed handlers are untouched; the 6 bulk handlers move to HandleBulk with identical bodies.
…op host inbound ceiling Endpoint/Topic now describe only the wire schema. MaxSize is folded privately by the firmware, which self-asserts its fixed RYNK_BUFFER_SIZE holds every frame (bulk included). postcard is slice-driven, so the host never needs per-type MaxSize: host bulk types stay unbounded alloc::Vec, and the placeholder POSTCARD_MAX_SIZE = RYNK_BUFFER_SIZE plus the @bulk/@floor/@gate macro machinery that existed only to work around it are gone. Command-table rows are now uniform. The host driver drops the inbound size ceiling entirely: frames are read by their u16 LEN and routed (reply -> SEQ+decode, topic -> decode-or-Unknown). Only transport failures and caller cancellation latch the link dead, closing a pre-existing gap where a large/unknown pre-handshake topic could kill it. tx_buf is sized to the device's advertised buffer, so an oversized outbound request fails to encode (non-fatal Encode) instead of the now-dead TooLarge check. No wire-format change; command IDs, payloads, capabilities, bulk page sizing, and snapshots unchanged. Signed-off-by: Haobo Gu <haobogu@outlook.com>
refactor(rynk): stream bulk transfer, drop the `bulk` feature
|
In favor of #962 |
The 2nd try of adding RMK's protocol. Different from previous tries(#750, #835), this time
postcard-rpcis dropped because it's kind of overkill and introduces long compile time.Instead, a simpler, header + payload like protocol is used, and the new protocol is called
rynkwhich meansrmk+link.Progress
All sub-PRs are merged into this branch:
RynkMessagea wrapper type #863 — MakeRynkMessagea wrapper typeRynkHidServicedocs/docs/main/docs/features/rynk.md(wired into the features nav)