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

Android BLE issues on parallel (5+) connection establishments

We need to establish connections to muliple of our products (they use nRF52832/nRF52840) parallel from our Android/iOS apps to send commands which are time critical (in relation between the devices).

This works fine from our iOS app.

On Android side we've been trying to implement this parallel connections (instead of serial connections, which we used before and which work fine on Android) for a while now and it seems like the Android Bluetooth stack is getting unreliable from time to time (we use tests which connect/disconnect to the devices in a loop) when we connect to multiple (~ more than 5) devices at the same time.
Unreliable means: We getting various errors and there seems to be no pattern when/at which device these errors happen. 

The errors happen nearly at every part of the connection process

- the well know generic GATT_ERROR (133) in the onConnectionStateChange() callback

- errors in the onMtuChanged() callback

- sometimes our services are not discovered correctly

- sometimes we get no responses on the writes to our characteristics

We use work arounds (like close the connection and reconnect) but from time to time we still run in issues which are not predictable and hard to debug.

I know, there is no way to "debug" this without code here. My question is:

Does anyone has experiences with such a parallel connection process on Android?
If so, can you confirm that the Android BLE stack reacts unreliable or is it working for you. If the latter, we would spend more time in the debugging, else we could stop the investigation and just use the serial connection method like before.

Thank you for your time!

  • Hi 

    According to this thread there is a hard limit of 7 connections in Android, but different phones might have different capabilities, and might be limited to less than 7 connections also. 

    Have you tested this on different Android phones, or just a single one?

    I can check next week if our Android developers have some practical experience with this, but in general it is rare to develop mobile applications that rely on a high number of connected devices. 
    Because phones have to schedule many different 2.4GHz based protocols, such as BLE, classic Bluetooth and WiFi, it is usually limited how many connections and how high throughput you get, compared to the performance of an nRF52 device running the SoftDevice. 

    Best regards
    Torbjørn

  • Hi Torbjørn,

    thank you for your response!

    I get your point about the frequently used 2.4GHz band. We could totally live with connection delays/bad bandwidth etc. if we would get reliable error-codes/infos from the Android Bluetooth stack. But these "random" and unpredictable errors I described above are kind of "gamling" in a production environment.

    We've tested with different Android devices (Google Pixel, LG, Samsung) and most of the time with 6 devices. So the hard limit of 7 devices /thanks for the linkto the thread)  should not apply in this cases, unless the Android Gatt cache is not cleaned up properly in time. We definitly call gatt.close() on every disconnect, so the cache SHOULD be cleaned up properly.

    I would love to here from you after you had a chat with your Android engineers! I know it's a rare usecase.

    Maybe we could build a test app with the Blinky app as counterpart .So we could reduce the issue to it's core without any vendor specific stuff. I will discuss this with my colleagues.

    Best regards
    Niklas

    • Im Wörterbuch speichern
      • Keine Wortliste für Englisch → Deutsch...
      • Eine neue Wortliste erstellen...
    • Kopieren
    • Im Wörterbuch speichern
      • Keine Wortliste für Englisch → Deutsch...
      • Eine neue Wortliste erstellen...
    • Kopieren
    • Im Wörterbuch speichern
      • Keine Wortliste für Englisch → Deutsch...
      • Eine neue Wortliste erstellen...
    • Kopieren
    • Im Wörterbuch speichern
      • Keine Wortliste für Englisch → Deutsch...
      • Eine neue Wortliste erstellen...
    • Kopieren
    • Im Wörterbuch speichern
      • Keine Wortliste für Englisch → Deutsch...
      • Eine neue Wortliste erstellen...
    • Kopieren
  • Hi Niklas

    Unfortunately it seems both our Android developers are on summer leave until August Disappointed

    I am afraid it will be limited how much we can look into this until they are back, since July is already a very hectic time in support. 

    I have one question though: On the devices where you see stability issues, are you able to solve these issues by removing one of the links?
    In other words, if 6 link is unstable, will 5 links be stable?

    Best regards
    Torbjørn

  • Hi, I know that this is an old question, but I'm having a similar issue with 5 parallel connection when performing DFU via BLE on Android/iOS. Connection initialization is failing for some devices with GATT_ERROR (133). When I performed one by one or 2-3 in parallel, it is ok.

    Do you have some solution to avoid this?

    I have plan to try synchronize the connection process, but didn't tried yet. 

    Thank you

Related