Skip to content

New protocol#750

Draft
HaoboGu wants to merge 24 commits intomainfrom
feat/protocol
Draft

New protocol#750
HaoboGu wants to merge 24 commits intomainfrom
feat/protocol

Conversation

@HaoboGu
Copy link
Copy Markdown
Owner

@HaoboGu HaoboGu commented Mar 3, 2026

This PR contains RMK's new host communication protocol.


UPDATE: Now the PR becomes quite large, I'll split it to several smaller parts.


Phase 1: ICD Types and postcard-rpc Integration

Phase 2: Feature Gate and ProtocolService Skeleton
Phase 3: Support USB Raw Bulk Transport
Phase 4: Implement core Endpoints, make the basic protocol work
Phase 5: Security (Lock/Unlock) feature
Phase 6: Implement all remaining endpoints
Phase 7: Topic(Notification from keyboard to host)
Phase 8: Support BLE Serial
Phase 9: Host Tool

HaoboGu added 12 commits March 1, 2026 23:29
Signed-off-by: Haobo Gu <haobogu@outlook.com>
…ypes

Signed-off-by: Haobo Gu <haobogu@outlook.com>
… topics

Add the complete Interface Control Document (ICD) for the RMK protocol in
rmk-types/src/protocol/rmk.rs. This defines the shared type contract between
firmware and host for the new postcard-rpc based communication protocol.

- Add heapless v0.9 dependency with serde support and postcard-schema
  heapless-v0_9 feature for schema derives on Vec-containing types
- Define 30+ protocol types: ProtocolVersion, DeviceCapabilities, RmkError,
  LockStatus, UnlockChallenge, KeyPosition, BulkRequest, StorageResetMode,
  ConnectionType, BatteryStatus, MacroInfo/Data, ComboConfig, MorseConfig,
  ForkConfig, BehaviorConfig, topic payloads, and request wrappers
- Declare 41 endpoints across System, Keymap, Encoder, Macro, Combo, Morse,
  Fork, Behavior, Connection, and Status categories
- Declare 8 topics for layer, WPM, battery, BLE, connection, sleep, and LED
- Add 29 tests: postcard serde round-trips and key hash collision detection
- Add PartialEq/Eq derives to EncoderAction for protocol type compatibility
- Mark Phase 1 complete in ROADMAP.md
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
…yload conversions

Signed-off-by: Haobo Gu <haobogu@outlook.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

Binary Size Report

use_config/stm32f1

   text	   data	    bss	    dec	    hex	filename
  55816	     24	   8064	  63904	   f9a0	rmk-stm32f1
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +831  [ = ]       0    .debug_str
  +0.0%    +117  [ = ]       0    .debug_info
  +0.1%     +88  [ = ]       0    .debug_line
  +0.8%     +45  [ = ]       0    .debug_abbrev
  +0.0%     +16  [ = ]       0    .debug_ranges
 -14.8%      -8  [ = ]       0    [Unmapped]
  -0.1%     -12  [ = ]       0    .debug_frame
  -0.0%     -24  -0.0%     -24    .text
  -0.2%     -32  [ = ]       0    .symtab
  -0.2%     -65  [ = ]       0    .strtab
  -0.2%    -216  [ = ]       0    .debug_loc
  +0.0%    +740  -0.0%     -24    TOTAL

use_config/stm32f4

   text	   data	    bss	    dec	    hex	filename
 135428	    320	  16548	 152296	  252e8	rmk-stm32f4
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.6% +10.6Ki  [ = ]       0    .debug_str
  +2.5% +2.70Ki  [ = ]       0    .strtab
  +0.1%    +760  [ = ]       0    .debug_info
  +0.4%    +635  [ = ]       0    .debug_line
  +0.4%    +488  +0.4%    +488    .text
  +0.7%    +304  [ = ]       0    .symtab
  +1.2%    +236  +1.3%    +236    .rodata
  +0.8%    +200  [ = ]       0    .debug_aranges
  +0.6%     +43  [ = ]       0    .debug_abbrev
  +4.2%     +17  [ = ]       0    .defmt
  -0.1%     -12  [ = ]       0    .debug_frame
 -28.8%     -19  [ = ]       0    [Unmapped]
  -0.2%    -144  [ = ]       0    .debug_ranges
  -0.9% -2.38Ki  [ = ]       0    .debug_loc
  +0.4% +13.4Ki  +0.5%    +724    TOTAL

HaoboGu added 4 commits March 4, 2026 01:05
…tus usage, fix wrong naming

Signed-off-by: Haobo Gu <haobogu@outlook.com>
…tatus struct

Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
refactor(event): move shared types out from protocol
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 4, 2026

Deploying rmk-rs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5ab2b9a
Status: ✅  Deploy successful!
Preview URL: https://8c3e92c9.rmk-4a2.pages.dev
Branch Preview URL: https://feat-protocol.rmk-4a2.pages.dev

View logs

HaoboGu added 3 commits March 6, 2026 11:50
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
HaoboGu added 5 commits March 9, 2026 10:15
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
* feat: Add `rmk_protocol` and `host_security` features

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* feat: basic `ProtocolService` impl

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* feat(protocol): first try of USB bulk transport

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* feat: update plan, fix feature gates

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* feat: add more commands

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* fix

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* feat(protocol): implement core endpoints and host CLI tool

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* feat(protocol): add generated dispatch and schema tooling

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* fix: fix build after merging

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* feat(protocol): make bulk keymap transfer faster

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* refactor(host): move BLE vial handling behind host transports

  - rename the BLE host service module to host_gatt and centralize host GATT writes
  - reuse ViaHostService across USB and BLE transports with simpler feature gating
  - add a bootloader-jump command to rmk-host-tool
  - fix dispatch alias generation for bounded generic parameters

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* refactor(protocol): add `check_unlocked` and `check_bounds` helper functions

Signed-off-by: Haobo Gu <haobogu@outlook.com>

---------

Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant