This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Unstable BLE connection in Android

Other Parts Discussed in Thread: CC2540

Hi all! We are developing an Android BLE application, using CC2540, but we have some issues with Android 6: It scans, it connects and sends and receives packets well, but it isn't stable for long time, specially when we repeat a operation periodically like read RSSI value every 1000ms; Android bluetooth device will crash and reset after a while.

I read https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/t/457958 , but we are testing on android 6.0.1 and using 1.4.0. Even we update our BLE Stack to 1.4.1, but it didn't fixed.

Have somebody any idea?! Thanks.

  • Can you attach sniffer log?
  • Hi Christin! I attached my Sniffer output, the issue happened at around packet number 7838. Thanks for your helping...

    5557.sniff_data.psd

  • Hi,

    There is not enough information in the log to see why the connection drops. What you can do is to extract the disconnect reason from application layer.

    Under function static void gapRole_ProcessGAPMsg( gapEventHdr_t *pMsg ) in peripheral.c, go to case GAP_LINK_TERMINATED_EVENT.

    You can extract the termination reason by doing         gapRole_ConnTermReason = pPkt->reason;  Then update the advertising data with the termination reason.

  • OK, it is Connection Timeout, that I was expected to, because it is phone chip that crashes and resets, so connections don't be closed normally and Timeout will occur in dongle.
    I searched and tried everything in both side (Android 6.0.1 application and CC2540 USB dongle) without success. I think a conflict occur between them.
    A note: When I do my periodical operation (like read RSSI continuously) with lower interval like 100ms; Everythink is OK (at least for few hours),
    But when try with 1000ms; Everything will drop after few seconds!!!
    Another note: Our application works well in older Androids (4.3 ~ 5.1).

    Thanks again...

  • Hi,

    I assume you meant supervision timeout.

    Which phone are you using? When you perform your periodic task, do you read it during connection event or just using a SW clock to wake up periodically?

    Is it possible for you to get error msg from the phone side? The BLE chip in the phone plays significant role and not all the android phones use the same BLE chip vendor. What we can do here is really limited if it's the phone crashed unfortunately.
  • Hi Christin, 

    Yes, I meant supervision timeout, I use Samsung Galaxy S6 and I perform my periodic task using threads (tried TimerTask, PostHandler or other mechanisms). I don't see any connection event callback in Android BLE API! It do operations itself during [next] connection events.

    Also in my device logcat, I see just resetting of Bluetooth Services, and sometimes In addition to "Binder Transaction Failed" errors.

    OK, I think I must focus on Android side again, too! Anyway thanks a lot!