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:
- Connection interval (MIN_CONN_INTERVAL and MAX_CONN_INTERVAL respectively) must be between 7.5 ms to 4 seconds
- 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:
- Interval Max * (Slave Latency + 1) ≤ 2 seconds
- Interval Min ≥ 20 ms
- Interval Min + 20 ms ≤ Interval Max Slave Latency ≤ 4 (What is 4 here ???)
- connSupervisionTimeout ≤ 6 seconds
- Interval Max * (Slave Latency + 1) * 3 < connSupervisionTimeout
Please let me know, how to debug and fix this issue further.