In Core Bluetooth, after connecting to a device, I turn off the device and the device is disconnected. But when I turn on the device again, there is no didDiscoverPeripheral
called again. How can I reconnect to the device again?
Navigate to Android–> Restrictions–> Allow Network Settings. Enable the 'Force Bluetooth' option to prevent the users from turning OFF the blue tooth and the 'Force Wi-Fi' option to prevent turning OFF the Wi-Fi.
The Core Bluetooth framework provides the classes needed for your apps to communicate with Bluetooth-equipped low energy (LE) and Basic Rate / Enhanced Data Rate (BR/EDR) wireless technology.
When you disconnect a device with cancelPeripheralConnection
the didDisconnectPeripheral
delegate method will be invoked. However from iOS 6.0 the device remains connected for about 40-50 seconds (or more), so no didDiscoverPeripheral
will be invoked in that timeframe. If you want to "discover" it again just call the retrieveConnectedPeripherals
method and you will get the reference in didRetrieveConnectedPeripherals
.
However, the best solution is to save the device's UUID and use that to reconnect with the retrievePeripherals
method. This will invoke didRetrievePeripherals
and you can reconnect with connectPeripheral
. This is the fastest way to reconnect to a device, no scanning is required in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With