[英]Bug in windows bluetooth le GetGattServicesAsync method
有時,無法從GetGattServicesAsync
方法GetGattServicesAsync
帶有參數BluetoothCacheMode.Cached
或BluetoothCacheMode.Uncached
響應。 只有Windows重新啟動才能幫助重新連接文件設備並從文件設備獲取服務。
我們將Windows.Devices.Bluetooth.dll
與.Net Framework 4.6.1一起使用來構建類庫。 Windows PC將連接藍牙文件設備。
問題重現的步驟:
FromBluetoothAddressAsync
將LE設備與桌面配對:
DeviceInformationPairing loPairingInf = poDevice.DeviceInformation.Pairing; if (!loPairingInf.IsPaired) { DevicePairingKinds loConfirm = DevicePairingKinds.ConfirmOnly; DevicePairingProtectionLevel loProtectionLevel = DevicePairingProtectionLevel.Default; DeviceInformationCustomPairing loCustomPairing = loPairingInf.Custom; }
檢查連接狀態。 如果狀態已連接,則調用方法GetGattServicesAsync(BluetoothCacheMode.Cached)
。 有時無法從GetGattServicesAsync
獲得響應。 30秒后,我們取消任務,處置BluetoothLEDevice
,解除BluetoothLEDevice
並嘗試重新連接該設備。 重新連接失敗,只有重新啟動Windows才能幫助建立與文件設備的連接。
PC:
戴爾Precision 5530
藍牙適配器高通QCA6174A
Windows 10企業版(1803)
版本10.0.17134內部版本17134.590
LE設備:
題:
是否可以避免GetGattServicesAsync的問題?
取消GetGattServicesAsync后,如果沒有重新啟動Windows,也許存在一些編程黑客來重新連接文件設備?
我發現一些系統服務與此問題有關。
您可以嘗試在TaskManager中重新啟動Bluetooth Support Service
。
如果要從TaskManager識別進程,則此服務的命令行為
C:\\ WINDOWS \\ system32 \\ svchost.exe -k LocalService -p -s bthserv
此解決方法並不完美,但比重新啟動計算機要好一些。
但是,請記住致電BluetoothLEDevice.Dispose
如果要關閉與BluetoothLE設備的連接,請處置。 否則,您可能會在一個過程中遇到其他問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.