Migrate HCICommandParameter encoding to DataContainer - #207
Merged
Conversation
Finish the encode-side DataContainer migration for the HCI layer (#161): - HCICommandParameter and HCIPacketHeader now require the generic append<Data: DataContainer>(to:) instead of Foundation's 'var data: Data'; DataContainer gains initializers for both. - Migrate all 91 command/header encoders to the generic API. - Remove 'import Foundation' from 167 files; only the host controller runtime (BluetoothHostController, HCILESetScanEnable, HCIError, HCIPacketHeader, HCICommandTimeout) still uses Foundation.Data. Source-breaking: command parameters and packet headers no longer expose 'data'; use 'Data(value)' instead.
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.
What changed
Finishes the encode-side
DataContainermigration for the HCI layer (#161), the counterpart to #206 for BluetoothGATT.HCICommandParameternow requires the genericfunc append<Data: DataContainer>(to:)instead of Foundation'svar data: Data, andHCIPacketHeader(command/event headers) gets the same treatment.DataContainergainsinit<T: HCICommandParameter>(_:)andinit<T: HCIPacketHeader>(_:)for building buffers.DataConvertible(e.g.HCILECreateConnection,HCILEEncrypt,HCILEAddDeviceToWhiteList) now encode through their existingappenddirectly, dropping the redundant Foundation wrappers.import Foundationremoved from 167 of 172 files. The remaining five (BluetoothHostController,HCILESetScanEnable,HCIError,HCIPacketHeader,HCICommandTimeout) genuinely useFoundation.Data/TimeInterval/CustomNSErrorin the host-controller runtime and are left for a follow-up.HCIWriteLocalNameencodes UTF-8 + zero padding without constructing intermediateFoundation.Data; the crashingHCISetEventFilterstub keeps itsfatalErrorbut under the new signature (implementing it is tracked separately).Not in scope
Making the host-controller runtime (
deviceRequest/receive,garbageResponse(Data)) generic overDataContainer— that is a deeper refactor of the async I/O surface.Reviewer notes
.data— useData(parameter)instead (the test target bridges this internally).return Data([…])→data += […], builder pattern → direct appends); byte order and field order are unchanged.swift format lint,swiftlint).