BluetoothLEAdvertisementPublisher 类

定义

用于发送蓝牙低功耗 (LE) 广告的对象。

public ref class BluetoothLEAdvertisementPublisher sealed
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Devices.Bluetooth.Advertisement.IBluetoothLEAdvertisementPublisherFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class BluetoothLEAdvertisementPublisher final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Devices.Bluetooth.Advertisement.IBluetoothLEAdvertisementPublisherFactory, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class BluetoothLEAdvertisementPublisher final
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Devices.Bluetooth.Advertisement.IBluetoothLEAdvertisementPublisherFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class BluetoothLEAdvertisementPublisher
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Devices.Bluetooth.Advertisement.IBluetoothLEAdvertisementPublisherFactory), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class BluetoothLEAdvertisementPublisher
function BluetoothLEAdvertisementPublisher(advertisement)
Public NotInheritable Class BluetoothLEAdvertisementPublisher
继承
Object Platform::Object IInspectable BluetoothLEAdvertisementPublisher
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
应用功能
bluetooth

注解

BluetoothLEAdvertisementPublisher 类允许配置和播发蓝牙 LE 播发数据包。 广告请求是尽最大努力提供服务的,广告参数由广告策略定义。

在构造 BluetoothLEAdvertisementPublisher 时配置播发的有效负载。 可以通过 BluetoothLEAdvertisementPublisher 的 Advertisement 属性检索有效负载。 如果以这种方式使用 ,则 BluetoothLEAdvertisement 类必须由调用方管理。 例如,不建议直接重复使用从 BluetoothLEAdvertisementReceivedEventArgs 获取的 BluetoothLEAdvertisement,因为它包含实际有效负载的重复,以便于访问常见数据部分。 如果需要复制收到的 BluetoothLEAdvertisement ,应仅复制 DataSections 属性,因为它们以原始形式表示广告数据部分。

本地播发资源在协议层受到限制。 此资源的使用最适合于企业用例等受控方案。 其他应用可能会竞争此有限的资源,无法保证任何特定用例的定期广播广告。

允许使用以下播发类型:

  • 制造商特定信息 (0xFF)
  • 系统未保留的任何非标准类型,如以下列表所示。 有关非标准类型的详细信息,请参阅 分配号码和 GAP 蓝牙规范。

以下播发类型是系统保留的,不允许使用:

  • 标志 (0x01)
  • 16 位服务 UUID (0x02) 不完整列表
  • 16 位服务 UUID (0x03) 的完整列表
  • 32 位服务 UUID 的不完整列表 (0x04)
  • 32 位服务 UUID (0x05) 的完整列表
  • 128 位服务 UUID (0x06) 的不完整列表
  • 128 位服务 UUID 的完整列表 (0x07)
  • 缩短的本地名称 (0x08)
  • 完成本地名称 (0x09)
  • Tx 功率级别 (0x0A)
  • 设备 (0x0D) 类
  • 简单配对哈希 C192 (0x0E)
  • 简单配对随机器 R192 (0x0F)
  • 安全管理器 TK 值 (0x10)
  • 安全管理器带外标志 (0x11)
  • 外围连接间隔范围 (0x12)
  • 16 位服务请求 UUID 列表 (0x14)
  • 32 位服务请求 UUID (0x1F) 列表
  • 128 位服务请求 UUID (0x15) 列表
  • 服务数据 16 位 UUID (0x16)
  • 服务数据 32 位 UUID (0x20)
  • 服务数据 128 位 UUID (0x21)
  • 公共目标地址 (0x17)
  • 随机目标地址 (0x18)
  • 外观 (0x19)
  • 广告间隔 (0x1A)
  • LE 蓝牙设备地址 (0x1B)
  • LE 角色 (0x1C)
  • 简单配对哈希 C256 (0x1D)
  • 简单配对随机器 R256 (0x1E)
  • 3D 信息数据 (0x3D)

版本历史记录

Windows 版本 SDK 版本 增值
2004 19041 IncludeTransmitPowerLevel
2004 19041 IsAnonymous
2004 19041 PreferredTransmitPowerLevelInDBm
2004 19041 UseExtendedAdvertisement

构造函数

BluetoothLEAdvertisementPublisher()

创建新的 BluetoothLEAdvertisementPublisher 对象。

BluetoothLEAdvertisementPublisher(BluetoothLEAdvertisement)

使用要发布的蓝牙 LE 播发创建新的 BluetoothLEAdvertisementPublisher 对象。

属性

Advertisement

获取要发布的蓝牙 LE 播发的副本。

配置发布者对象时,不能 (BluetoothLEAdvertisementPublisher.Advertisement.FlagsBluetoothLEAdvertisementPublisher.Advertisement.LocalName) 添加受限节类型。 尝试设置这些属性值会导致运行时异常。 仍可以设置制造商数据部分,或限制列表未定义的任何其他部分。

IncludeTransmitPowerLevel

指定播发标头中是否包含发射功率级别。 默认为 False。

IsAnonymous

指定设备地址是否包含在播发标头中。 默认情况下,将包含地址。

PreferredTransmitPowerLevelInDBm

如果指定,则请求无线电对播发使用指示的发射功率级别。 默认为 Null。

Status

获取 BluetoothLEAdvertisementPublisher 的当前状态。

UseExtendedAdvertisement

指定广告发布者应使用扩展广告格式。

方法

Start()

开始播发蓝牙 LE 播发有效负载。

Stop()

停止发布者并停止播发蓝牙 LE 广告有效负载。

事件

StatusChanged

BluetoothLEAdvertisementPublisher 的状态已更改的通知。

适用于

另请参阅