Skip to content

Commit

Permalink
Removed unwanted retrieve services on connect
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosinigaglia authored and Ville Hakulinen committed Jan 21, 2025
1 parent d90b83b commit 92e05c5
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions android/src/main/java/it/innove/Peripheral.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public class Peripheral extends BluetoothGattCallback {

private final Queue<Runnable> commandQueue = new ConcurrentLinkedQueue<>();
private final Handler mainHandler = new Handler(Looper.getMainLooper());
private Runnable discoverServicesRunnable;
private boolean commandQueueBusy = false;

private List<byte[]> writeQueue = new ArrayList<>();
Expand Down Expand Up @@ -320,21 +319,6 @@ public void onConnectionStateChange(BluetoothGatt gatta, int status, final int n
if (newState == BluetoothProfile.STATE_CONNECTED && status == BluetoothGatt.GATT_SUCCESS) {
connected = true;

discoverServicesRunnable = new Runnable() {
@Override
public void run() {
try {
gatt.discoverServices();
} catch (NullPointerException e) {
Log.d(BleManager.LOG_TAG,
"onConnectionStateChange connected but gatt of Run method was null");
}
discoverServicesRunnable = null;
}
};

mainHandler.post(discoverServicesRunnable);

sendConnectionEvent(device, "BleManagerConnectPeripheral", status);

Log.d(BleManager.LOG_TAG, "Connected to: " + device.getAddress());
Expand All @@ -345,11 +329,6 @@ public void run() {

} else if (newState == BluetoothProfile.STATE_DISCONNECTED || status != BluetoothGatt.GATT_SUCCESS) {

if (discoverServicesRunnable != null) {
mainHandler.removeCallbacks(discoverServicesRunnable);
discoverServicesRunnable = null;
}

for (Callback writeCallback : writeCallbacks) {
writeCallback.invoke("Device disconnected");
}
Expand Down Expand Up @@ -400,8 +379,6 @@ public void run() {
commandQueueBusy = false;
connected = false;
clearBuffers();
commandQueue.clear();
commandQueueBusy = false;

gatt.disconnect();
gatt.close();
Expand Down

0 comments on commit 92e05c5

Please sign in to comment.