Add firmware nanopb protocol core

This commit is contained in:
2026-04-11 11:56:45 +08:00
parent f753a7f883
commit 1b2fe79b5d
6 changed files with 503 additions and 5 deletions

View File

@@ -32,11 +32,6 @@ Design notes:
## Planned next nodes
- keyboard split logic uses `function_bitmap_event`
- CDC transport module
- GATT transport module
- nanopb integration and generated protocol code
### Node 2: keyboard split point
Files updated in this step:
@@ -59,3 +54,43 @@ Implemented behavior:
- for consumer usages marked as function keys:
- stop normal HID reporting
- emit `function_key_event`
### Node 3: nanopb build integration and protocol core
Files updated in this step:
- `CMakeLists.txt`
- `prj.conf`
- `app.overlay`
- `inc/keyboard_proto.h`
- `src/modules/keyboard_proto.c`
Design notes:
- use NCS built-in nanopb instead of a hand-written protobuf runtime
- generate protocol code from the shared `.proto`
- keep one firmware-side protocol helper that:
- encodes and decodes `CdcPacketBody`
- encodes and decodes `CdcFrame`
- validates checksum
- routes host commands back into existing modules
Implemented behavior:
- enable CDC ACM class in Zephyr USB device-next stack
- add a CDC ACM UART node in devicetree
- wire `zephyr_nanopb_sources()` into the build
- add protocol helper functions for:
- body encode/decode
- CDC frame encode
- CDC frame stream extraction
- hello response build
- ack/error build
- function key event build
- LED state build
- host command dispatch
## Planned next nodes
- CDC transport module
- GATT transport module