I want to build an iOS App, which connects every minute with a BLE peripheral to retrieve a specific characteristic. In most cases this works very well, but after a few hours the CBPeripheral's state gets stucked at .connecting
sometimes, if I try to connect again.
I tried to observe that behavior with a Bluetooth sniffer:
1,010,604 38 ADV_IND (pub) 0x000000000159 24 42 00:00:00.000665 23.02.2017 02:55:22.715507
1,010,605 38 CONNECT_IND (rand) 0x000000000901 (pub) 0x000000000159 34 52 00:00:00.000424 23.02.2017 02:55:22.715931
As you can see, the peripheral sends out the advertising and my iPhone answers with the connect indication directly. At this point the CPPeripheral's state stuck at .connecting
and centralManager(_:didConnect:)
is not getting called.
At the moment I just retry to connect to the peripheral and the 4th or 5th attempt is working. But why does that happen? I can't recognize a pattern in this strange behavior.