2013-03-12 79 views

回答

7

我已經運行到這個也是一樣,它似乎是在藍牙核心的XPC通信的錯誤:

2013-03-22 14:49:24.652 Buggy[985:907] Connecting to peripheral <CBConcretePeripheral: 0x1dd4e150 UUID = (null), Name = "iPhone 5 #003014", IsConnected = NO> 
2013-03-22 14:49:24.659 Buggy[985:907] CoreBluetooth[WARNING] Unknown error: 311 
2013-03-22 14:49:24.661 Buggy[985:907] Failed to connect to peripheral <CBConcretePeripheral: 0x1dd4e150 UUID = (null), Name = "iPhone 5 #003014", IsConnected = NO> 
2013-03-22 14:49:24.689 Buggy[985:907] Discovered peripheral <CBConcretePeripheral: 0x1dd644d0 UUID = (null), Name = "iPhone 5 #003014", IsConnected = NO> with advertisement data { 
    kCBAdvDataLocalName = "iPhone 5 #003014"; 
    kCBAdvDataServiceUUIDs =  (
     "Unknown (<b2e74c08 96094371 a8f0978c 655700ea>)" 
    ); 
}, RSSI: -50 
2013-03-22 14:49:24.692 Buggy[985:907] Connecting to peripheral <CBConcretePeripheral: 0x1dd644d0 UUID = (null), Name = "iPhone 5 #003014", IsConnected = NO> 
2013-03-22 14:49:45.035 Buggy[985:110b] CoreBluetooth[ERROR] XPC connection interrupted, resetting 
2013-03-22 14:49:45.050 Buggy[985:907] Central manager updated state to: 1 
2013-03-22 14:49:45.116 Buggy[985:907] Central manager updated state to: 4 
2013-03-22 14:49:47.271 Buggy[985:907] Central manager updated state to: 5 

後這點事情又開始工作,至少要等到錯誤311環再次來襲幾分鐘後。

下面是這一直是可靠的,我一個解決辦法:

// In centralManager:didFailToConnectPeripheral:error:, ARC enabled 
if (error.code == 0) { 
    self.centralManager.delegate = nil; 
    self.centralManager = nil; 
    // Remove all references to any peripherals you've been interacting with 
    [self.peripherals removeAllObjects]; 

    /* Some delay (more than the next iteration of the runloop, less than 2 seconds) is required in order to: 
    * • Allow ARC to drain the autorelease pool, ensuring destruction of the centralManager 
    * • Allow Core Bluetooth to turn off the radio. 
    * 
    * This means that this workaround might not work if: 
    * • Your code has another active central manager somewhere 
    * • Another app is using BLE (in theory; I haven't tested this) 
    */ 
    double delayInSeconds = 2.0; 
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 
     self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue()]; 
     [self startScanning]; 
    }); 
} 
+0

成功連接到外圍設備「CoreBluetooth [WARNING] Unknown error:14」導致它斷開連接後出現此錯誤。有任何想法嗎? – mikemeli 2013-03-22 23:42:44

+0

看起來像你已經發布了[這個問題](堆棧溢出)(http://stackoverflow.com/questions/15581684/corebluetoothwarning-unknown-error-14-on-iphone-5)。我不知道手,但[你並不孤單](http://e2e.ti.com/support/low_power_rf/f/538/p/220588/777454.aspx)。 – numist 2013-03-23 01:34:47

相關問題