fix(pairing): pairing flow preempt status read fix
This commit is contained in:
@ -51,6 +51,11 @@ class _DeviceDetailsPageState extends ConsumerState<DeviceDetailsPage> {
|
||||
2.77,
|
||||
3.27,
|
||||
];
|
||||
static const List<Duration> _initialStatusRetryDelays = [
|
||||
Duration(milliseconds: 500),
|
||||
Duration(milliseconds: 1500),
|
||||
Duration(seconds: 3),
|
||||
];
|
||||
|
||||
bool _isExitingPage = false;
|
||||
bool _hasRequestedDisconnect = false;
|
||||
@ -218,7 +223,24 @@ class _DeviceDetailsPageState extends ConsumerState<DeviceDetailsPage> {
|
||||
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) {
|
||||
await service.dispose();
|
||||
return;
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:abawo_bt_app/controller/bluetooth.dart';
|
||||
import 'package:abawo_bt_app/database/database.dart';
|
||||
import 'package:abawo_bt_app/model/bluetooth_device_model.dart';
|
||||
@ -92,14 +90,6 @@ class _ConnectDevicePageState extends ConsumerState<ConnectDevicePage> {
|
||||
|
||||
switch (res) {
|
||||
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 name = device.name.isNotEmpty ? device.name : 'Unknown Device';
|
||||
final deviceCompanion = ConnectedDevicesCompanion(
|
||||
|
||||
Reference in New Issue
Block a user