3

I'm trying to open two L2CAP channels between iPhone and app running on MacOS.

MacOS app published two channels: PSM=193 and PSM=194.

I open those channels on iOS app:

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

And then I get successful delegate callbacks:

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)
}

What's interesting though is the output...:

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

Delegate callback is called with different channel instance but with the same PSM. On the MacOS app, I do get callback that channel 194 was opened though. However, when I write some data to the 194 channel, it's actually send to the first 193 channel that I opened. Am I doing something wrong or is it a CoreBluetooth bug?

msmialko
  • 1,439
  • 2
  • 20
  • 35
  • Please differentiate the code locations, is all of the code given running on the IOS device or are the callbacks running on MacOS? It is not possible to distinguish given the code. –  Dec 01 '18 at 05:26
  • All quoted code is from iOS side. – msmialko Dec 02 '18 at 10:21
  • The bluetooth spec says that PSM-channel numbers must be odd-numbered. Maybe it just assumes the closest even-numbered channel and uses that. – Nailer Mar 11 '19 at 10:40

0 Answers0