setPreferredPhy method

Future<void> setPreferredPhy({
  1. required String deviceId,
  2. required BluetoothPhy txPhy,
  3. required BluetoothPhy rxPhy,
  4. int phyOptions = 0,
})

设置 BLE 连接优先 PHY。

参数:

  • deviceId:已连接设备标识,无默认值。
  • txPhy:发送方向 PHY,无默认值。Android 8.0+ 支持;iOS/macOS/Linux/Windows/Web 不支持。
  • rxPhy:接收方向 PHY,无默认值。推荐与 txPhy 保持一致。
  • phyOptions:Android PHY 选项,默认 0 表示无偏好。只有使用 BluetoothPhy.leCoded 时才需要考虑平台常量 S2/S8;一般推荐保持 0

推荐值:如果 BluetoothAdapterInfo.isLe2MPhySupportedtrue,短距离高吞吐可用 BluetoothPhy.le2m;长距离低速可用 BluetoothPhy.leCoded;否则使用 BluetoothPhy.le1m

Implementation

Future<void> setPreferredPhy({
  required String deviceId,
  required BluetoothPhy txPhy,
  required BluetoothPhy rxPhy,
  int phyOptions = 0,
}) {
  throw UnimplementedError('setPreferredPhy() has not been implemented.');
}