1

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.

karel
  • 5,489
  • 46
  • 45
  • 50
MarkW
  • 51
  • 3

1 Answers1

2

The citation is 100% true. Connection setup has nothing to do with if the device is bonded or not (assuming you don't use directed advertising). If the peripheral is neither connected nor advertising, the radio is completely off and therefore a central can't connect.

If you want to minimize power consumption, make sure you don't advertise when you don't need to. Depending on your use case, can you have anything triggering advertising? For example a button or a sensor event?

If you need to advertise all the time, you can try use a longer advertising interval to save battery, but this will increase discovery and connection setup time.

Emil
  • 16,784
  • 2
  • 41
  • 52
  • Thanks for the response. Have additional question/update. Does it make sense for my peripheral to set the advertising to say 1 second after powering up and after a device pairs/bonds to drop the advertising to say once per minute? Also is the radio always listening even with large advertising periods? – MarkW Feb 18 '19 at 14:33
  • FYI. I am playing around with creating my own smart watch so the peripheral (watch) should always have the radio enabled. – MarkW Feb 18 '19 at 14:56