I'm doing pairing test with code below in WPF app, but it always failed with Failed status .
To use BluetoothLe library I just added reference (C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd)
if (!DeviceInformation.Pairing.IsPaired)
{
Logger.Info($"{DeviceInformation.Name} Try Pairing");
var result = await DeviceInformation.Pairing.PairAsync(DevicePairingProtectionLevel.None);
Logger.Info($"{result.Status}");
}
strange thing is
pairing is okay with UWP App with same code.
unpairing is ok in both UWP and WPF app.
The difference is that UWP app always pops up system dialog to confirm pairing and unparing, but WPF app doesn't show any dialog.
Can anybody help me?
Solved! Thank you. I Just used custom paring.
public async void Pair()
{
if (!DeviceInformation.Pairing.IsPaired)
{
Logger.Info($"{DeviceInformation.Name} Try Pairing");
DeviceInformation.Pairing.Custom.PairingRequested += CustomOnPairingRequested;
var result = await DeviceInformation.Pairing.Custom.PairAsync(
DevicePairingKinds.ConfirmOnly, DevicePairingProtectionLevel.None);
DeviceInformation.Pairing.Custom.PairingRequested -= CustomOnPairingRequested;
Logger.Info($"{result.Status}");
}
}
private void CustomOnPairingRequested(
DeviceInformationCustomPairing sender,
DevicePairingRequestedEventArgs args)
{
Logger.Info("Test");
args.Accept();
}