Re-enabled auto reconnection in BLE2 data source - seems to be working well after several disconnect-reconnect cycles.

This commit is contained in:
Graham Jones
2024-04-14 19:55:41 +01:00
parent 9e421d51a5
commit db9515cf31
4 changed files with 16 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
OpenSeizureDetector Android App - Change Log
============================================
V4.2.7 - BLE2 data source re-start fixed??
V4.2.6 - Fixed problem with notifications in Android 13
- Improved start-up checks for permissions
- Improved system re-start after changing settings (but still not perfect!)

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="139"
android:versionName="4.2.6">
android:versionCode="140"
android:versionName="4.2.7">
<!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

View File

@@ -186,11 +186,13 @@ public class SdDataSourceBLE2 extends SdDataSource {
@Override
public void onConnectedPeripheral(BluetoothPeripheral peripheral) {
Log.i(TAG,"BluetoothCentralManagerCallback.onConnectedPeripheral()");
mUtil.showToast("Watch Connected");
super.onConnectedPeripheral(peripheral);
}
@Override
public void onConnectionFailed(BluetoothPeripheral peripheral, HciStatus status) {
Log.i(TAG,"BluetoothCentralManagerCallback.onConnectionFailed() - attempting to reconnect");
mUtil.showToast("Failed to Connect to Watch - Retrying");
mBluetoothCentralManager.autoConnectPeripheral(peripheral, peripheralCallback);
super.onConnectionFailed(peripheral, status);
}
@@ -200,10 +202,11 @@ public class SdDataSourceBLE2 extends SdDataSource {
Log.i(TAG,"BluetoothCentralManagerCallback.onDisonnectedPeripheral - mShutdown is set, so not reconnecting");
} else {
Log.i(TAG,"BluetoothCentralManagerCallback.onDisonnectedPeripheral");
//Log.i(TAG, "BluetoothCentralManagerCallback.onDisonnectedPeripheral - attempting to re-connect...");
//bleDisconnect();
//mShutdown=false;
//mBluetoothCentralManager.autoConnectPeripheral(peripheral, peripheralCallback);
mUtil.showToast("WATCH CONNECTION LOST");
Log.i(TAG, "BluetoothCentralManagerCallback.onDisonnectedPeripheral - attempting to re-connect...");
bleDisconnect();
mShutdown=false;
mBluetoothCentralManager.autoConnectPeripheral(peripheral, peripheralCallback);
}
super.onDisconnectedPeripheral(peripheral, status);
}
@@ -534,8 +537,8 @@ public class SdDataSourceBLE2 extends SdDataSource {
mShutdown = true;
mBlePeripheral.cancelConnection();
Log.i(TAG, "bleDisconnect() - closing BluetoothCentralManager");
mBluetoothCentralManager.close();
//Log.i(TAG, "bleDisconnect() - closing BluetoothCentralManager");
//mBluetoothCentralManager.close();
} catch (Exception e) {
Log.e(TAG,"bleDisconnect() - Error: "+e.getMessage());
mUtil.showToast("Error disconnecting from watch");
@@ -551,6 +554,7 @@ public class SdDataSourceBLE2 extends SdDataSource {
super.stop();
try {
mShutdown = true;
bleDisconnect();
CurrentTimeService.stopServer();
} catch (Exception e) {

View File

@@ -2,7 +2,9 @@
<resources>
<string name="app_name">OpenSeizureDetector</string>
<string name="changelog">
"\nV4.2.6 - Fixed issues with Android 13 notifications and BLE data source shutdown. Added support for V2.x of Garmin watch app, Added new BLE2 data source, signal strength and battery level graphs.
"\n
\nV4.2.7 - Finally fixed BLE2 data source re-start after dropping connection?
\nV4.2.6 - Fixed issues with Android 13 notifications and BLE data source shutdown. Added support for V2.x of Garmin watch app, Added new BLE2 data source, signal strength and battery level graphs.
\nV4.2.4 - Fault alarm rather than crash if bluetooth system crashes.
\nV4.2.3 - Bug Fixes (heart rate alarm and latched alarm issues)
\nV4.2 - Added support for PineTime Watches using Bluetooth data source.