I apologize for the title of the post, the same as many others without a response, but I put it in a somewhat different context.
My application keeps four BLE devices connected simultaneously (four BluetoothLE instances).
The code for connecting to the four devices is executed in a sequence. When each device got connected, the callback for bytes received is registered for a characteristic.
I'm highly concerned because I'm not able to reproduce the error.
Several tests disconnecting and reconnecting to all devices result without problems. Simultaneous data readings from all four devices also occur without problems.
When only a single device is connected, any of them, it has never happened.
Other information. When the error appears, the connection to the problem device, whatever it may be, remains active, but subsequent data readings produce the same error.
Any suggestions or previous experience on this issue?
Should I establish the connections waiting for the previous one to happen?
In theory this should be fine as the Connected event only occurs once all of the services and characteristics are discovered. Generally, this error indicates that Android has cached a set of UUIDs different than what you are expecting. Sometimes this can be resolved by turning the Bluetooth off and on in your system settings.
My app settings allows users to select four specific devices (internally MAC address) that are within BLE field. And they can change the order of the four selected ones. So, each instance of BluetoothLE possibly reconnects to a different device, depending on the user's choice.
So it is possible that something is happening in the android bluetooth stack like what you mention. I will try to turn it off and on when the error appears again.
Turning OFF/ON bluetooth after error shows up does not restore to a correct state.
I immediately run nRF Connect app and the issue persists, it connects to problematic device but then immediately disconnects (I will check the code of the esp32 device carefully).
I changed the connection sequence by delegating each connection until the previous device got connected, in order to not launching two simultaneous connections, but the problem persists the same way.
I compiled the app and when started it connects to all devices well, the error has not occurred, yet. I have already done a few tests.
Other changes made previously without result in ble peripheral device (ESP32) code
-two published services were mixed and advertised as a single UUID
-the tuning of the connection parameters was disabled, the default values โโof the central device (mobile) remained.