Skip to content

Commit

Permalink
Get the created L2CAP channel
Browse files Browse the repository at this point in the history
Merge pull request #20 from playmoweb/get-l2cap-channel
  • Loading branch information
manolofdez authored Feb 10, 2023
2 parents 6e90f2d + 088e952 commit b130ad4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Sources/Peripheral/Peripheral.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class Peripheral {

/// Attempts to open an L2CAP channel to the peripheral using the supplied Protocol/Service Multiplexer (PSM).
@available(iOS 11.0, *)
public func openL2CAPChannel(_ PSM: CBL2CAPPSM) async throws {
public func openL2CAPChannel(_ PSM: CBL2CAPPSM) async throws -> CBL2CAPChannel? {
try await self.context.openL2CAPChannelExecutor.enqueue { [weak self] in
self?.cbPeripheral.openL2CAPChannel(PSM)
}
Expand Down Expand Up @@ -376,7 +376,7 @@ extension Peripheral.DelegateWrapper: CBPeripheralDelegate {
func peripheral(_ cbPeripheral: CBPeripheral, didOpen channel: CBL2CAPChannel?, error: Error?) {
Task {
do {
let result = CallbackUtils.result(for: (), error: error)
let result = CallbackUtils.result(for: channel, error: error)
try await self.context.openL2CAPChannelExecutor.setWorkCompletedWithResult(result)
} catch {
Self.logger.warning("Received OpenChannel result without a continuation")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Peripheral/PeripheralContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ class PeripheralContext {
private(set) lazy var discoverDescriptorsExecutor = AsyncExecutorMap<CBUUID, Void>()
private(set) lazy var readDescriptorValueExecutor = AsyncExecutorMap<CBUUID, Void>()
private(set) lazy var writeDescriptorValueExecutor = AsyncExecutorMap<CBUUID, Void>()
private(set) lazy var openL2CAPChannelExecutor = AsyncSerialExecutor<Void>()
private(set) lazy var openL2CAPChannelExecutor = AsyncSerialExecutor<CBL2CAPChannel?>()
}

0 comments on commit b130ad4

Please sign in to comment.