startAdvertising method
Future<void>
startAdvertising({
- BluetoothAdvertisementData advertisementData = const BluetoothAdvertisementData(),
- BluetoothAdvertisementData? scanResponse,
- BluetoothAdvertisingSettings settings = const BluetoothAdvertisingSettings(),
开始 BLE 广播。
参数:
advertisementData:主广播数据,默认const BluetoothAdvertisementData()。 跨平台推荐只放localName与少量serviceUuids,避免超过传统 31 字节限制。scanResponse:扫描响应数据,默认null。Android 支持;iOS/macOS 当前忽略; Linux/Windows/Web 不支持广播。settings:广播设置,默认const BluetoothAdvertisingSettings(),即 balanced、 medium、connectabletrue、无超时。Android 支持这些设置;iOS/macOS 当前忽略设置; Linux/Windows/Web 不支持广播。
平台差异:Android 支持 manufacturer/service data、scan response 和功率/模式设置;
iOS/macOS 当前只使用 BluetoothAdvertisementData.localName 与 serviceUuids;
Linux/Windows/Web 不支持。
Implementation
Future<void> startAdvertising({
BluetoothAdvertisementData advertisementData =
const BluetoothAdvertisementData(),
BluetoothAdvertisementData? scanResponse,
BluetoothAdvertisingSettings settings =
const BluetoothAdvertisingSettings(),
}) {
throw UnimplementedError('startAdvertising() has not been implemented.');
}