Connection Options
ConnectionOptions (ConnectionOptions) controls how IBluetoothRemoteDevice.ConnectAsync() establishes a connection: permission behavior, retry logic, whether to wait for an advertisement first, and platform-specific parameters. It's passed per call, not DI-configured — see the type's generated page for the full property list.
Basic Usage
var options = new ConnectionOptions
{
PermissionStrategy = PermissionRequestStrategy.RequestAutomatically,
ConnectionRetry = RetryOptions.Default,
WaitForAdvertisementBeforeConnecting = false
};
await device.ConnectAsync(options);
Platform-Specific Options
- Android (AndroidConnectionOptions):
AutoConnect,ConnectionPriority,TransportType,PreferredPhy(API 26+), and per-operationServiceDiscoveryRetry/GattWriteRetry/GattReadRetry. - Apple (AppleConnectionOptions):
NotifyOnConnection/NotifyOnDisconnection/NotifyOnNotification,EnableTransportBridgingandRequiresAncs(iOS 13+). - Windows (WindowsConnectionOptions): see the generated reference — Windows exposes fewer connection-time knobs than Android/Apple.
Best Practices
- Always set retry logic. Connection failures are common, especially Android GATT error 133 — prefer
RetryOptions.AggressiveoverRetryOptions.Nonein production. - Disable
AutoConnecton Android. Direct connections are faster and more predictable;AutoConnect = trueis rarely what you want. - Match
ConnectionPriorityto the use case —Highfor real-time audio/control,LowPowerfor periodic sensor reads (see Enumerations for the trade-off table). - Add GATT operation retries on Android (
ServiceDiscoveryRetry,GattWriteRetry,GattReadRetry) for unreliable devices. - Set
WaitForAdvertisementBeforeConnecting = truefor devices with intermittent advertising. - Use conditional platform blocks (
options.Android = .../options.Apple = ...) rather than assuming one platform's option shape works everywhere.