2.0 KiB
2.0 KiB
Host Protocol Rebuild
Goal
Use protobuf as the single protocol definition source.
This stage fixes two earlier mistakes:
- payload encode/decode should not be hand-written in COM
- the outer CDC frame should also be part of the schema
Current schema
Files:
KeyBorad/proto/keyboard.protoKeyBorad/proto/keyboard.options
Design
1. Outer frame is part of protobuf
The outer CDC frame is described as:
CdcFrame
Fields:
head1head2payload_lengthtypepayloadchecksum
2. Business body is part of protobuf
The business payload is described as:
CdcPacketBody
Supported messages:
HelloReqHelloRspBitmapFunctionKeyEventLedStateTimeSyncThemeRgbAckError
3. Transport split
- CDC sends
CdcFrame - GATT sends
CdcPacketBody
Why this is the chosen direction
- one full schema instead of half schema
- no repeated hand-written payload parsing
- easier to teach layer responsibilities
- easier to align host and firmware
Current blocker
protoc.exe is not present in 3rdParty, but the machine has an available
protobuf compiler binary at:
C:\Program Files\Lenovo\AIAgent\Modules\RAG\_internal\torch\bin\protoc.exe
Completed nodes
Node 1: full schema definition
Files:
KeyBorad/proto/keyboard.protoKeyBorad/proto/keyboard.options
Implemented behavior:
- outer frame moved into protobuf as
CdcFrame - business body moved into protobuf as
CdcPacketBody - all current message types included in one schema
Node 2: generated C++ protobuf code
Files:
KeyBorad/generated/cpp/keyboard.pb.hKeyBorad/generated/cpp/keyboard.pb.cc
Implemented behavior:
- generated from the full protocol schema
- ready to be used by the later thin COM wrapper
Next step
Stop expanding hand-written typed payload parsing.
The next COM implementation step should use:
- generated
keyboard.pb.h/.cc - a thin wrapper that connects
QByteArraywith generated protobuf messages