isPaired static method
Check if a device is paired.
For Apple and Web, you have to pass a "pairingCommand" with an encrypted read or write characteristic.
Returns true/false if it manages to execute the command.
Returns null when no pairingCommand is passed.
Note that it will trigger pairing if the device is not already paired.
Implementation
static Future<bool?> isPaired(
String deviceId, {
BleCommand? pairingCommand,
Duration? timeout,
}) async {
if (BleCapabilities.hasSystemPairingApi) {
return _bleCommandQueue.queueCommand(
() => _platform.isPaired(deviceId),
deviceId: deviceId,
timeout: timeout,
);
}
if (pairingCommand == null) {
UniversalLogger.logWarning("PairingCommand required to get result");
return null;
}
try {
await _connectAndExecuteBleCommand(
deviceId,
pairingCommand,
updateCallbackValue: false,
timeout: timeout,
);
// Because pairingCommand will be never null, so we wont get Unknown result here
return true;
} catch (e) {
UniversalLogger.logError("ExecuteBleCommandFailed: $e");
return false;
}
}