This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Central device claims to have Connected but no Connection event is fired on the peripheral

I'm developing a multirole device to connect to a peripheral device that we developed earlier.

The multirole device when acting as a central device it scans for the peripheral and if found it connects, then secure the connection and bond. After several successful connections, the central says that it connects to the peripheral but before being able to secure the connection or to discovery the services it disconnects.

I've enabled the logger on both devices and added logs to see the progress of the connection and the events.

I've seen that when the problem happens, the central is showing me the BLE_GAP_EVT_CONNECTED but the peripheral doesn't show anything. it's like the central device is firing a false BLE_GAP_EVT_CONNECTED event.

I've tried with the scan_params.extended on and off and the behavior is the same.

I've confirmed that when connected from another central that works fine (using the phone with the nrfConnect application), the peripheral shows the events as expected.

Both devices are using the nrf52832

The peripheral is using the SDK 15.0.0 and the softdevice s132 6.0.0

The device acting as a central is using the SDK 16.0.0 and the softdevice s132 7.0.1

  • I first thought that it was related with this issue:

    https://devzone.nordicsemi.com/f/nordic-q-a/42384/connection-security-failed-role-central-in-ble_app_rscs_c/229637#229637

    However I now believe it's the other way around, that issue may be caused by this odd behavior

  • Deleting the bonds seems to solve the issue, therefore I believe it's something related to the flash storage?

  • You are not writing anything about how frequently this occurs , but it is possible that the connection request packet from the central to the peripheral from time to time is lost (e.g. due to interference). In such case the central will first get an BLE_GAP_EVT_CONNECTED event, then shortly after get an BLE_GAP_EVT_DISCONNECTED event with disconnect reason BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED. 

    Best regards,
    Kenneth

  • Hello Kenneth, as I say before, the connection works fine for a while, I can turn off, turn on, disconnect, reconnect several times, then suddenly, it stops working, no more connection to that particular peripheral, I don't believe it's something regarding interference, both devices are close, is not like it sometimes connects and sometimes it fail, when the issue happens, it never connect again. However, without moving anything, just deleting bonds or doing a mass erase it starts working again. 

    I'm going to try to sniff the packets to check if there's something wrong that I'm not seeing in the logs, however I need to get the nrf52 DK or the dongle to do it.

    Summarizing:

    1. After a fresh mass erase or a delete bonds, everything works fine, it always find the peripheral, connect, bonds, reconnects if disconnected, you can power off and on several times and everything works

    2. Suddenly the peripheral doesn't connect anymore, the Central is able to see the advertising packets from the peripheral, however as soon as the central tries to connect, the BLE_GAP_EVT_CONNECTED is received in the Central device but the peripheral doesn't receive anything, shortly after the central disconnects

    3. The peripheral is connectable through another central

    4. Scanning and connecting for another peripheral works fine (creating and using a new bond and a new peer entry)

    5. Deleting all bonds on the central and allowing the peripheral to refresh the bond information fix the connection issues

    6. Repeat from step 1

    I haven't count how many times the connection works before getting the issue, however I'm sure that it's more than at least 10 times, but probably a lot more.

  • It sounds very much like that you have some whitelist enabled/active on the peripheral, and if for instance the peripheral is bonded with >8 devices, then it is not able to include the "older" centrals in the whitelist. Hence the "old" central will not be able to connect.

    It may also be because the central have deleted or erased it's bond data, in such case you need to allow re-pairing from the peripheral by adding the following code on the peripheral:

    https://devzone.nordicsemi.com/f/nordic-q-a/37837/sdk15-paring-problem/145821#145821 

    I assume you are not altering the GAP address on the central or peripheral here.

Related