これは、BLEデバイスを取得するためのUWPコードです。なぜ私はbleDevice ==いくつかのデバイスのnullを取得する?私はそれを説明する文書を見つけられませんでした。BluetoothLEDevice.FromIdAsync returned null
var devices = await DeviceInformation.FindAllAsync(BluetoothLEDevice.GetDeviceSelector());
foreach (DeviceInformation di in devices)
{
Debug.WriteLine(di.Name);
BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromIdAsync(di.Id);
if (bleDevice == null) {
Debug.WriteLine("--- NULL ----");
continue;
}
Debug.WriteLine(bleDevice.Name);
}
私はbleDeviceを得ることに気づいた!=、WindowsのデバイスマネージャでSTATUS_DEVICE_POWER_FAILUREと感嘆符を持っているBLEデバイスの場合はnull。
デバイスマネージャで感嘆符が付いていないBLEデバイスの場合、bleDevice == nullが返されます。
、私は非常にあなたに感謝しなければなりませんこの単純な解決策のために私はなぜ私がnullになっていたのかを理解しようとしている私の髪を引っ張っていた。 – Kingpin