-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Hey there.
About a month ago, I slowly started making the steps for developing my own SDK, until I heard you were already making one. The first thing I did, was make sure I could connect to the Nuimo programmatically, without the user having to pair it first. And so I did. I'll post some snippets of the code here, so you can implement it into the SDK if you want. If not, I'll just keep that part in my own application. It could definitely use some polish, but it was just a proof of concept to make sure I could connect it programmatically.
static void Main(string[] arg)
{
var aqsFilter = "System.Devices.Aep.ProtocolId:=\"{bb7bb05e-5972-42b5-94fc-76eaa7084d49}\"";
var deviceWatcher = DeviceInformation.CreateWatcher(aqsFilter, new[] {"System.Devices.Aep.IsPaired"},
DeviceInformationKind.AssociationEndpoint);
deviceWatcher.Added += DeviceWatcher_Added;
deviceWatcher.Updated += DeviceWatcher_Updated;
deviceWatcher.Start();
Console.ReadLine();
});
private static void DeviceWatcher_Updated(DeviceWatcher sender, DeviceInformationUpdate args)
{
}
private static async void DeviceWatcher_Added(DeviceWatcher sender, DeviceInformation args)
{
if (args.Name != "Nuimo")
return;
sender.Stop();
Console.WriteLine(args.Name);
foreach (var keyValuePair in args.Properties)
{
Console.WriteLine($"{keyValuePair.Key}: {keyValuePair.Value}");
}
if (!args.Pairing.IsPaired)
{
DevicePairingKinds ceremoniesSelected = DevicePairingKinds.ConfirmOnly | DevicePairingKinds.DisplayPin | DevicePairingKinds.ProvidePin | DevicePairingKinds.ConfirmPinMatch;
DevicePairingProtectionLevel protectionLevel = DevicePairingProtectionLevel.Default;
// Specify custom pairing with all ceremony types and protection level EncryptionAndAuthentication
DeviceInformationCustomPairing customPairing = args.Pairing.Custom;
customPairing.PairingRequested += PairingRequestedHandler;
var result = await customPairing.PairAsync(ceremoniesSelected, protectionLevel);
customPairing.PairingRequested -= PairingRequestedHandler;
if (result.Status == DevicePairingResultStatus.Paired)
{
Console.WriteLine("Successfully paired! :D");
}
else
{
Console.WriteLine("Pairing Failed " + result.Status);
return;
}
}
}
private static void PairingRequestedHandler(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
{
args.Accept();
}
Metadata
Metadata
Assignees
Labels
No labels