Bluetooth caching

Hi,

I am using nRF Connect SDK, 2.2.0.

I am developing a Central device, which performs the following, in this order:

  1. Enables Bluetooth (bt_enable())
  2. Starts scanning (bt_le_scan_start()) looking for a specific Peripheral
  3. Once the Peripheral is found - it connects to it (bt_conn_le_create())
  4. Once connection is established, it starts discovery of primary service and few characteristics (bt_gatt_discover())
  5. After everything needed is discovered, at some point later, the Central disconnects from the Peripheral (bt_conn_disconnect() with reason 
    BT_HCI_ERR_REMOTE_USER_TERM_CONN)

All of the above works - no errors/warnings in the console.

After step 5, once the Central is disconnected, the Peripheral is powered OFF. While the Peripheral is OFF, if I repeat steps 1-5 - they all succeed - the Bluetooth stack still finds (scan) the peripheral, is able to connect to it, even though it is not there. The discovery step does not discovery anything - the callback is invoked with attr set to NULL.

My question is - is there a way to clear all cached information? What I want to see is, for example, a scan that does not find the Peripheral.

Thank you,

D.

Parents
  • Some more information:

    Just for testing, I tried steps 1, 2 and 3, only. What I see is that, when scan is started again, later, and the Peripheral is not there, I still get ADV report, with some random address for the Peripheral - an address that the Peripheral never used.

    If the Peripheral comes back online, I still get some random address (in the ADV report) - not the correct Peripheral address.

    I also noticed that, when I get the random address, I invoke bt_le_scan_stop(), which completes without error. But after that, the scan callback is invoked again, even though I stopped scanning. And the second invocation contains the correct Peripheral address.

    Any idea why this is happening?

    Maybe it is related to the fact that bt_disable() is not really implemented, based on this:

    https://devzone.nordicsemi.com/f/nordic-q-a/93896/how-to-disable-bt-in-ncs2-1-2

Reply
  • Some more information:

    Just for testing, I tried steps 1, 2 and 3, only. What I see is that, when scan is started again, later, and the Peripheral is not there, I still get ADV report, with some random address for the Peripheral - an address that the Peripheral never used.

    If the Peripheral comes back online, I still get some random address (in the ADV report) - not the correct Peripheral address.

    I also noticed that, when I get the random address, I invoke bt_le_scan_stop(), which completes without error. But after that, the scan callback is invoked again, even though I stopped scanning. And the second invocation contains the correct Peripheral address.

    Any idea why this is happening?

    Maybe it is related to the fact that bt_disable() is not really implemented, based on this:

    https://devzone.nordicsemi.com/f/nordic-q-a/93896/how-to-disable-bt-in-ncs2-1-2

Children
Related