微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

蓝牙 LE 广告观察器未在 HoloLens 2

如何解决蓝牙 LE 广告观察器未在 HoloLens 2

在此 question 之后,我也无法让蓝牙观察器在 HoloLens 2 上接收广告。我已经完成了示例 here,但在我的电脑上运行场景 2 时没有运气笔记本电脑和我的 HoloLens 上的场景 1。

我的 HoloLens 似乎没有触发任何接收到的事件。我试过重新启动 HoloLens 并检查更新。我目前运行的是操作系统版本 20346.1403。

非常感谢任何帮助故障排除。我已经能够让 regular BluetoothLE sample 正确运行,但是我的最终目标是让所有这些都在 Unity 应用程序中运行,并且由于某种原因,观察者没有收到任何带有常规 BluetoothLE 代码的事件来自我的 Unity 应用程序。

如果有人对 Unity 和 bluetoothLE 示例有经验,我非常想了解更多相关信息。

using TMPro;
using UnityEngine;
#if WINDOWS_UWP
using Windows.Devices.Bluetooth.Advertisement;
using System.Runtime.InteropServices.WindowsRuntime;
#endif

public class GPSReceiver : MonoBehavIoUr
{
    public TextMeshProUGUI debugText;
#if WINDOWS_UWP
    bluetoothleadvertisementwatcher watcher;
#endif
    public static ushort BEACON_ID = 1775;
    public EventProcessor eventProcessor;

void Awake()
{
#if WINDOWS_UWP
    watcher = new bluetoothleadvertisementwatcher();
    BluetoothLEManufacturerData manufacturerData = new BluetoothLEManufacturerData
    {
        CompanyId = BEACON_ID
    };
    watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(manufacturerData);
    watcher.Received += Watcher_Received;
    watcher.Start();
    debugText.text = "Watcher status: " + watcher.Status.ToString() + " " + watcher.ScanningMode.ToString();
#endif
}

#if WINDOWS_UWP
private async void Watcher_Received(bluetoothleadvertisementwatcher sender,BluetoothLEAdvertisementReceivedEventArgs args)
{
    debugText.text = "received bytes";
    ushort identifier = args.Advertisement.ManufacturerData[0].CompanyId;
    byte[] data = args.Advertisement.ManufacturerData[0].Data.ToArray();
    // Updates to Unity UI don't seem to work nicely from this callback so just store a reference to the data for later processing.
    eventProcessor.QueueData(data);
}
#endif
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。