【问题标题】:BLE estimote eddystone background task not runningBLE 估计 eddystone 后台任务未运行
【发布时间】:2015-12-18 14:25:16
【问题描述】:

我正在尝试创建一个后台任务,该任务将在系统检测到由 estimote 信标广播的 eddystone 广告时运行。

我已经将信标配置为发送 eddystone 数据包,并在应用程序处于前台时使用 UniversalBeaconLibrary 获取这些数据包(这里没有问题)。

现在我想在应用程序未启动时收到通知(使用对蓝牙广播数据包作出反应的后台任务)。据我了解,为了避免对电池/cpu 造成太大压力,我确实需要过滤这些广告。

一种最简单的过滤形式(我尝试使用的)是使用蓝牙 SIG 提供的公司 ID。

这是我尝试过的:

public static async void Register()
{
    if (BackgroundTaskRegistration.AllTasks.Count == 0)
    {
        var trigger = MakeTrigger();

        // this is needed for Phone, not so for Windows in this case.  
        var allowed = await BackgroundExecutionManager.RequestAccessAsync();

        if ((allowed != BackgroundAccessStatus.Denied) &&
            (allowed != BackgroundAccessStatus.Unspecified))
        {
            BackgroundTaskBuilder builder = new BackgroundTaskBuilder
            {
                Name = "BLEWatcher",
                TaskEntryPoint = typeof(BLEBackgroundConsumer.Consumer).FullName
            };
            builder.SetTrigger(trigger);
            builder.Register();
        }
    }
}
private static BluetoothLEAdvertisementWatcherTrigger MakeTrigger()
{
    var trigger = new BluetoothLEAdvertisementWatcherTrigger();
    //Can add some filters here
    //trigger.AdvertisementFilter.Advertisement.ManufacturerData.Add(new BluetoothLEManufacturerData()
    //{
    //    CompanyId = 349 //Estimote
    //});
    //trigger.AdvertisementFilter.Advertisement.ManufacturerData.Add(new BluetoothLEManufacturerData()
    //{
    //    CompanyId = 76 // Apple
    //});
    //trigger.AdvertisementFilter.Advertisement.ManufacturerData.Add(new BluetoothLEManufacturerData()
    //{
    //    CompanyId = 224 // Google
    //});
    return (trigger);
}

因为它是我得到一个例外,说没有足够或太多的过滤。

取消注释其中一个触发器块时,我没有发现异常,但任务似乎没有启动。

**编辑:**我问估计他们在使用 eddystone 数据包时广播的公司 ID 是什么。根据他们的说法,没有。

关于这个答案,什么是合适的过滤器?

【问题讨论】:

    标签: c# bluetooth-lowenergy estimote windows-10-universal eddystone


    【解决方案1】:

    Bluetooth SIG 公司 ID 仅与制造商 Bluetooth LE 广告一起使用,例如 iBeacon 和 AltBeacon。 Eddystone 使用不包含公司 ID 的服务蓝牙 LE 广告。相反,它们包含 0xFEAA 的 16 位服务 UUID。

    更多详情请看这里:https://github.com/google/eddystone/blob/master/protocol-specification.md

    【讨论】:

    • 谢谢,现在我只需为此服务 UUID 创建一个位掩码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-01
    • 1970-01-01
    • 2020-10-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多