18

I am sporadically getting the message "CoreBluetooth[WARNING] Unknown error: 1309” on the console when running a BlueTooth app I am developing. Even though the message states that it is a warning, it stops execution of the app. I have been able to work around this problem by turning the Bluetooth setting off and then back on. Can anyone tell me what is causing this and what I should do to avoid it?

James Lin
  • 715
  • 6
  • 18
  • Did you write or read a characteristic before getting that warning? – Larme Dec 18 '13 at 12:20
  • Did you ever resolve this? I get this occasionally when using the simulator. Workaround is to turn off and then turn on the Bluetooth on the device (simulator in my case) – OneGuyInDc Jan 11 '14 at 19:04
  • Same problem here. I tried to isolate the source of the problem and seems to be bound to the scanForPeripheral function. – valvoline Feb 08 '14 at 10:12
  • I am seeing this error a lot. It's triggered when connecting to a peripheral - after connectToPeripheral is caused, didFailToConnectToPeripheral is passed an Unknown Error: 1309. It wedges the BLE stack, apparently - only a reboot seems to allow the central to connect to that same peripheral. This is between two IOS devices. Any help would be greatly appreciated - not getting much help from Apple. – moe Feb 17 '14 at 18:49
  • Same problem here. Seems that sometimes the CoreBluetooth stack turns into an inconsistent state that prevents the affected device to connect with any BLE device around. We was able to reproduce the problem in a deterministic way, using a simple application that is both scanner and advertiser of service/characteristic. When four or more devices are scanning and advertising at the same time, if you kill and restart the application three or four times it turn into an inconsistent state, returning the infamous CoreBluetooth[WARNING] Unknown error: 1309 We was not able to fix the problem. – valvoline Feb 23 '14 at 10:30
  • I'm also getting this problem. is there any way to escalate with apple? – Allen Mar 09 '14 at 06:18
  • I think this situation happens when you keep a connection to the peripheral and never disconnect it. Try to disconnect it ASAP. – Kevin Cao Mar 12 '14 at 09:15
  • I know this topic pretty old, I just wanted to add that I ran into this problem and figured out this: 1) It only seems to occur when you connect to a device you have previously connected to and 2) I was able to fix this with a simple retry mechanism - simply trying to connect again a few seconds later seems to work all of the time for me. Maybe this helps ^^ – BlackWolf Jul 05 '14 at 08:38
  • Are you trying to scan any device using core bluetooth – Balaji Kondalrayal Jul 29 '14 at 07:17

2 Answers2

3

That's a known issue, It's caused due to deadlock in CoreBluetooth (Apple's bug), 1309 error is mostly appears when your app operates as a Central and Peripheral, and when the operations are overlapping each other, in that case deadlock will be produced (which can be resolved by rebooting device).

Seems BLE stack gets corrupted in some other cases too (iOS 7 and lower), on iOS 7.1 stack is much more stable, and doesn't have issues like this.
How we resolve issues like this?
Showing troubleshoot screen where user can fix problem himself/herself.

You can find known iOS issues here http://help.getpebble.com/customer/portal/articles/957568-troubleshooting#Pair

Anyway I think you can start using https://github.com/l0gg3r/LGBluetooth which will reduce chance having bugs on your side, and make your job much more effective.
Here are read/write examples

Read

[LGUtils readDataFromCharactUUID:@"f045"
                     serviceUUID:@"5ec0"
                      peripheral:peripheral
                      completion:^(NSData *data, NSError *error) {
                          NSLog(@"Data : %s Error : %@", (char *)[data bytes], error);
                      }];

Write

int8_t dataToWrite = 0xFF;
[LGUtils writeData:[NSData dataWithBytes:&dataToWrite length:sizeof(dataToWrite)]
       charactUUID:@"cef9"
       serviceUUID:@"5ec0"
        peripheral:peripheral 
        completion:^(NSError *error) {
            NSLog(@"Error : %@", error);
        }];
l0gg3r
  • 8,564
  • 3
  • 24
  • 44
1

Since the CoreBluetooth is issuing this “warning”, there has to be someone at Apple or in the Bluetooth community who wrote the code or at least knows what situation is triggering the message. Can anyone tell me what is causing this and what I should do to avoid it, or point me to some material that will help me in this endeavor?

If I had to hazard a guess, I’d say that the primary reason you haven’t received much of a response is because you’ve given no description of your issue beyond “sometimes I see error 1309 and things stop working”.

If you haven’t already, please file a bug on bugreporter.apple.com and include as much detail as possible - a description of what you’re trying to do, repro steps that lead to the issue, even a test app. Respond to me directly with the bug number, and I will follow-up

bLacK hoLE
  • 681
  • 1
  • 7
  • 20