I am writing an application using CoreBluetooth in iOS8 that detects and connects to other phones using the application. I'm trying to find a better way to create a connection, while both applications are data-based, but they had difficulty in a scenario where both phones have background + blocked ones. I followed the suggestions of this post:
How to detect neighboring devices with Bluetooth LE in iOS 7.1 both in the background and in the foreground?
I could not establish a connection when both phones were marked + blocked, but I was able to get a connection in which the peripheral and central phones are blocked + blocked, and then I unlock the central (central part of the background). When I unlock the peripherals, nothing happens. It also works when they are created but not locked.
So, to establish a connection when unlocking the "periphery", I decided to create a central and peripheral device on both phones for simultaneous scanning and advertising. No matter what the other detects, scanning / advertising and connection will stop first. I am having problems with this method, which are described in detail in the following two questions:
Peripheral and central at the same time in iOS
iOS CoreBluetooth Simultaneous Peripheral and Central Managers
Basically, I think that when both of my devices try to connect to each other at the same time, they become freezes when they try to connect and didConnectPeripheral is never called on either of them (the last thing they both display is a message saying that they trying to connect). It worked sometimes, although I am also a little confused why there is a probabilistic nature of the connection. Does anyone have any suggestions on how to approach the problem? If there is a better way to establish a connection when both applications are marked + blocked, let me know because it was my original problem.
Thanks!
source share