Cannot get read/notify when connected to more than two devices.



  • When connected to two devices, I'm able to read and get notify no problem. As soon as I connect a third device, I no longer get anymore reads or notifies.

    Is this something in device config ore ble manager config I need to do to be able to handle this?



  • There's nothing in SweetBlue preventing you from using multiple devices. There are multiple factors which can affect how many simultaneous connections you can have. Older versions of android only allowed about 3 or 4 devices, whereas newer ones will allow anywhere from 7-15 (to get above 7 or 8, it will require Bluetooth 5).
    Also, the device manufacturer could have imposed their own limits in their bluetooth implementation.

    Have you tried the SweetBlue Toolbox app? Try connecting in that app and see how many you can get connected at once, and still receive reads. This will at least rule out implementation errors.



  • Thanks for getting back with me.

    It appears I get the same results using the Toolbox app, but did notice something interesting. My flow using Toolbox app after having connected to two devices

    1. Turn device 1 on. Wait for button to turn green and say "Disconnect". Usually takes about 5-10 seconds
    2. I'm able to get notify values
    3. Turn device off. Wait for button to turn white and say "Connect"

    =========

    1. Turn device 2 on. Wait for button to turn green and say "Disconnect". Usually takes about 5-10 seconds.
    2. I'm able to get notify values
    3. Turn device off. Wait for button to turn white and say "Connect"

    This is pretty consistent. I can do this multiple times with the same result, but sometimes when I turn a device on, it's button will not turn green even after waiting for over a minute. But as soon as I turn on another device (two devices are now on), both devices will connect and buttons will turn green.

    When a third device is added, the only way I can get a device to connect and turn green, is to turn on another device too.

    This is pretty consistent with results I'm seeing with Sweetblue in our app. We try to connect to devices use a ReconnectFilter

     val deviceReconnectFilter = object : DeviceReconnectFilter {
                override fun onConnectFailed(connectFailEvent: DeviceReconnectFilter.ConnectFailEvent): ConnectFailPlease {
                    return ConnectFailPlease.retry()
                }
    
                override fun onConnectionLost(connectionLostEvent: ConnectionLostEvent): ConnectionLostPlease {
                    return ConnectionLostPlease.retryIn(Interval.secs(3.0) )
                }
            }
    

    So our app is continuously trying to connect to devices it knows about. When device is turned on ConnectionEvent is triggered and we start getting data. When the device is turned off, onConnectionLost is fired and we start continuously trying to reconnect.

    Is there another way we should be trying to handle continuously being connected to a device?