Rename in-app pairing capabilities (#88)

This commit is contained in:
Foti Dim
2024-09-23 07:13:41 +02:00
committed by GitHub
parent bf270c2bf4
commit 3ecbcb9b43
4 changed files with 186 additions and 104 deletions
+17 -9
View File
@@ -1,23 +1,31 @@
import 'package:flutter/foundation.dart';
class BleCapabilities {
/// Returns true if pairing is possible either by API or by encrypted characteristic.
/// Returns true if in-app pairing is possible either by API or by encrypted characteristic
/// using any kind of security level (JustWorks, Numeric Comparison or Passkey Entry).
///
/// All platforms return true except Web/Windows and Web/Linux which return false.
/// All platforms return true except Web/Windows and Web/Linux which return false
/// because they only support "Numeric Comparison" and "Passkey Entry".
///
/// Under conditions, `Web/Windows` and `Web/Linux` could still trigger in-app pairing.
/// Peripherals that require "Numeric Comparison" or "Passkey Entry" can
/// successfully trigger pairing.
/// When false, triggering pairing depends on the security level requested by your peripheral.
/// In that case, it is recommended to use `triggersJustWorksPairingWithEncryptedChar`
/// in conjunction with the security level of your peripheral.
static final bool supportsAllPairingKinds =
triggersJustWorksPairingWithEncryptedChar || hasSystemPairingApi;
/// Returns true if the platform triggers JustWorks pairing when trying to read or write
/// to an encrypted characteristic.
///
/// Higher security level pairing modes like "Numeric Comparison" or "Passkey Entry"
/// 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 bool supportsInAppPairing =
_triggersPairingWithEncryptedChar || hasSystemPairingApi;
static final _triggersPairingWithEncryptedChar =
static final triggersJustWorksPairingWithEncryptedChar =
defaultTargetPlatform != TargetPlatform.windows &&
defaultTargetPlatform != TargetPlatform.linux;
/// Returns true if pair()/unpair() are supported on the platform.
static bool hasSystemPairingApi = !kIsWeb &&
(defaultTargetPlatform == TargetPlatform.android ||
defaultTargetPlatform == TargetPlatform.windows ||