fix(pairing): pairing flow preempt status read fix
This commit is contained in:
@ -51,6 +51,11 @@ class _DeviceDetailsPageState extends ConsumerState<DeviceDetailsPage> {
|
|||||||
2.77,
|
2.77,
|
||||||
3.27,
|
3.27,
|
||||||
];
|
];
|
||||||
|
static const List<Duration> _initialStatusRetryDelays = [
|
||||||
|
Duration(milliseconds: 500),
|
||||||
|
Duration(milliseconds: 1500),
|
||||||
|
Duration(seconds: 3),
|
||||||
|
];
|
||||||
|
|
||||||
bool _isExitingPage = false;
|
bool _isExitingPage = false;
|
||||||
bool _hasRequestedDisconnect = false;
|
bool _hasRequestedDisconnect = false;
|
||||||
@ -218,7 +223,24 @@ class _DeviceDetailsPageState extends ConsumerState<DeviceDetailsPage> {
|
|||||||
buttonDeviceId: widget.deviceAddress,
|
buttonDeviceId: widget.deviceAddress,
|
||||||
);
|
);
|
||||||
|
|
||||||
final initialStatusResult = await service.readStatus();
|
var initialStatusResult = await service.readStatus();
|
||||||
|
for (final delay in _initialStatusRetryDelays) {
|
||||||
|
if (initialStatusResult.isOk() || !mounted) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Future<void>.delayed(delay);
|
||||||
|
if (!mounted) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
final bluetooth = ref.read(bluetoothProvider).value;
|
||||||
|
if (bluetooth == null || !isCurrentDeviceConnected(bluetooth)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
initialStatusResult = await service.readStatus();
|
||||||
|
}
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
await service.dispose();
|
await service.dispose();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:abawo_bt_app/controller/bluetooth.dart';
|
import 'package:abawo_bt_app/controller/bluetooth.dart';
|
||||||
import 'package:abawo_bt_app/database/database.dart';
|
import 'package:abawo_bt_app/database/database.dart';
|
||||||
import 'package:abawo_bt_app/model/bluetooth_device_model.dart';
|
import 'package:abawo_bt_app/model/bluetooth_device_model.dart';
|
||||||
@ -92,14 +90,6 @@ class _ConnectDevicePageState extends ConsumerState<ConnectDevicePage> {
|
|||||||
|
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case Ok():
|
case Ok():
|
||||||
if (!Platform.isAndroid) {
|
|
||||||
controller.readCharacteristic(
|
|
||||||
device.id,
|
|
||||||
'0993826f-0ee4-4b37-9614-d13ecba4ffc2',
|
|
||||||
'0993826f-0ee4-4b37-9614-d13ecba40000',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final notifier = ref.read(nConnectedDevicesProvider.notifier);
|
final notifier = ref.read(nConnectedDevicesProvider.notifier);
|
||||||
final name = device.name.isNotEmpty ? device.name : 'Unknown Device';
|
final name = device.name.isNotEmpty ? device.name : 'Unknown Device';
|
||||||
final deviceCompanion = ConnectedDevicesCompanion(
|
final deviceCompanion = ConnectedDevicesCompanion(
|
||||||
|
|||||||
Reference in New Issue
Block a user