readConnectionParameters method

  1. @override
Future<BleConnectionParameters?> readConnectionParameters({
  1. required String deviceAddress,
})
override

Returns a snapshot of the active BLE link parameters for the connected device.

The native layer caches PHY values from onPhyRead and connection interval values from onConnectionUpdated, both of which fire automatically during connection setup. This call is effectively synchronous — it reads from the native cache rather than triggering a BLE operation.

Returns null on iOS and on Android API < 26, where the underlying callbacks are not available.

Implementation

@override
Future<BleConnectionParameters?> readConnectionParameters({
  required String deviceAddress,
}) async {
  try {
    final Map<dynamic, dynamic>? result =
        await channel.invokeMethod<Map<dynamic, dynamic>>(
      'readConnectionParameters',
      {'address': deviceAddress},
    );
    if (result == null) return null;
    return BleConnectionParameters.fromMap(result);
  } on PlatformException catch (e) {
    throw BluetoothConnectionException(
      'Failed to read connection parameters: ${e.message}',
    );
  }
}