feat(core): model board_id in USB and BLE device-info status - #32
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Firmware now reports its board model as a stable slug (
board_id, e.g.crowpanel_28) in device info on both transports (canshift-firmware#67, context in CANShift/canshift-firmware#66). This adds the matching contract in@canshift/coreso the tuner can auto-detect an already-flashed device's board for the multi-board flashing chain.Where the field landed
BLE STATUS —
src/schemas/ble-status.ts(already modeled, added the typed field)Firmware emits
{ ver, board_id, can, is_day }. The wire schema is deliberately.passthrough(), soboard_idalready flowed through untyped — this makes it a typed optional:board_idonBleStatusWireSchema,boardId?: stringonBleStatus, and thever→firmwareVersionstyle mappingboard_id → boardIdinbleStatusFromWire.USB CMD_GET_STATUS —
src/schemas/usb-status.ts(new)The USB device-info response
{ status:"ok", version, protocol, is_day, board_id }was not modeled anywhere in core — the tuner had no typed contract for it, yet USB is the flasher's primary connection and #66's board auto-detection reads exactly this frame. Added a schema mirroring the BLEparseBleStatuspattern:UsbStatusWireSchema(.passthrough(), matching the BLE status forward-compat convention) withstatusas the success discriminator,version/protocol/is_dayrequired,board_idoptional.UsbStatus={ firmwareVersion, protocolVersion, isDay, boardId? }(version→firmwareVersion,protocol→protocolVersion,board_id→boardId).usbStatusFromWire+parseUsbStatus(raw): UsbStatusResult(theok/invalid_json/not_an_object/wrong_shapediscriminated result the tuner consumes).Both are exported from the barrel (
parseUsbStatus,USB_STATUS_MAX_STRING_LEN, typesUsbStatus/UsbStatusResult), mirroring the BLE status export surface.Naming / convention
board_id(snake_case) on the wire ↔boardId(camelCase) in TS, via the*FromWireboundary mapper — same convention asver → firmwareVersion,is_day → isDay.No schema-version bump
These are ephemeral device→app status frames, not persisted
DashboardConfig, so theCURRENT_SCHEMA_VERSION+ migration rule does not apply. The change is purely additive:boardIdis optional on both, so a frame from older firmware without it still parses.Note: the firmware-caps-parity suite checks
#definecaps, not status-frame JSON keys, so there is no automated status-field parity assertion today — this keeps core's status contract in sync with firmware manually. A grep-style parity assertion could be a follow-up but is out of scope here.Test plan
npm run build/npm run lint/npm run format:check— cleannpm test— 1039 passed, 3 skipped (unrelated); firmware-parity suites green with the sibling firmware checkout (which has canshift-firmware#67 merged). New coverage:board_id;bleStatusFromWireexposesboardIdand omits it when absent;parseBleStatusexposes it end-to-endboard_idparses and exposesboardId; frame without it stays valid; passthrough tolerates unknown keys; invalid JSON / non-object / wrong-shape rejection pathsReferences CANShift/canshift-firmware#66. Do not merge — ready for review; the 2.5.0 release is handled separately.