This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

The scan observer stops getting called after a failed attempt to connect to a peripheral using whitelist.

Hello All,

I have the following issue
- a peripheral and a central using nrf52832 with SDK 15.3 and S132
- on the peripheral I advertise with a whitelist
- the central scans with UUID filter activated for a specific UUID

Now when the central sees the peripheral, it tries to connect to it but since it is not in the centrals whitelist the connection is not established.
The problem on the central side is that the observer function nrf_ble_scan_on_ble_evt() stops getting called after the failed attempt to connect.

I reproduced this behavior using the ble_app_multirole_lesc example with some minor changes.
On the central I commented out the call to ble_advertising_start() so that it only scans.
On the peripheral I removed the scan_start() call so it only advertises and I activated the whitelist which has one entry.

I did put logging in nrf_ble_scan_on_adv_report() so that I can see whenever it gets called. When I run the central code, there is continuous log showing advertising packets from different devices. After a failed attempt to connect, I turn off the peripheral and there is no log output from nrf_ble_scan_on_adv_report() any more on the central.

This is how the log looks like on the central:
<info> ble_scan: B460775CF63C
<info> ble_scan: 775F1B8AEA41
<info> ble_scan: EE8BD6D1ABF4
<info> app: CENTRAL: Connected, handle: 0.
<info> app: CENTRAL: Searching for HRS on conn_handle 0x0
<info> peer_manager_handler: Connection security failed: role: Central, conn_handle: 0x0, procedure: Bonding, error: 4352
<warning> peer_manager_handler: Disconnecting conn_handle 0.
<info> app: CENTRAL: Disconnected, handle: 0, reason: 0x3E
<info> app: Scanning
<info> ble_scan: 44237CE1653F
<info> ble_scan: EE8BD6D1ABF4

Obviously this leads to a problem state where the central can not find any other devices to connect to. Stopping and starting the scan does not help. Only if the same peripheral appears again, the central starts calling nrf_ble_scan_on_adv_report again.

Do you know what could be causing this issue and how to resolve it? Does the SoftDevice get stuck somewhere?

Thanks,
Skara


Parents Reply
  • Hi Skara

    Thanks for sharing the trace. 

    I can't really spot anything problematic there. The central tries to connect three times, and fails each time (because of the whitelist I assume). 

    After the third connection attempt there is no more activity in the trace. Is this because you stopped the trace, or was there no more activity over the air?

    Best regards
    Torbjørn

Children
  • Hi,

    I did not stop the trace but switched the peripheral device off.

    The problem is that at that point the central seems to be stuck somewhere and since the observer never gets called again it can not initiate connections to other devices. The observer only gets called again if I turn the same peripheral back on and it starts advertising again.

    Here are the slightly modified ble_central_and_peripheral projects that I use to reproduce it.


    ble_app_multirole_lesc.tar.gz

    Cheers
    Skara

  • Hi Skara

    What are these other devices that you are trying to connect to?

    Shouldn't they also show up in the sniffer trace, if they are advertising at the same time as the whitelist peripheral?

    I can take a look at your code, but it would be good to know a bit more about the various devices you are using in your test. 

    Best regards
    Torbjørn

  • Hey Torbjørn,

    in my actual application I will have multiple different peripherals to which the central will try to connect to as soon as it sees any of them.

    In this trace I filtered only the packets of the peripheral that the central is trying to connect to. The trace was made in a very noisy environment with more than 20 advertising BLE devices of which only one advertises the filtered UUID.

    As I've written in my initial post, I did add a logging call in the observer function nrf_ble_scan_on_adv_report() which prints the addresses of the peripherals from which packets were received. Before powering on the peripheral, this log is coming continuously showing the addresses of many different devices. After the failed pair/bond and powering off the peripheral no log is to be seen as the observer function is never called again.

    Best
    Skara

  • Hi Skara

    How is the whitelist set in your test?

    I added some logging every time the set_whitelist() function is run, and see that it never finds any peers to add to the list. 

    In my test the two devices will just enter into an infinite connecting-> starting pairing-> timing out on passkey confirmation -> disconnecting -> reconnecting loop. 

    As soon as I turn off the peripheral the scanner proceeds to pick up other advertise packets. 

    Maybe I also need to run one of your other peripherals to reproduce the issue?

    Best regards
    Torbjørn

  • Hi Torbjørn,

    the whitelist is only activated/applied if there are already bonded peers. So before starting the central I used the mobile nrf connect app to bond to the peripheral. Than just restart the peripheral and power the central on and you should be able to reproduce it.

    Thanks
    Skara

Related