Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Bluetooth LE: Code=6 "The connection has timed out unexpectedly."

I have a BLE peripheral device (for which I control the firmware) and two mobile apps acting as centrals, one on Android, the other on iOS 8.1.

The Android app works fine. The iOS does not. It will spontaneously disconnect some time after connection. The error is:

Code=6 "The connection has timed out unexpectedly."

The time between connection and this disconnection is random. I've measured from 40s to 4m30s.

All the peripheral device is doing with the BLE connection is writing some firmware logging messages to the mobile app UI. Just a few writes to that one characteristic in quick succession every few minutes. There is no error in the peripheral device firmware.

How do I find the cause of the disconnection?

like image 273
Eliot Avatar asked Sep 15 '15 14:09

Eliot


2 Answers

After some extensive support from Nordic Semiconductor, the manufacturer of the BLE module on the peripheral, we're pretty sure the cause of this is an inaccurate clock on the iPhone 5C BLE module. That is, it's less accurate than stated in the connection request. Here's my question on the Nordic forums:

https://devzone.nordicsemi.com/question/51258/ios-8-disconnection-code6-the-connection-has-timed-out-unexpectedly/

like image 87
Eliot Avatar answered Oct 09 '22 00:10

Eliot


So I was facing this problem with Microchip BM78 Bluetooth module talking with iOS. I found this tech note which was very helpful: https://developer.apple.com/library/archive/qa/qa1931/_index.html

These settings are flashed onto the BM78 module. Here are the Apple 'rules' from the above tech note:

  • Interval Min ≥ 15 ms (multiples of 15 ms)
  • Interval Min + 15 ms ≤ Interval Max (Interval Max == 15 ms is allowed)
  • Interval Max * (Slave Latency + 1) ≤ 2 seconds
  • Interval Max * (Slave Latency + 1) * 3 < connSupervisionTimeout
  • Slave Latency ≤ 30
  • 2 seconds ≤ connSupervisionTimeout ≤ 6 seconds

My values (working well):

  • Interval Min = 15ms
  • Interval Max = 30ms
  • Slave Latency = 4
  • Connection Supervision Timeout =~ 5 seconds
like image 2
Jim Holland Avatar answered Oct 09 '22 00:10

Jim Holland