为了账号安全,请及时绑定邮箱和手机立即绑定

带有 Unity 的 Hololens 上的 BluetoothLEDevice

带有 Unity 的 Hololens 上的 BluetoothLEDevice

C#
炎炎设计 2022-01-09 16:15:44
我正在尝试从 BLE 设备读取传感器数据,但对 Unity / C# / HoloLens / UWP 来说是全新的。我使用的 UWP 命名空间:#if NETFX_COREusing System;using Windows.Devices.Bluetooth.Advertisement;using Windows.Devices.Bluetooth;#endif这是 BluetoothLEAdvertisementWatcher.Received 的事件处理程序:#if NETFX_COREprivate async void Watcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args){    Debug.Log("=Received Advertisement=");    ulong bluetoothAddress = args.BluetoothAddress;    Debug.Log("  BT_ADDR: " + bluetoothAddress);    Debug.Log("  Local name: " + args.Advertisement.LocalName);    Debug.Log("  advertisement type: " + args.AdvertisementType.ToString());    // Throws 'System.IO.FileNotFoundException' in System.Private.CoreLib.ni.dll    BluetoothLEDevice device = await BluetoothLEDevice.FromBluetoothAddressAsync(bluetoothAddress);}#endif我在堆栈跟踪中看到的所有内容都是:抛出异常:System.Private.CoreLib.ni.dll 中的“System.IO.FileNotFoundException”系统找不到指定的文件。(来自 HRESULT 的异常:0x80070002)我不知道如何进一步调试这个,或者一般有什么问题。
查看完整描述

1 回答

?
森栏

TA贡献1810条经验 获得超5个赞

在我的特殊情况下,转到系统 - > 设备(HOLOLENS)并删除所有以前配对的蓝牙设备可以解决问题。

就我而言,我在设备列表中只有 Hololens 的“Clicker”。删除它后

System.IO.FileNotFoundException

不再抛出,并且

BluetoothLEDevice.FromBluetoothAddressAsync

似乎工作。答题器不在附近或在任何地方,只是之前(几周前)配对

这个错误总是可以通过以下方式重现:

  • 配对答题器

  • 配对其他 Gatt 设备

在调用 BluetoothLEDevice.FromBluetoothAddressAsync 时,System.IO.FileNotFoundException 再次被抛出,即使点击器未配对。当我从设备列表中删除答题器时,它又可以工作了。


查看完整回答
反对 回复 2022-01-09
  • 1 回答
  • 0 关注
  • 612 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号