Skip to content

Commit

Permalink
chore: add constant for error code 133
Browse files Browse the repository at this point in the history
  • Loading branch information
j0tunn committed Oct 24, 2024
1 parent e730a88 commit 1b57f24
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/platform/android/java/chip/platform/AndroidBleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ class ConnectionGattCallback extends AndroidBluetoothGattCallback {
private static final int STATE_DISCOVER_SERVICE = 2;
private static final int STATE_REQUEST_MTU = 3;

/// Unfortunately GATT 133 is very generic, however among other things
/// it may also show up on device out of range or BLE being closed due to
/// background task termination, hence it is a candidate to retry connectivity.
private static final int kGattRetryableErrorStatus = 133;

private int mState = STATE_INIT;
private BluetoothDevice mDevice;
private int connectRetriesLeft = 3;
Expand All @@ -612,10 +617,9 @@ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState
}

if (newState == BluetoothProfile.STATE_DISCONNECTED
&& status == 133
&& status == kGattRetryableErrorStatus
&& connectRetriesLeft-- > 0) {
Log.i(TAG, "GATT_ERROR 133. Retrying connect...");
Log.i(TAG, "Retries left: " + connectRetriesLeft);
Log.i(TAG, "Retries left: " + connectRetriesLeft + ". Retrying connect...");

gatt.close();

Expand Down

0 comments on commit 1b57f24

Please sign in to comment.