Skip to content

Commit 6790dc6

Browse files
committed
Restore point for changes to BT/BLE device connection code -- Remedy long service discovery times -- Testing VI
1 parent 41b8595 commit 6790dc6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/src/main/java/com/maxieds/chameleonminilivedebugger/BluetoothBroadcastReceiver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public BluetoothBroadcastReceiver() {
5858
btGattConn = null;
5959
}
6060

61-
private static final boolean PRINT_SERVICES_LIST_TO_LOG = false;
61+
private static final boolean PRINT_SERVICES_LIST_TO_LOG = true;
6262
private static final boolean PRINT_SERVICES_LIST_FULL = false;
6363

6464
public static void printServicesSummaryListToLog(BluetoothGatt btGatt) {
@@ -93,7 +93,7 @@ public static void printServicesSummaryListToLog(BluetoothGatt btGatt) {
9393
}
9494

9595
public static final int DISCOVER_SVCS_ATTEMPT_COUNT = 10;
96-
public static final long CHECK_DISCOVER_SVCS_INTERVAL = 60000L;
96+
public static final long CHECK_DISCOVER_SVCS_INTERVAL = 7500L;
9797

9898
@SuppressLint("MissingPermission")
9999
public void onReceive(Context context, Intent intent) {

app/src/main/java/com/maxieds/chameleonminilivedebugger/BluetoothGattConnector.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This program (The Chameleon Mini Live Debugger) is free software written by
3434
import android.os.Handler;
3535
import android.os.Looper;
3636
import android.os.ParcelUuid;
37+
import android.widget.Toast;
3738

3839
import androidx.annotation.NonNull;
3940

@@ -589,11 +590,14 @@ public void run() {
589590
disconnectDevice();
590591
stopConnectingDevices();
591592
startConnectingDevices();
593+
} else if (!btGattRef.discoverServices()) {
594+
Utils.displayToastMessage("Discovering bluetooth services. Prepare to wait ...", Toast.LENGTH_LONG);
595+
discoverServicesHandler.postDelayed(this, BluetoothBroadcastReceiver.CHECK_DISCOVER_SVCS_INTERVAL);
592596
} else if (configureGattConnector()) {
593597
BluetoothBroadcastReceiver.printServicesSummaryListToLog(btGattRef);
594598
notifyBluetoothBLEDeviceConnected();
595599
} else {
596-
btGattRef.discoverServices();
600+
Utils.displayToastMessage("Discovering bluetooth services. Prepare to wait ...", Toast.LENGTH_LONG);
597601
discoverServicesHandler.postDelayed(this, BluetoothBroadcastReceiver.CHECK_DISCOVER_SVCS_INTERVAL);
598602
}
599603
}

0 commit comments

Comments
 (0)