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

BLE disconnect

I'm observing frequent Bluetooth disconnection on my custom board which has nRF51822 SoC. So far, I haven't been able to figure out the root cause. In order to narrow down the issue, I'm using the ble_app_template example from the SDK, with very litle modifications (since the example template is for NRF51422, therefore, I had to make few changes in the KEIL Toolchain and some chanegs for clock source and button support package).

Steps to reproduce:

  • Erase entire chip.
  • Program Softdevice.
  • Observe that the device is advertising.
  • Connect using MCP app running on Smartphone.
  • Connection established, read services.
  • Perform Bond (In my opinion, it does not matter here)
  • Leave the peripheral and the central in IDLE (Observe that Empty PDUs are being exchanged)

Result:

  • Disconnect after sometime (Control opcode: LL_TERMINATE_IND from my peripheral - > Smartphone)
  • Disconnect reason: BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION (0x16)

Refer the attached Sniffer capture screenshot.

Environment:

  • SoC: NRF51822QFAA, IC revision 3
  • Softdevice: S110, v8.0
  • SDK: v10.0.0
  • Clock source: NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION (No external clock)
  • Central: Nordic MCP (v4.1.3) Android (v4.3) application running on Samsung S3 Smartphone

GAP connection parameters

MIN_CONN_INTERVAL   MSEC_TO_UNITS(100, UNIT_1_25_MS)
MAX_CONN_INTERVAL   MSEC_TO_UNITS(200, UNIT_1_25_MS)
SLAVE_LATENCY       8
CONN_SUP_TIMEOUT    MSEC_TO_UNITS(6000, UNIT_10_MS)

Please correct me if I'm wrong; my understanding with the above values is that:

minimum connection interval = 100 ms

maximum connection interval = 200 ms

slave latency (number of connection events that the slave can safely skip) = 8

connection supervisor timeout (max time period, before a link is finally considered lost) = 6000 ms

The reason, I picked these values to satisfy:

  1. Connection interval (MIN_CONN_INTERVAL and MAX_CONN_INTERVAL respectively) must be between 7.5 ms to 4 seconds
  2. conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval, i.e. (6000 ms * 4) > (1 + 8) * 200 ms => 24000 ms > 1800 ms

As, I'd like to be able to connect to my peripheral (custom board) with iOS based devices as well, I referred the Apple's recommended BLE Connection parameters and those connection settings also satisfy Apple's guidelines. Snip from section 3.6 of this document:

  1. Interval Max * (Slave Latency + 1) ≤ 2 seconds
  2. Interval Min ≥ 20 ms
  3. Interval Min + 20 ms ≤ Interval Max Slave Latency ≤ 4 (What is 4 here ???)
  4. connSupervisionTimeout ≤ 6 seconds
  5. Interval Max * (Slave Latency + 1) * 3 < connSupervisionTimeout

Please let me know, how to debug and fix this issue further.

Parents
  • FormerMember
    0 FormerMember

    I would recommend you to do the following:

    Set a breakpoint on all sd_ble_gap_disconnect() calls in your application. When your peripheral device wants to disconnect, it will then stop there. From there, you can start "going backwards" and try to track down the root cause for the disconnect.

  • Hi @sidekick, I had a similar kind of doubt regarding the connection interval time for BLE Nordic UART Service on nrf52840 microcontroller with softdevice s140. I want to know after connecting with a nordic mobile app, can the connection remain idle for longer time. If I keep the connection idle it disconnects after certain time The solution you mentioned of replacing "sd_ble_gap_disconnect" with "sd_ble_gap_ppcp_set" in connection parameter event handler, so "sd_ble_gap_ppcp_set" accepts connection parameters as input do I need to initialize the gap connection parameters in event handler again?

Reply
  • Hi @sidekick, I had a similar kind of doubt regarding the connection interval time for BLE Nordic UART Service on nrf52840 microcontroller with softdevice s140. I want to know after connecting with a nordic mobile app, can the connection remain idle for longer time. If I keep the connection idle it disconnects after certain time The solution you mentioned of replacing "sd_ble_gap_disconnect" with "sd_ble_gap_ppcp_set" in connection parameter event handler, so "sd_ble_gap_ppcp_set" accepts connection parameters as input do I need to initialize the gap connection parameters in event handler again?

Children
Related