startScan method
startScan starts scanning for BLE devices.
To get the results, you need to set a callback function using onScanResult
.
Implementation
@override
Future<bool?> startScan({String? macAddress, List<String>? servicesUuids}) async {
if (_client == null) {
log("Error initializing BlueZClient");
return false;
}
_isScanning = true;
_macAddressFilter = macAddress;
try {
final adapter = _client!.adapters.firstOrNull;
await adapter?.startDiscovery();
for (final device in _client!.devices) {
_onScanAdded(device);
}
return true;
} catch (e) {
log("Error initializing BlueZClient: $e");
return false;
}
}