12

When I am trying to connect with Bluetooth LE with my iphone application. It gives CoreBluetooth[ERROR] XPC connection interrupted, resetting. Why is it.?

  • 1
    Please add more details on exception – Niroshan Abayakoon Mar 01 '13 at 02:17
  • I'm facing this problem too on my Mac Mini @ 10.9 (for Mac app, I use <IOBluetooth/IOBluetooth.h> instead of <CoreBluetooth/CoreBluetooth.h>, everything else is the same). I noticed that this problem does not happen if I am transmitting some data over Wi-fi at the same time. 500 kbit/sec is enough to get rid of this problem. Once I stop data transfer over Wi-fi, the problem starts occurring again. I suspect the root cause is in a timing issue, i.e. there is someting in the CoreBluetooth stack which happens faster than expeted, hence the issue is. – Sergey Nov 04 '13 at 17:40
  • I am getting this problem on a Late-2012 Mac Mini (Broadcom Chipset: 20702B0 Firmware Version: v78 c8621) running 10.9 Mavericks (Apple Bluetooth Software Version 4.2.0f6 12982). The CBCentralManager gets XPC connection interrupted and then resets itself always 500ms after connecting to peripheral. Trying @Sergey’s trick of transferring data over wifi using nc did not seem to help. On the other hand, I don’t get this problem on an older Mid-2011 Mac Mini (Broadcom Chipset: 20702A3 Firmware Version: v131 c5495) also running Mavericks. – yonran Dec 05 '13 at 20:54

4 Answers4

3

“CoreBluetooth[ERROR] XPC connection interrupted, resetting” means that the blued Bluetooth daemon has crashed. You may be able to see more details by opening Console and looking at the system log and DiagnosticReports.

In my case, it seems that the exception within blued happens because SerialNumber is nil somewhere. I have no workaround and have reported it to bugreport.apple.com (bug 16075785).

The method that actually causes the exception is deterministic but varies by computer. On one computer with internal Bluetooth 4.0 chip, it is the call to -[CBPeripheral discoverCharacteristics:forService:]. On another computer with Bluetooth 4.0 USB adapter, it is the call to -[CBPeripheral writeValue:forCharacteristic:type:] or -[CBPeripheral setNotifyValue:forCharacteristic:]

'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: SerialNumber)'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x00007fff91b1141c __exceptionPreprocess + 172
        1   libobjc.A.dylib                     0x00007fff9231de75 objc_exception_throw + 43
        2   CoreFoundation                      0x00007fff91a0c62e -[__NSDictionaryM setObject:forKey:] + 1102
        3   blued                               0x0000000103d5d422 blued + 336930
        4   blued                               0x0000000103d4b115 blued + 262421
        5   IOBluetooth                         0x00007fff97354093 -[IOBluetoothL2CAPChannel processIncomingData:] + 576
        6   IOBluetooth                         0x00007fff97353e3c -[IOBluetoothL2CAPChannel handleMachMessage:] + 45
        7   Foundation                          0x00007fff94d98e35 __NSFireMachPort + 94
        8   CoreFoundation                      0x00007fff91a42d04 __CFMachPortPerform + 388
        9   CoreFoundation                      0x00007fff91a42b69 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41

Edit 2014-02-27: My particular crash happens because the device GATT table contains an invalid non-UTF8 value for Characteristic 2A25 «Serial Number String» within Service 180A «Device Information», and the blued daemon is creating a NSString* from it and putting it into a NSMutableDictionary. A temporary workaround is to make setObject:forKey: never fail within blued by jumping to the nearest ret command:

sudo /Applications/Xcode.app/Contents/Developer/usr/bin/lldb <<PID of blued>>
breakpoint set --fullname "-[__NSDictionaryM setObject:forKey:]" --condition "$rdx == 0"
breakpoint command add 1
register write pc `$pc+967`
continue
DONE
yonran
  • 18,156
  • 8
  • 72
  • 97
  • Just to add to this. If you end up with a bad GATT table in OSX during development, you reset it by restarting your computer. I spent two hours trying to figure out why I couldn't discover any services before trying a reboot. The reboot solved it. Bad GATT tables can be cleared on iOS by disabling your adapter and re-enabling it (this clears the GATT cache). – Sandy Chapman Mar 26 '14 at 13:36
  • 2
    @SandyChapman, for some incorrect GATT entries, restarting isn’t enough. See [Does blued cache ATT values, and how to clear the cache?](http://stackoverflow.com/questions/22028998/does-blued-cache-att-values-and-how-to-clear-the-cache) for deleting it manually. – yonran Mar 26 '14 at 16:03
  • How did you get the stack trace? I'm running on iOS and all I get is the log – André Fratelli Aug 09 '15 at 22:40
  • @AndréFratelli, the stack trace I got was from a blued crash on OSX, and it is available in Console under Diagnostics. I have not had to retrieve crash reports of system daemons on iOS, but hopefully this guide is helpful: [Chromium: Retrieving Crash Reports on iOS](http://www.chromium.org/developers/how-tos/retrieving-crash-reports-on-ios) – yonran Aug 10 '15 at 20:09
  • experienced something similar - was solved by resetting network settings on iOS which cleared bluetooth device cache. – Cherpak Evgeny Feb 17 '16 at 09:59
2

Happens to me too - specifically when initiating a CBCentralManager (CM) scan when I stop the CM scan and restart it - it is usually resolved. I am afraid it's a bug in CoreBluetooth implementation

mindbomb
  • 1,642
  • 4
  • 20
  • 35
0

I got this crash when adding a service to a CBPeripheralManager. Turns out that I had a nasty typo (no compiler errors or warnings) in my methods to get some characteristic ids. So a couple of characteristics were created with nil ids. All I got was this error in the logs under iOS 7.1.1 and when looking at my device logs found BTServer crash reports. My device with a iOS 8.1.2 didn't log this to the console so it might have been even worse to find the issue.

SuperGuyAbe
  • 525
  • 1
  • 5
  • 5
0

Accidentally found another reason for this error: USB hub and poor connection or power made my debugging environment corrupt. Meaning it did report the error irregularly.

More on my Odyssee: Usually I connect directly to build machine, but when I got this issue it was connected via USB hub of my monitor. I restarted Xcode, restarted the buildmachine with no success. Funny fact: Same setup was working properly for 3 days now, but on friday (today) connecting to debugger was reluctant.

Hope this hint isn't a one time wonder ;-)

andreas-supersmart
  • 4,114
  • 2
  • 18
  • 13