3

My app needs to detect other iPhones and connect to all of them one at a time quickly (Those iPhones also have the same functionality). So I implemented both peripheral and central. I only try connecting to another phone if:

if (![_discoveredPeripheral isConnected] && [[UIDevice currentDevice] name] < [advertisementData objectForKey:@"kCBAdvDataLocalName"]) 

(I advertise the name of the device to avoid both devices to connect to each other at the same time)

It works correctly, but after a few minutes I get this error:

[1622:1103] CoreBluetooth[ERROR] XPC connection interrupted, resetting

Is the problem in my algorithm of connecting? Or is it not doable to be a peripheral and connect as a central at the same time?

Aboelseoud
  • 556
  • 1
  • 7
  • 22

1 Answers1

0

I was also working with the same kind of application. As I understand you are trying to use same device for the central as well as peripheral application .You cannot do this . Because what I have observe is peripheral application is only can be detected when it is in foreground and in same device you cant run the two program in the foreground at a time . So you need to install the central and peripheral application in two separate devices .

V-Xtreme
  • 7,230
  • 9
  • 39
  • 79
  • They aren't two different apps. The same controller implements both and it works without connecting. But once I connect, the app crashes after a while. – Aboelseoud May 14 '13 at 09:14
  • actually you can implement both central and peripheral in a single application . But only one mode will work at a time . – V-Xtreme May 14 '13 at 09:16
  • That's what I did. But for both to work do I have to stopAdvertising when I startScanning and stopScan when I startAdvertising? – Aboelseoud May 14 '13 at 09:17
  • have look at http://developer.apple.com/library/ios/#samplecode/BTLE_Transfer/Introduction/Intro.html this is what you wanted . – V-Xtreme May 14 '13 at 09:23
  • I've seen that. This is not what I want. I need the all the iPhones to be centrals and peripherals at the same time without any user interacting with the phone in order to exchange information. – Aboelseoud May 14 '13 at 09:25