mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-01 14:40:32 +10:00
Enhance Bluetooth scanning and notification handling for web platform
This commit is contained in:
committed by
just-stuff-tm
parent
c23a1da430
commit
5f4333398e
@@ -738,7 +738,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await FlutterBluePlus.startScan(
|
await FlutterBluePlus.startScan(
|
||||||
withKeywords: ["MeshCore-", "Whisper-"],
|
withKeywords: ["MeshCore-", "Whisper-", "Wismesh-", "WisCore-"],
|
||||||
webOptionalServices: [Guid(MeshCoreUuids.service)],
|
webOptionalServices: [Guid(MeshCoreUuids.service)],
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
androidScanMode: AndroidScanMode.lowLatency,
|
androidScanMode: AndroidScanMode.lowLatency,
|
||||||
@@ -836,7 +836,18 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
throw Exception("MeshCore characteristics not found");
|
throw Exception("MeshCore characteristics not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retry setNotifyValue with increasing delays
|
if (PlatformInfo.isWeb) {
|
||||||
|
debugPrint('Starting setNotifyValue(true)');
|
||||||
|
debugPrint('Web: Calling setNotifyValue(true) without awaiting');
|
||||||
|
unawaited(() async {
|
||||||
|
try {
|
||||||
|
await _txCharacteristic!.setNotifyValue(true);
|
||||||
|
} catch (error) {
|
||||||
|
debugPrint('Web setNotifyValue error (ignoring): $error');
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
debugPrint('setNotifyValue(true) configuration completed');
|
||||||
|
} else {
|
||||||
bool notifySet = false;
|
bool notifySet = false;
|
||||||
for (int attempt = 0; attempt < 3 && !notifySet; attempt++) {
|
for (int attempt = 0; attempt < 3 && !notifySet; attempt++) {
|
||||||
try {
|
try {
|
||||||
@@ -850,6 +861,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
if (attempt == 2) rethrow;
|
if (attempt == 2) rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_notifySubscription = _txCharacteristic!.onValueReceived.listen(
|
_notifySubscription = _txCharacteristic!.onValueReceived.listen(
|
||||||
_handleFrame,
|
_handleFrame,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user