我正在嘗試從 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 再次被拋出,即使點擊器未配對。當我從設備列表中刪除答題器時,它又可以工作了。
- 1 回答
- 0 關注
- 702 瀏覽
添加回答
舉報
0/150
提交
取消
