I am new to Bluetooth, but have been working for a month or so on a Android Client that connects to a BLE peripheral to write data to a characteristic.
My BLE peripheral is a nrf52832 (Nordic) device and I have loaded the BLE_SM (security manager) example project so that I can use bonding/pairing for secure communications.
My Android code pairs/bonds successfully to the peripheral, but from what I can see the peripheral now stops advertising. I'm not sure if this is normal or it's because I received a gap.onDisconnection event of type REMOTE_USER_TERMINATED_CONNECTION.
Irrespective I am bonded so you would think I could now not need to scan anymore for the device and could just call device.connectGatt()
, but it is not working and my callback gets a GATT STATE_DISCONNECTED event.
I read in another post that had pasted the following from Nordic (Tutorial):
It is not possible to connect to a peripheral which is not advertising, even though one knows its address from before. This is because the peripheral will only turn on the receiver for a set amount of time after transmitting an advertisement. This time is used to listen for connection requests and scan requests.
If this is in fact true, it seems I would be unable to stop the peripheral continually advertising, which is not helpful if I am trying to reduce the peripheral's power consumption.