Trouble Reconnecting Peripherals after Disconnection.

Hi,

We are developing a new project using the nRF52832 as our controller and nRF5 SDK 17.0.2 as our SDK.

We have integrated the NUS client and NUS peripheral parts from the ble_app_uart_c and ble_app_uart example projects. We've checked the functionality and it works well in the first stage. That is, the device can scan for nearby advertised devices based on the NUS service and connect to them. After the connection, the device acts as a peripheral and can connect with the nRF Connect app, sending and receiving data to and from the app through the connected device. Essentially, the device acts as a gateway between the app and connected peripherals.

Initially, there was no issue with the BLE connection. However, after disconnecting the nearby advertised peripherals, we are unable to connect to the two peripherals again. We can only connect to the same peripheral. What could be the issue?

Device (gateway acting as central and peripheral): NUS client and NUS peripheral integrated ble_app_hrs_rscs_relay example code flashed board . Connected peripheral: Modified NUS client and NUS peripheral integrated ble_app_hrs_rscs_relay example code flashed board , capable of capturing nearby beacon data and sending it to the connected gateway.

When we initially flash the code, we can connect the gateway to two nearby peripherals. However, when a peripheral disconnects, we can't connect to that two peripheral again.but we can connect only one same peripherl . The log output shows this:

SCAN START

12:13:07.819 -> <info> app: Connected to target F0C798AA5E92

12:13:07.819 -> <info> app: Central connected

12:13:07.819 -> <info> app: Attempt to find HRS, RSC, or NUS conn_handle 0x0

12:13:07.819 -> <info> app: NUS client assigned to conn_handle 0x0 (index: 0)

12:13:07.866 -> <info> app: nrf_ble_scan_start : 0
12:13:07.866 -> 

12:13:07.866 -> <info> app: SCAN START

12:13:08.287 -> <info> app: ATT MTU exchange completed.

12:13:08.334 -> <info> app: Ble NUS max data length set to 0xF4(244)

12:13:08.334 -> <info> peer_manager_handler: Connection security failed: role: Central, conn_handle: 0x0, procedure: Bonding, error: 133

12:13:08.334 -> <warning> peer_manager_handler: Disconnecting conn_handle 0.

12:13:08.475 -> <error> nrf_ble_gq: SD GATT procedure (3) failed on connection handle 0 with error: 0x00000008.

12:13:08.475 -> <info> app: DB Discovery instance 0x2000477C available on conn handle: 0

12:13:08.522 -> <info> app: Found 1 services on conn_handle: 0

12:13:08.522 -> <info> app: current instance index 0
12:13:08.522 -> 

12:13:08.522 -> <info> app: Disconnected from instance 0

12:13:08.522 -> <info> app: nrf_ble_scan_start : 0
12:13:08.522 -> 

12:13:08.522 -> <info> app: SCAN START

12:13:08.522 -> <info> app: Device disconnected, conn_handle: 0x0, reason: 0x16

12:13:08.522 -> <info> app: nrf_ble_scan_start : 0
12:13:08.522 -> 

12:13:08.522 -> <info> app: SCAN START

12:13:09.646 -> <info> app: Connected to target F0C798AA5E92

12:13:09.646 -> <info> app: Central connected

12:13:09.646 -> <info> app: Attempt to find HRS, RSC, or NUS conn_handle 0x0

12:13:09.646 -> <info> app: NUS client assigned to conn_handle 0x0 (index: 0)

12:13:09.646 -> <info> app: nrf_ble_scan_start : 0
12:13:09.646 -> 

12:13:09.646 -> <info> app: SCAN START

12:13:10.256 -> <info> app: ATT MTU exchange completed.

12:13:10.303 -> <info> app: Ble NUS max data length set to 0xF4(244)

12:13:10.443 -> <info> peer_manager_handler: Connection security failed: role: Central, conn_handle: 0x0, procedure: Bonding, error: 133

12:13:10.490 -> <warning> peer_manager_handler: Disconnecting conn_handle 0.

12:13:10.678 -> <error> nrf_ble_gq: SD GATT procedure (3) failed on connection handle 0 with error: 0x00000008.

12:13:10.678 -> <info> app: DB Discovery instance 0x2000477C available on conn handle: 0

12:13:10.678 -> <info> app: Found 1 services on conn_handle: 0

12:13:10.678 -> <info> app: current instance index 0
12:13:10.678 -> 

12:13:10.678 -> <info> app: Disconnected from instance 0

kindly Please provide your response as soon as possible. Your valuable input is urgently needed. 

  •  , ,I modified the following parameters:

    • Central Link Count:

      // <o> NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links.
      #ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT
      #define NRF_SDH_BLE_CENTRAL_LINK_COUNT 10
      #endif
      
    • Peripheral Link Count:

      // <o> NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links.
      #ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT
      #define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1
      #endif
      
    • Total Link Count:

      // <o> NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count.
      // <i> Maximum number of total concurrent connections using the default configuration.
      #ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT
      #define NRF_SDH_BLE_TOTAL_LINK_COUNT 11
      #endif
      
    • RAM Starting Address: 0x2000B198

    After these changes, I observed the following behavior:

    1. When Device 1 and Device 2 are connected, disconnecting Device 2 results in the following log output:

      11:03:06.626 -> <info> app: SCAN START
      11:03:06.626 -> <info> app: Device disconnected, conn_handle: 0x0, reason: 0x8
      11:03:06.626 -> <info> app: Erase bonds!
      11:03:06.626 -> <info> app: ENTER PM EVENT HANDLER: evt_id=12
      11:03:06.626 -> <info> peer_manager_handler: All peers deleted.
      11:03:06.626 -> <info> app: nrf_ble_scan_start : 0
      11:03:06.626 -> 
      11:03:06.626 -> <info> app: SCAN START
      11:03:06.626 -> <error> app: Fatal error
      11:03:06.626 -> <warning> app: System reset 
      
    2. Following the system reset, the gateway attempts to connect to two nearby available peripherals.

    I'm seeking assistance in understanding the root cause of this "Fatal error" and subsequent system reset . 

  • Hi, 
    If you want to see what cause the error, switch the project from Release to Debug. 

    If you don't have that option you can try adding DEBUG to preprocessor symbols. 

    Please try to test without bonding/security from what you provided it seems bonding was still used ? 
    evt_id=5 = PM_EVT_CONN_SEC_CONFIG_REQ. 

Related