Files
KeyBoard_QT/docs/host_dri_rebuild.md
2026-04-11 10:51:29 +08:00

1.9 KiB

Host DRI Rebuild

Goal

Keep the device runtime layer small and transport-only.

The DRI layer should:

  • enumerate endpoints
  • open and close connections
  • read raw bytes
  • write raw bytes

The DRI layer should not:

  • parse frames
  • manage protocol state
  • decide handshake success

Completed Nodes

Node 1: GATT placeholder

Files:

  • KeyBorad/KeyBorad/DRI/GATT/Dri_Gatt.h
  • KeyBorad/KeyBorad/DRI/GATT/Dri_Gatt.cpp

Design notes:

  • reserves the BLE transport position early
  • keeps the implementation small for now
  • avoids mixing GATT transport with logic concerns

Implemented behavior:

  • keep the same surface shape as CDC:
    • Enum
    • Open
    • Close
    • ReadBytes
    • WriteBytes
  • stay transport-only
  • keep real BLE implementation for a later node

Node 2: BLE device discovery

Files updated in this step:

  • KeyBorad/KeyBorad/DRI/GATT/Dri_Gatt.cpp
  • KeyBorad/KeyBorad/KeyBorad.vcxproj

Design notes:

  • use Qt Bluetooth directly
  • keep discovery synchronous for now so the first teaching step stays small
  • only collect low-energy devices

Implemented behavior:

  • start BLE discovery with QBluetoothDeviceDiscoveryAgent
  • collect device name and address
  • filter to LowEnergyCoreConfiguration
  • stop after a short timeout

Node 3: CDC transport cleanup

Files updated in this step:

  • KeyBorad/KeyBorad/DRI/Dri_Cdc.h
  • KeyBorad/KeyBorad/DRI/Dri_Cdc.cpp

Design notes:

  • remove frame parsing from the driver
  • remove handshake ownership from the driver
  • keep only enumerate/open/close/read-bytes/write-bytes

Implemented behavior:

  • list ports with Dri_Cdc_Enum()
  • open one port with Dri_Cdc_Open()
  • close one port with Dri_Cdc_Close()
  • read raw bytes with timeout
  • write raw bytes with timeout

Next DRI nodes

  • implement real GATT discovery and notify/write path
  • provide one simple connection summary for logic layer