I am developping a Android app that connects to multiple BLE devices at the same time, after that i read characteristic permanently from those devices but after a while, I am getting a status 257 in the onConnectionStateChanged() function, the android documentation doesn't explain what is the reason of the error, or how to fix it.
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
Log.i("TAG","onConnectionStateChange, status : "+status+" parseConnection : "+ GattStatusParse.parseConnection(status)+" or "+ GattStatusParse.parseConnection(status));
isConnected = BluetoothProfile.STATE_CONNECTED == newState;
if (status == BluetoothGatt.GATT_SUCCESS) {
if (isConnected) {
Log.i(TAG, "GATT connected." + connectedBluethoothDevice.toString());
gatt.discoverServices();
} else {
Log.i("TAG"," GATT disconnected " + device.getAddress() + " state of the opération : " + status + " connexion state : " + newState);
if (connectedBluethoothDevice.contains(device)) {
connectedBluethoothDevice.remove(device);
}
}else{
if (connectedBluethoothDevice.contains(device)) {
int mConnectionState = mBluetoothManager.getConnectionState(device, BluetoothProfile.GATT);
if(mConnectionState==BluetoothProfile.STATE_DISCONNECTED || mConnectionState==BluetoothProfile.STATE_DISCONNECTING){
connectedBluethoothDevice.remove(device);
}
}
}
}
could anyone help me to fix this problem, thanks.