2026-04-11 09:34:25 +08:00
|
|
|
# Host LGC Rebuild
|
|
|
|
|
|
|
|
|
|
## Goal
|
|
|
|
|
|
|
|
|
|
Keep the logic layer small, readable, and teachable.
|
|
|
|
|
|
|
|
|
|
The logic layer should:
|
|
|
|
|
|
|
|
|
|
- own connection state
|
|
|
|
|
- own handshake state
|
|
|
|
|
- call DRI for bytes
|
|
|
|
|
- call COM for frame and packet parsing
|
|
|
|
|
- expose a small interface to APP
|
|
|
|
|
|
|
|
|
|
The logic layer should not:
|
|
|
|
|
|
|
|
|
|
- parse serial bytes by itself
|
|
|
|
|
- enumerate devices directly
|
|
|
|
|
- own widget code
|
|
|
|
|
|
|
|
|
|
## Completed Nodes
|
|
|
|
|
|
|
|
|
|
### Node 1: function executor shell
|
|
|
|
|
|
|
|
|
|
Files:
|
|
|
|
|
|
|
|
|
|
- `KeyBorad/KeyBorad/LOGIC/Lgc_FunctionExecutor.h`
|
|
|
|
|
- `KeyBorad/KeyBorad/LOGIC/Lgc_FunctionExecutor.cpp`
|
|
|
|
|
|
|
|
|
|
Design notes:
|
|
|
|
|
|
|
|
|
|
- keep function execution out of session code
|
|
|
|
|
- reserve one place for OS-specific actions
|
|
|
|
|
- keep the initial implementation small
|
|
|
|
|
|
|
|
|
|
### Node 2: state model
|
|
|
|
|
|
|
|
|
|
Files updated in this step:
|
|
|
|
|
|
|
|
|
|
- `KeyBorad/KeyBorad/LOGIC/Lgc_State.h`
|
|
|
|
|
|
|
|
|
|
Design notes:
|
|
|
|
|
|
|
|
|
|
- state is plain data
|
|
|
|
|
- connection text and last action text live here
|
|
|
|
|
- handshake result fields live here
|
|
|
|
|
|
|
|
|
|
### Node 3: session handshake path
|
|
|
|
|
|
2026-04-11 09:38:07 +08:00
|
|
|
Files completed in this step:
|
2026-04-11 09:34:25 +08:00
|
|
|
|
|
|
|
|
- `KeyBorad/KeyBorad/LOGIC/Lgc_Session.h`
|
|
|
|
|
- `KeyBorad/KeyBorad/LOGIC/Lgc_Session.cpp`
|
|
|
|
|
|
2026-04-11 09:38:07 +08:00
|
|
|
Implemented behavior:
|
2026-04-11 09:34:25 +08:00
|
|
|
|
|
|
|
|
- try CDC handshake
|
2026-04-11 09:38:07 +08:00
|
|
|
- send `HelloReq`
|
|
|
|
|
- wait for `HelloRsp`
|
2026-04-11 09:34:25 +08:00
|
|
|
- store the active transport
|
2026-04-11 09:38:07 +08:00
|
|
|
- keep a stream buffer for CDC bytes
|
|
|
|
|
- return the next parsed packet to upper layers
|
2026-04-11 09:34:25 +08:00
|
|
|
|
|
|
|
|
### Node 4: core facade
|
|
|
|
|
|
2026-04-11 09:40:59 +08:00
|
|
|
Files completed in this step:
|
2026-04-11 09:34:25 +08:00
|
|
|
|
|
|
|
|
- `KeyBorad/KeyBorad/LOGIC/Lgc_Core.h`
|
|
|
|
|
- `KeyBorad/KeyBorad/LOGIC/Lgc_Core.cpp`
|
|
|
|
|
|
2026-04-11 09:40:59 +08:00
|
|
|
Implemented behavior:
|
2026-04-11 09:34:25 +08:00
|
|
|
|
|
|
|
|
- give APP one small entry point
|
2026-04-11 09:40:59 +08:00
|
|
|
- start CDC handshake through session
|
|
|
|
|
- expose `Start / Poll / Close / GetState`
|
|
|
|
|
- refresh state from `HelloRsp`
|
|
|
|
|
- update a simple action text when packets arrive
|