3

我正在尝试在 iPhone 和在 MacOS 上运行的应用程序之间打开两个 L2CAP 通道。

MacOS 应用发布了两个频道:PSM=193PSM=194.

我在 iOS 应用上打开这些频道:

peripheral.openL2CAPChannel(CBL2CAPPSM(193))
peripheral.openL2CAPChannel(CBL2CAPPSM(194))

然后我得到成功的委托回调:

public func peripheral(_ peripheral: CBPeripheral,
                    didOpen channel: CBL2CAPChannel?, 
                              error: Error?) {

   print("Opened channel PSM is: \(channel.psm)")

   // Keep strong reference to opened channel
   openedChannels.append(channel)
}

有趣的是输出......:

Opened channel PSM is: 193 
Opened channel PSM is: 193 // !?!

使用不同的通道实例但使用相同的 PSM 调用委托回调。在 MacOS 应用程序上,我确实收到了该频道194已打开的回调。但是,当我向通道写入一些数据时194,它实际上是发送到193我打开的第一个通道。我做错了什么还是CoreBluetooth错误?

4

0 回答 0