Rename to triggersConfirmOnlyPairing

This commit is contained in:
Foti Dim
2024-09-24 17:33:00 +02:00
parent 73e4d5e68e
commit 4914687284
2 changed files with 9 additions and 10 deletions
+8 -9
View File
@@ -2,26 +2,25 @@ import 'package:flutter/foundation.dart';
class BleCapabilities {
/// Returns true if in-app pairing is possible either by API or by encrypted characteristic
/// using any kind of pairing method (JustWorks, Numeric Comparison or Passkey Entry).
/// using any kind of pairing method (Just Works, Numeric Comparison or Passkey Entry).
///
/// All platforms return true except Web/Windows and Web/Linux which return false
/// because they only support "Numeric Comparison" and "Passkey Entry".
///
/// For more fine-grained control it is recommended to use `triggersJustWorksPairingWithEncryptedChar`
/// For more fine-grained control it is recommended to use `triggersConfirmOnlyPairing`
/// in conjunction with the pairing method of your peripheral,
/// e.g. if (!BleCapabilities.triggersJustWorksPairingWithEncryptedChar && peripheralUsesJustWorksPairing) throw "In-app pairing not supported";
/// e.g. if (!BleCapabilities.triggersConfirmOnlyPairing && peripheralUsesConfirmOnlyPairing) throw "In-app pairing not supported";
static final bool supportsAllPairingKinds =
triggersJustWorksPairingWithEncryptedChar || hasSystemPairingApi;
triggersConfirmOnlyPairing || hasSystemPairingApi;
/// Returns true if the platform triggers JustWorks pairing when trying to read or write
/// to an encrypted characteristic.
/// Returns true if the platform triggers pairing for devices that use only confirmation pairing
/// (a.k.a. "Just Works" or legacy pairing) when trying to read or write to an encrypted characteristic.
///
/// Pairing methods such as "Numeric Comparison" or "Passkey Entry"
/// trigger pairing on all platforms.
/// The "Numeric Comparison" and "Passkey Entry" pairing methods trigger pairing on all platforms.
///
/// `Web/Linux` could also, under certain conditions, trigger "Just Works" pairing
/// but it very unreliable, therefore we return false.
static final triggersJustWorksPairingWithEncryptedChar =
static final triggersConfirmOnlyPairing =
defaultTargetPlatform != TargetPlatform.windows &&
defaultTargetPlatform != TargetPlatform.linux;
+1 -1
View File
@@ -236,7 +236,7 @@ class UniversalBle {
/// You can optionally pass a pairingCommand if you know an encrypted read or write characteristic.
/// If you do, it returns true if it can successfully execute the command after pairing.
///
/// On `Web/Windows` and `Web/Linux` it does not work for devices that use "Just Works" pairing.
/// On `Web/Windows` and `Web/Linux`, it does not work for devices where `BleCapabilities.triggersConfirmOnlyPairing` is false.
static Future<bool?> pair(
String deviceId, {
BleCommand? pairingCommand,