2026-04-11 10:10:43 +08:00
|
|
|
# Host COM Rebuild
|
|
|
|
|
|
|
|
|
|
## Goal
|
|
|
|
|
|
|
|
|
|
Keep the COM layer small, explicit, and easy to teach.
|
|
|
|
|
|
|
|
|
|
The COM layer should:
|
|
|
|
|
|
|
|
|
|
- define packet types and payload structures
|
|
|
|
|
- build full wire frames
|
|
|
|
|
- parse full wire frames
|
|
|
|
|
- parse typed packet payloads
|
|
|
|
|
|
|
|
|
|
The COM layer should not:
|
|
|
|
|
|
|
|
|
|
- enumerate devices
|
|
|
|
|
- open ports
|
|
|
|
|
- own handshake state
|
|
|
|
|
- own UI state
|
|
|
|
|
|
|
|
|
|
## Current file roles
|
|
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
### `Com_PbCodec.h/.cpp`
|
2026-04-11 10:10:43 +08:00
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
Owns the protobuf-side wrapper:
|
2026-04-11 10:10:43 +08:00
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
- full protobuf frame serialize / parse
|
|
|
|
|
- checksum validation
|
|
|
|
|
- typed helper entry points like hello request / response
|
2026-04-11 10:10:43 +08:00
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
### `keyboard.pb.h/.cc`
|
2026-04-11 10:10:43 +08:00
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
Own the generated protocol model:
|
2026-04-11 10:10:43 +08:00
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
- outer `CdcFrame`
|
|
|
|
|
- business `CdcPacketBody`
|
|
|
|
|
- all message definitions
|
2026-04-11 10:10:43 +08:00
|
|
|
|
|
|
|
|
## Completed nodes
|
|
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
### Node 1: protobuf thin wrapper
|
2026-04-11 10:27:05 +08:00
|
|
|
|
|
|
|
|
Files added in this step:
|
|
|
|
|
|
|
|
|
|
- `KeyBorad/KeyBorad/COM/Com_PbCodec.h`
|
|
|
|
|
- `KeyBorad/KeyBorad/COM/Com_PbCodec.cpp`
|
|
|
|
|
|
|
|
|
|
Design notes:
|
|
|
|
|
|
|
|
|
|
- stop expanding hand-written typed payload logic
|
|
|
|
|
- let protobuf generated code own message encode/decode
|
|
|
|
|
- keep only a thin Qt-friendly wrapper
|
|
|
|
|
|
|
|
|
|
Implemented behavior:
|
|
|
|
|
|
|
|
|
|
- serialize a full `CdcFrame`
|
|
|
|
|
- parse and validate a full `CdcFrame`
|
|
|
|
|
- build `HelloReq` using generated protobuf types
|
|
|
|
|
- parse `HelloRsp` using generated protobuf types
|
|
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
### Node 2: remove legacy manual codec
|
|
|
|
|
|
|
|
|
|
Files removed in this step:
|
|
|
|
|
|
|
|
|
|
- `KeyBorad/KeyBorad/COM/Com_Cdc.h`
|
|
|
|
|
- `KeyBorad/KeyBorad/COM/Com_CdcEncode.h`
|
|
|
|
|
- `KeyBorad/KeyBorad/COM/Com_CdcEncode.cpp`
|
|
|
|
|
- `KeyBorad/KeyBorad/COM/Com_CdcDecode.h`
|
|
|
|
|
- `KeyBorad/KeyBorad/COM/Com_CdcDecode.cpp`
|
|
|
|
|
|
|
|
|
|
Design notes:
|
|
|
|
|
|
|
|
|
|
- no dual path
|
|
|
|
|
- no hand-written payload encode/decode path left behind
|
|
|
|
|
- protobuf is now the only packet encode/decode direction
|
|
|
|
|
|
|
|
|
|
Implemented behavior:
|
2026-04-11 10:27:05 +08:00
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
- checksum moved into `Com_PbCodec.cpp`
|
|
|
|
|
- old manual packet structs and old codec files removed
|
2026-04-11 10:27:05 +08:00
|
|
|
|
2026-04-11 10:10:43 +08:00
|
|
|
## COM done criteria
|
|
|
|
|
|
|
|
|
|
For the current project stage, COM is considered done when:
|
|
|
|
|
|
2026-04-11 10:33:07 +08:00
|
|
|
1. the protocol source is the `.proto` file
|
|
|
|
|
2. generated `.pb.*` files exist
|
|
|
|
|
3. `Com_PbCodec` provides thin project-facing helpers
|
|
|
|
|
4. no legacy hand-written packet codec remains
|