Repository navigation
Peripheral-role L2CAP
PeripheralHost can now publish L2CAP channels and accept the channels that centrals open. This works on CoreBluetooth, on the in-process virtual radio, and over the simulator link. One simulator can open an L2CAP channel to another simulator.
let psm = try await host.publishL2CAPChannel()
for await channel in await host.incomingL2CAPChannels() {
Task {
for try await data in channel.incomingData {
try await channel.write(data)
}
}
}In-process virtual devices can publish channels too, with VirtualDeviceHandle.publishL2CAPChannel(psm:) and a handler that conforms to VirtualL2CAPAccepting.
New provider tools
bleswift-provider capturescans real devices with the Mac's radio and writes a fixture document.bleswift-provider statusshows the sessions of a running provider (--jsonfor JSON).bleswift-provider install-agentruns the provider at login.uninstall-agentremoves it.bleswift-provider --verboselogs each link message.
Fixed
- A late result of a cancelled or timed-out
openL2CAPChannelno longer goes to the next open. - A pending L2CAP open now fails when the peripheral disconnects. Before, it waited forever.
- A client with a different protocol version now always receives the provider's refusal and its reason.
Upgrade notes
- The link protocol is now version 2. Use the same BLESwift version for your app and for
bleswift-provider. - New public enum cases: see "Changed" in the changelog.
Full changelog: 3.1.0...3.2.0