1

My problem is that on line 35, where I start IOBluetoothDeviceInquiry, it gives me the following error: Failed to create connection to the daemon: Distributed objects message send timed out Here is my code that is not working:

import Cocoa
import IOBluetooth

class BlueDelegate : IOBluetoothDeviceInquiryDelegate {
    func deviceInquiryDeviceFound(_ sender: IOBluetoothDeviceInquiry, device: IOBluetoothDevice) {
        sender.stop()
        let thingy = device
        print("Found Device: \(thingy.nameOrAddress)")
        print(IOBluetoothDevicePair(device: thingy).start())
    }
}


@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    let bt = IOBluetoothDeviceInquiry(delegate: BlueDelegate())

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        // Insert code here to initialize your application
        print("Starting...")
        bt?.updateNewDeviceNames = true
        print("0")
        bt?.stop()
        print("1")
        switch (bt?.start())! {
            case kIOReturnSuccess: print("Success!");break
            case kIOReturnError: print("General Error.");break
            case kIOReturnNoMemory: print("Memory Allocation Error.");break
            case kIOReturnNoResources: print("resource shortage");break
            case kIOReturnIPCError: print("Mach IPC failure");break
            case kIOReturnNoDevice: print("no such device");break

            default:print("Unknown Status.");break
        }
        print("2")
    }

    func applicationWillTerminate(_ aNotification: Notification) {
        // Insert code here to tear down your application
        bt?.stop()
    }


}

What should I do to fix this problem so that my app can continue development?

Thanks in advance,

Aaronjam.

Aaronjam
  • 15
  • 1
  • 10

0 Answers0