How do you use IOBluetooth?

I managed to connect to and pair with a device. I can't figure out how to use a L2CAP channel. Here is my code

let device = IOBluetoothDevice(addressString:"A4:38:CC:3A:BF:16");
   if device?.isConnected() != true {
      print(device?.openConnection())
      let devicepair = IOBluetoothDevicePair(device: device)
      print(devicepair?.start())
 }

I figured out how to make a channel and receive data. But the data function isn't printing anything. Here is what I have so far:

class ChannelDelegate: IOBluetoothL2CAPChannelDelegate {

  func l2capChannelOpenComplete(_ l2capChannel: IOBluetoothL2CAPChannel!, status error: IOReturn)
  {
    print("Channel Opened!")
  }
  func l2capChannelData(_ l2capChannel: IOBluetoothL2CAPChannel!, data dataPointer: UnsafeMutableRawPointer!, length dataLength: Int) {
    print(dataPointer)
  }
let device = IOBluetoothDevice(addressString: "A4:38:CC:3A:BF:16");
var channel: IOBluetoothL2CAPChannel? = IOBluetoothL2CAPChannel()
device?.openL2CAPChannelSync(&channel, withPSM: 1, delegate: ChannelDelegate()))
channel?.setDelegate(ChannelDelegate())
How do you use IOBluetooth?
 
 
Q