私はBLEデバイスをスキャンできるWindowsの電話アプリで作業しています。私は希望のデバイスを表示しているロジックを実装しています。利用可能な/存在するBluetooth低エネルギー(BLE)デバイスをスキャンする方法はありますか?
しかし、問題は、私がそれらのデバイスを削除するか、それらをオフにすると、私のアプリケーションがスキャン結果でその名前を返すということです。キャッシュされた結果が戻ってくると思います。どのように私はそれが利用可能/存在するデバイスだけを表示することを確認することができます。
私はスキャンでSystem.Devices.Aep.IsPresentなどの追加プロパティを使用しようとしましたが、利用可能なデバイスに関係なく結果にnullが表示されています。ここで
は、私が使用していたコードスニペットです -
string[] requestedProperties = new string[] { "System.Devices.Aep.IsPresent"
, "System.Devices.Present"
, "System.Devices.Connected"
, "System.Devices.Paired"
, "System.Devices.Aep.IsConnected"
, "System.Devices.AepContainer.IsPresent"
};
diCollection = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(serviceUuid)
, requestedProperties
);
foreach (var diItem in diCollection)
{
Debug.WriteLine("Discovered Device name - " + diItem.Name);
Debug.WriteLine("Discovered Device Additional Properties Below");
foreach (var item in diItem.Properties)
{
Debug.WriteLine("Key-{0} Value-{1}", item.Key, item.Value);
}
}
をここで使用Package.appxmanifest能力である -
<Capabilities>
<Capability Name="internetClientServer" />
<DeviceCapability Name="bluetooth" />
</Capabilities>
私はこの小さな問題を解決してください。私はここで何か些細なことを逃していますか?
ありがとうございます。
このクラスを使用してみましたか?https://msdn.microsoft.com/en-us/library/windows.devices.bluetooth.advertisement.bluetoothleadvertisementwatcher.aspx? – Emil
こんにちはEmil、私はそれを試していないが、私はこのクラスが私が使用しているWindows Mobile 8.1 APIで利用できないことがわかります。私はこれがUWPプロジェクトに存在することがわかりますが。 – Jkm
このJkmを解決できましたか? – user3141326