New Protocol - V2#848
Conversation
Size Report
|
Deploying rmk-rs with
|
| Latest commit: |
87fb488
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0964a461.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".
| #[serde_inline_default(false)] | ||
| pub rynk_enabled: bool, |
There was a problem hiding this comment.
Default HostConfig to the default Rynk protocol
With rmk/Cargo.toml now defaulting to the rynk feature, a keyboard.toml that omits [host] still resolves to vial_enabled = true and this newly added rynk_enabled = false. The macro’s validate_feature_config_parity requires the TOML flags to match the enabled Cargo features, so default-feature builds fail unless every project explicitly adds vial_enabled = false and rynk_enabled = true. The config defaults should match the crate defaults, or the parity check should derive the omitted host protocol from enabled features.
Useful? React with 👍 / 👎.
| /// Jump to the bootloader (DFU mode) — fire-and-forget, same contract as | ||
| /// [`reboot`](Self::reboot). | ||
| pub async fn bootloader_jump(&mut self) -> Result<(), RynkHostError> { | ||
| self.send_no_reply::<command::BootloaderJump>(&()).await |
There was a problem hiding this comment.
Report locked bootloader jumps instead of fire-and-forget
When the device is still locked, firmware gates BootloaderJump in RynkService::requires_unlock and sends Err(Locked) instead of jumping, but this client path uses send_no_reply and returns Ok(()) as soon as the frame is written. In that locked scenario tooling reports that DFU mode was requested successfully even though the firmware rejected it; handle the locked/rejected path before using the fire-and-forget behavior needed for the successful jump case.
Useful? React with 👍 / 👎.
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.
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Wire the six bulk handlers (keymap/combo/morse Get+Set) with up-front whole-request validation, advertise real bulk capabilities (max_bulk_keys, bulk_transfer_supported), and pin BULK_SIZE <= u8::MAX for the u8 wire field.
A bulk keymap run was confined to a single layer, forcing a host to restart the run at every layer boundary. The keymap is stored as one flat, layer-major array (`layer * rows * cols + row * cols + col`) — the same index space `get_action_flat`/`set_action_by_flat_index` already use — so a run is naturally just a contiguous slice of the whole keymap. `check_keymap_run` now computes the global flat offset and bounds against the keymap's total size instead of one layer's, letting a run cross both row and layer boundaries and stop only at the end of the keymap. Get reads via `get_action_flat`; Set decomposes the flat offset back to `(layer, row, col)` to keep the durable per-key persist. This lets a host stream the entire keymap as one contiguous BULK_SIZE-chunked sequence. Combo and morse bulk are already flat contiguous slot lists (no analogous sub-boundary) and macro buffer transfer is bounds-clamped; audited, no change needed. Adds a cross-layer round-trip test and corrects the now-stale "never wraps across layers" comments.
One `BULK_SIZE` governed all three bulk endpoints, but the item sizes differ ~17×: a KeyAction is 16 B, a Combo 83 B. The RYNK buffer auto-sizes to `BULK_SIZE × largest_item`, so it was dominated by the combo response (665 B at defaults) while the keymap response used only 129 of the 671 B buffer. Keymap — the one endpoint with hundreds of entries to stream — was throttled to 8 keys/message; combos and morses, capped at their slot counts (8), gained nothing from a larger chunk. Split the knob in two: - `BULK_KEYMAP_SIZE` (protocol_max_bulk_keymap_size, default 32) — keys per keymap message. 32 keys encode to 513 B, still under the combo-dominated 665 B, so RYNK_MIN_BUFFER_SIZE stays 671 B — 4× the keymap throughput at zero extra RAM. - `BULK_SIZE` (protocol_max_bulk_size, default 8) — combos/morses per message, unchanged. DeviceCapabilities now advertises both budgets: `max_bulk_keys` (keymap) and the new `max_bulk_configs` (combo/morse). Wire snapshots regenerated for the added field (DeviceCapabilities only). Loopback bulk tests move to a 48-key 4-layer fixture so a full BULK_KEYMAP_SIZE run (and one past it) fits without the keymap span being the limiter; bulk_action() widened to distinct keycodes.
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
73761d1 to
0dff9a7
Compare
Signed-off-by: Haobo Gu <haobogu@outlook.com>
c952ee0 to
5ffdabf
Compare
Signed-off-by: Haobo Gu <haobogu@outlook.com>
5ffdabf to
62a9432
Compare
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
fix: align docs.rs features with rynk
fix: expose rynk layout API to wasm
fix: model rynk macros as a flat buffer
Runtime conversions in GetCapabilities were unreachable: every constant is provably in range at build time (BULK_* are capped at 255 by BULK_COUNT_CEILING, MACRO_DATA_SIZE by MAX_MACRO_DATA_SIZE, and RYNK_BUFFER_SIZE - RYNK_HEADER_SIZE cannot underflow thanks to the RYNK_MIN_BUFFER_SIZE const assert in rynk/mod.rs), so revert the handler to plain casts. Trim the build_constants checks to the values no other bound covers: morse_max_num and split_peripherals_num (auto-raised after deserialization), ble_profiles_num, macro_space_size, and rynk_buffer_size. combo_max_length, max_patterns_per_key, and protocol_macro_chunk_size are already bounded by the protocol ceilings checked directly above.
fix: validate rynk capability bounds
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:
RynkMessagea wrapper type #863