CoreBluetooth shuts down repeatedly

I was looking for this problem, but no one sees it.

I have two iPads. One of them acts as a Bluetooth peripheral device, which is always in the foreground. Since I'm more interested in the central side, I made my central iPad mode for the BLE central one. My workflow is as follows:

  • The central application starts and starts the scan.
  • Peripheral Ad Service (or in range)
  • The central device connects to the peripheral device and stops scanning.
  • The peripheral stops the ad (or leaves the range)
  • The central device turns off and starts the scan.
  • Follow steps 1-5, regardless of whether the center is in the foreground or in the background.

When I launch my central iPad app, steps 3 and 5 are repeated every 10 seconds, even if the service is advertised all the time. This happens in the foreground and in the background.

When disconnecting, I get this error:

Error occurred while disconnecting peripheral: The specified device has disconnected from us. 

Any ideas on why he keeps disconnecting? Does CoreBluetooth clear connections if no data is transferred? Right now, my central is doing a one-time read of peripheral characteristics. It does not subscribe to updates because the values ​​are static. Thanks!!

+7
ios background-process core-bluetooth
source share
1 answer

In my case, the solution was to subscribe to this characteristic regardless of whether this value is static or not. It seems that the subscription will keep the connection alive, whereas if you read one-time values, the structure will try to save battery life and disconnect the connection, forcing you to manually reconnect before doing another read or write.

+7
source share

All Articles