共用方式為


BluetoothLEAdvertisementWatcherTrigger 類別

定義

表示已註冊以在背景掃描藍牙 LE 公告的觸發程式。

public ref class BluetoothLEAdvertisementWatcherTrigger sealed
/// [Windows.Foundation.Metadata.Activatable(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 BluetoothLEAdvertisementWatcherTrigger 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(65536, "Windows.Foundation.UniversalApiContract")]
class BluetoothLEAdvertisementWatcherTrigger final
[Windows.Foundation.Metadata.Activatable(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 BluetoothLEAdvertisementWatcherTrigger
[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(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class BluetoothLEAdvertisementWatcherTrigger
function BluetoothLEAdvertisementWatcherTrigger()
Public NotInheritable Class BluetoothLEAdvertisementWatcherTrigger
繼承
Object Platform::Object IInspectable BluetoothLEAdvertisementWatcherTrigger
屬性
實作

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

備註

收到公告時,就會啟動背景工作。

此觸發程式的運作方式與 BluetoothAdvertisementWatcher 類別類似,但例外狀況是它有更多限制,因為它可讓應用程式在背景接收廣告。 值得注意的是,在背景中完全接受單一篩選模式, (不更多,而不是較少的) 。

註冊之後,背景監看員會以最佳方式提供服務。 當收到符合透過觸發程式設定篩選的公告時,將會啟動背景工作來通知應用程式。 應用程式也會透過背景工作內容中提供的觸發程式詳細資料,收到背景監看員失敗或中斷的通知。 若要停止接收公告,必須取消註冊與此觸發程式相關聯的背景工作。

基於一般本質,不允許在背景篩選下列廣告類型

  • 旗標 (0x01)
  • 裝置 (0x0D) 類別
  • 安全性管理員頻外旗標 (0x11)
  • 外觀 (0x19)
  • LE 角色 (0x1C)

製造商特定資料之原始區段的背景篩選 (0xFF) 只會針對具有0x00之區段的第二個位元組相符,因為它對應于公司識別碼欄位最重要的位元組。 所有 SIG 指派的公司識別碼目前都已將此位元組設定為0x00,且只執行與單一位元組的部分比對,可能會導致在有多個廣告商存在時,超過收到的廣告。 這可能會影響系統的電池使用時間。

使用 BluetoothLEAdvertisementWatcherTrigger 受限於可用的硬體卸載資源。 本機藍牙無線電支援 HCI 擴充功能 的新 Windows 裝置可提供較低的電源廣告掃描,改善長期案例的電池使用時間,例如指標。 可用的硬體資源數量取決於無線電和目前的全系統使用量,而且嘗試註冊此觸發程式時,不會再使用任何資源時傳回 BluetoothError.ResourceInUse 。 應用程式應該謹慎使用這些資源,以提供專注且有效率的案例,以便只監看需要特定遠端廣告商的唯一廣告資料。

雖然許多新的 Windows 裝置都支援 HCI 擴充功能,但有些裝置可能沒有,特別是在舊版 Windows 版本的舊版裝置上升級的情況。 在這些情況下,Windows 會模擬軟體中的硬體篩選,在系統上的所有應用程式中提供最多 20 個觸發條件。 使用此軟體模擬時,嘗試在達到上限後註冊觸發程式資源,會導致擲回例外狀況,並 ERROR_NO_SYSTEM_RESOURCES (0x800705AA) 錯誤。

版本歷程記錄

Windows 版本 SDK 版本 已新增值
2004 19041 AllowExtendedAdvertisements

建構函式

BluetoothLEAdvertisementWatcherTrigger()

建立 BluetoothLEAdvertisementWatcherTrigger 類別的新實例。

屬性

AdvertisementFilter

取得或設定使用承載區段型篩選的藍牙 LE 廣告篩選組態。

AllowExtendedAdvertisements

使用擴充廣告格式啟用廣告的接收。 預設為 False。

MaxOutOfRangeTimeout

取得此觸發程式 之 SignalStrengthFilter 屬性所支援的範圍逾時上限。

MaxSamplingInterval

取得此觸發程式的 SignalStrengthFilter 屬性所支援的最大取樣間隔。 取樣間隔上限是用來停用取樣篩選準則,而且只會根據傳入和超出範圍的裝置觸發接收的事件。

MinOutOfRangeTimeout

取得此觸發程式 之 SignalStrengthFilter 屬性所支援的最小超出範圍逾時。

MinSamplingInterval

取得這個觸發程式的 SignalStrengthFilter 屬性支援的最小取樣間隔。 背景監看員的最小取樣間隔不能是零,不同于其前景對應專案。

SignalStrengthFilter

取得或設定使用訊號強度型篩選的藍牙 LE 廣告篩選組態。

適用於

另請參閱