I've looked up and down for this problem, but no one seems to have it.
I have two iPads. One is acting as a Bluetooth peripheral that is always in the foreground. Since I am more interested in the central side, I have made my central iPad background-capable for BLE-central. My workflow is as follows:
- Central app runs and starts scanning
- Peripheral advertises service (or comes within range)
- Central device connects to peripheral and stops scanning
- Peripheral stops advertisement (or leaves range)
- Central device disconnects and starts scanning
- Do steps 1-5 seamlessly whether the central is in the foreground or background
When I run my central iPad app, steps 3 and 5 repeat every 10 seconds, even though the service is being advertised the entire time. This happens in the foreground and background.
On disconnect, I get this error:
Error occurred while disconnecting peripheral: The specified device has disconnected from us.
Any ideas on why it keeps disconnecting? Does CoreBluetooth clean up the connections if no data is being transferred? Right now, my central is doing a one-off read of peripheral characteristics. It is not subscribing to updates, since the values are static. Thanks!!