Ejemplo n.º 1
0
        /// <summary>
        /// Called when custom pairing is initiated so that we can handle the custom ceremony
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void PairingRequestedHandler(
            DeviceInformationCustomPairing sender,
            DevicePairingRequestedEventArgs args)
        {
            // Save the args for use in ProvidePin case
            pairingRequestedHandlerArgs = args;

            // Save the deferral away and complete it where necessary.
            if (args.PairingKind != DevicePairingKinds.DisplayPin)
            {
                deferral = args.GetDeferral();
            }

            string confirmationMessage;

            switch (args.PairingKind)
            {
            case DevicePairingKinds.ConfirmOnly:
                // Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile
                // If this is an App for Athens where there is no Windows Consent UX, you may want to provide your own confirmation.
            {
                confirmationMessage = string.Format(bluetoothConfirmOnlyFormatString, args.DeviceInformation.Name, args.DeviceInformation.Id);
                DisplayMessagePanelAsync(confirmationMessage, MessageType.InformationalMessage);
                // Accept the pairing which also completes the deferral
                AcceptPairing();
            }
            break;

            case DevicePairingKinds.DisplayPin:
                // We just show the PIN on this side. The ceremony is actually completed when the user enters the PIN
                // on the target device
            {
                confirmationMessage = string.Format(bluetoothDisplayPinFormatString, args.Pin);
                DisplayMessagePanelAsync(confirmationMessage, MessageType.OKMessage);
            }
            break;

            case DevicePairingKinds.ProvidePin:
                // A PIN may be shown on the target device and the user needs to enter the matching PIN on
                // this Windows device.
                await MainPage.Current.UIThreadDispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                {
                    // PIN Entry
                    inProgressPairButton.Flyout = savedPairButtonFlyout;
                    inProgressPairButton.Flyout.ShowAt(inProgressPairButton);
                });

                break;

            case DevicePairingKinds.ConfirmPinMatch:
                // We show the PIN here and the user responds with whether the PIN matches what they see
                // on the target device. Response comes back and we set it on the PinComparePairingRequestedData
                // then complete the deferral.
            {
                confirmationMessage = string.Format(bluetoothConfirmPinMatchFormatString, args.Pin);
                DisplayMessagePanelAsync(confirmationMessage, MessageType.YesNoMessage);
            }
            break;
            }
        }
Ejemplo n.º 2
0
 private void CustomOnPairingRequested(
     DeviceInformationCustomPairing sender,
     DevicePairingRequestedEventArgs args)
 {
     Console.WriteLine("Done Pairing");
     args.Accept("0");
 }
Ejemplo n.º 3
0
        public static async void HandlePairing(CoreDispatcher dispatcher, DevicePairingRequestedEventArgs args)
        {
            using (Deferral deferral = args.GetDeferral())
            {
                switch (args.PairingKind)
                {
                case DevicePairingKinds.DisplayPin:
                    await ShowPinToUserAsync(dispatcher, args.Pin);

                    args.Accept();
                    break;

                case DevicePairingKinds.ConfirmOnly:
                    args.Accept();
                    break;

                case DevicePairingKinds.ProvidePin:
                {
                    string pin = await GetPinFromUserAsync(dispatcher);

                    if (String.IsNullOrEmpty(pin))
                    {
                        args.Accept(pin);
                    }
                }
                break;
                }
            }
        }
Ejemplo n.º 4
0
 private void OnCustomPairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     while (pin == null)
     {
         Thread.Sleep(500);
     }
     args.Accept(pin);
     pin = null;
 }
Ejemplo n.º 5
0
 private void handlerPairingReq(DeviceInformationCustomPairing CP, DevicePairingRequestedEventArgs DPR)
 {
     //so we get here for custom pairing request.
     //this is the magic place where your pin goes.
     //my device actually does not require a pin but
     //windows requires at least a "0".  So this solved
     //it.  This does not pull up the Windows UI either.
     DPR.Accept("0");
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Called when a custom pairing is initiated so that we can handle its custom ceremony
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public async void PairingRequestedHandlerAsync(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
        {
            LogService.Write((Enum.GetName(typeof(DevicePairingKinds), args.PairingKind)), LoggingLevel.Information);

            BluetoothDeviceInfo currentDevice = new BluetoothDeviceInfo(args.DeviceInformation);

            // Save the args for use in ProvidePin case
            _pairingRequestedArgs = args;

            // Save the deferral away and complete it where necessary.
            if (args.PairingKind != DevicePairingKinds.DisplayPin)
            {
                _deferral = args.GetDeferral();
            }

            switch (args.PairingKind)
            {
            // Windows itself will pop the confirmation dialog as part of "consent" depending on which operating OS is running
            case DevicePairingKinds.ConfirmOnly:
            {
                var confirmationMessage = string.Format(BluetoothConfirmOnlyText, args.DeviceInformation.Name, args.DeviceInformation.Id);
                if (await DisplayMessagePanel(confirmationMessage, MessageType.InformationalMessage))
                {
                    AcceptPairing();
                }
            }
            break;

            // We only show the PIN on this side. The ceremony is actually completed when the user enters the PIN on the target device.
            case DevicePairingKinds.DisplayPin:
            {
                var confirmationMessage = string.Format(BluetoothDisplayPINText, args.Pin);
                await DisplayMessagePanel(confirmationMessage, MessageType.OKMessage);
            }
            break;

            // A PIN may be shown on the target device and the user needs to enter the matching PIN on the originating device.
            case DevicePairingKinds.ProvidePin:
            {
                _inProgressPairButton.Flyout = _savedPairButtonFlyout;
                _inProgressPairButton.Flyout.ShowAt(_inProgressPairButton);
            }
            break;

            // We show the PIN here and the user responds with whether the PIN matches what is displayed on the target device.
            case DevicePairingKinds.ConfirmPinMatch:
            {
                var confirmationMessage = string.Format(BluetoothConfirmPINMatchText, args.Pin);
                if (await DisplayMessagePanel(confirmationMessage, MessageType.YesNoMessage))
                {
                    AcceptPairing();
                }
            }
            break;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Accept the current pairing using the PIN parameter and complete the deferral
        /// </summary>
        /// <param name="PIN"></param>
        private void AcceptPairingWithPIN(string PIN)
        {
            if (_pairingRequestedArgs != null)
            {
                _pairingRequestedArgs.Accept(PIN);
                _pairingRequestedArgs = null;
            }

            CompleteDeferral();
        }
Ejemplo n.º 8
0
        private async void OnPairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
        {
            switch (args.PairingKind)
            {
            case DevicePairingKinds.ConfirmOnly:
                // Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile
                // If this is an App for 'Windows IoT Core' where there is no Windows Consent UX, you may want to provide your own confirmation.
                args.Accept();
                break;

            case DevicePairingKinds.DisplayPin:
                // We just show the PIN on this side. The ceremony is actually completed when the user enters the PIN
                // on the target device. We automatically except here since we can't really "cancel" the operation
                // from this side.
                args.Accept();

                // No need for a deferral since we don't need any decision from the user
                Debug.WriteLine("Please enter this PIN on the device you are pairing with: {0}", args.Pin);
                break;

            case DevicePairingKinds.ProvidePin:
                // A PIN may be shown on the target device and the user needs to enter the matching PIN on
                // this Windows device. Get a deferral so we can perform the async request to the user.
                var collectPinDeferral = args.GetDeferral();

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    // NOT IMPLEMENTED - Make ASYNC
                    // GET PIN FROM USER

                    collectPinDeferral.Complete();
                });

                break;

            case DevicePairingKinds.ConfirmPinMatch:
                // We show the PIN here and the user responds with whether the PIN matches what they see
                // on the target device. Response comes back and we set it on the PinComparePairingRequestedData
                // then complete the deferral.
                var displayMessageDeferral = args.GetDeferral();

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    // NOT IMPLEMENTED - Make ASYNC
                    // CONFIRM PIN MATCH

                    displayMessageDeferral.Complete();
                });

                break;
            }
        }
        private void OnPairRequestedAsyncCallback(
            DeviceInformationCustomPairing sender,
            DevicePairingRequestedEventArgs args)
        {
            this.log.Info("OnPairRequested", () => string.Format("Paring kind {0}", args.PairingKind.ToString()));

            BT_PairInfoRequest pairInfo = new BT_PairInfoRequest();

            pairInfo.DeviceName = args.DeviceInformation.Name;

            switch (args.PairingKind)
            {
            case DevicePairingKinds.ConfirmOnly:
                // Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile
                // If this is an App for 'Windows IoT Core' or a Desktop and Console application
                // where there is no Windows Consent UX, you may want to provide your own confirmation.
                args.Accept();
                break;

            case DevicePairingKinds.ProvidePin:
                // A PIN may be shown on the target device and the user needs to enter the matching PIN on
                // this Windows device. Get a deferral so we can perform the async request to the user.
                using (Windows.Foundation.Deferral collectPinDeferral = args.GetDeferral()) {
                    pairInfo.PinRequested = true;
                    if (this.BT_PairInfoRequested != null)
                    {
                        this.BT_PairInfoRequested(this, pairInfo);
                    }
                    else
                    {
                        this.log.Error(9999, "No subscriber to pin request");
                    }

                    this.log.Info("OnPairRequested",
                                  () => string.Format("Pin '{0}' Response:{1}",
                                                      pairInfo.Pin, pairInfo.Response));

                    if (pairInfo.Response)
                    {
                        // TODO Check for the result to see if you go ahead
                    }

                    if (!string.IsNullOrEmpty(pairInfo.Pin))
                    {
                        args.Accept(pairInfo.Pin);
                    }
                    // TODO - needs to be disposed
                    collectPinDeferral.Complete();
                };
                break;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Accept the pairing and complete the deferral
        /// </summary>
        public void AcceptPairing()
        {
            LogService.Write("Bluetooth Pairing Accepted", LoggingLevel.Information);
            TelemetryService.WriteEvent("BluetoothDevicePaired");

            if (_pairingRequestedArgs != null)
            {
                _pairingRequestedArgs.Accept();
                _pairingRequestedArgs = null;
            }

            CompleteDeferral();
        }
Ejemplo n.º 11
0
 private void Custom_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     if (args.PairingKind == DevicePairingKinds.ProvidePin)
     {
         // add reference: Microsoft.VisualBasic.dll
         string result = Microsoft.VisualBasic.Interaction.InputBox("Pin?", "Pairing...", "");
         if (string.IsNullOrEmpty(result) == false)
         {
             args.Accept(result);
         }
     }
     else
     {
         args.Accept();
     }
 }
Ejemplo n.º 12
0
        private void PairingRequestedHandler(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs arguments)
        {
            switch (arguments.PairingKind)
            {
            case DevicePairingKinds.ConfirmOnly:
                arguments.Accept();
                break;

            case DevicePairingKinds.ProvidePin:
                var    collectPinDeferral = arguments.GetDeferral();
                string pin = "000000";
                arguments.Accept(pin);
                collectPinDeferral.Complete();
                break;
            }
        }
Ejemplo n.º 13
0
 private void CustomPairing_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     Logger.Log($"Accepting pairing request with PIN: {args.Pin}.");
     args.Accept();
 }
Ejemplo n.º 14
0
        private async void CustomPairInfo_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
        {
            Deferral PairDeferral = args.GetDeferral();

            switch (args.PairingKind)
            {
            case DevicePairingKinds.ConfirmPinMatch:
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Tips.Text             = "请确认PIN码与配对设备一致\r" + args.Pin;
                        Tips.Visibility       = Visibility.Visible;
                        PinConfirm.Visibility = Visibility.Visible;
                        PinRefuse.Visibility  = Visibility.Visible;
                    });

                break;
            }

            case DevicePairingKinds.ConfirmOnly:
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Tips.Text             = "请确认是否与配对设备配对";
                        Tips.Visibility       = Visibility.Visible;
                        PinConfirm.Visibility = Visibility.Visible;
                        PinRefuse.Visibility  = Visibility.Visible;
                    });

                break;
            }
            }
            await Task.Run(() =>
            {
                PinLock.WaitOne();

                if (IsPinConfirm)
                {
                    args.Accept();
                }
            });

            PairDeferral.Complete();
        }
        private async void PairingRequestedHandler(
            DeviceInformationCustomPairing sender,
            DevicePairingRequestedEventArgs args)
        {
            switch (args.PairingKind)
            {
                case DevicePairingKinds.ConfirmOnly:
                    // Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile
                    // If this is an App for 'Windows IoT Core' where there is no Windows Consent UX, you may want to provide your own confirmation.
                    args.Accept();
                    break;

                case DevicePairingKinds.DisplayPin:
                    // We just show the PIN on this side. The ceremony is actually completed when the user enters the PIN
                    // on the target device. We automatically except here since we can't really "cancel" the operation
                    // from this side.
                    args.Accept();

                    // No need for a deferral since we don't need any decision from the user
                    await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        ShowPairingPanel(
                            "Please enter this PIN on the device you are pairing with: " + args.Pin,
                            args.PairingKind);

                    });
                    break;

                case DevicePairingKinds.ProvidePin:
                    // A PIN may be shown on the target device and the user needs to enter the matching PIN on 
                    // this Windows device. Get a deferral so we can perform the async request to the user.
                    var collectPinDeferral = args.GetDeferral();

                    await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
                    {
                        string pin = await GetPinFromUserAsync();
                        if (!string.IsNullOrEmpty(pin))
                        {
                            args.Accept(pin);
                        }

                        collectPinDeferral.Complete();
                    });
                    break;

                case DevicePairingKinds.ConfirmPinMatch:
                    // We show the PIN here and the user responds with whether the PIN matches what they see
                    // on the target device. Response comes back and we set it on the PinComparePairingRequestedData
                    // then complete the deferral.
                    var displayMessageDeferral = args.GetDeferral();

                    await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
                    {
                        bool accept = await GetUserConfirmationAsync(args.Pin);
                        if (accept)
                        {
                            args.Accept();
                        }

                        displayMessageDeferral.Complete();
                    });
                    break;
            }
        }
Ejemplo n.º 16
0
        private static void PairingRequestedHandler(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args, string pin)
        {
            switch (args.PairingKind)
            {
            case DevicePairingKinds.ConfirmOnly:
                Console.WriteLine("Pairing mode: ConfirmOnly");
                args.Accept();
                return;

            case DevicePairingKinds.ProvidePin:
                Console.WriteLine("Pairing mode: ProvidePin");
                Console.WriteLine($"Pin is requested by the device. Using '{pin}' as a pin code");
                args.Accept(pin);
                return;

            case DevicePairingKinds.ConfirmPinMatch:
                Console.WriteLine("Pairing mode: ConfirmPinMatch");
                Console.WriteLine($"The device's pin code: '{args.Pin}'");
                Console.WriteLine("Waiting for the target device to accept the pairing (you probably need to follow the instructions on the target device's screen)");
                args.Accept();
                return;
            }

            Console.WriteLine($"Unexpected pairing type: {args.PairingKind}");
            throw new Exception();
        }
Ejemplo n.º 17
0
        private async void PairingRequestedHandler(
            DeviceInformationCustomPairing sender,
            DevicePairingRequestedEventArgs args)
        {
            switch (args.PairingKind)
            {
            case DevicePairingKinds.ConfirmOnly:
                // Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile
                // If this is an App for 'Windows IoT Core' where there is no Windows Consent UX, you may want to provide your own confirmation.
                args.Accept();
                break;

            case DevicePairingKinds.DisplayPin:
                // We just show the PIN on this side. The ceremony is actually completed when the user enters the PIN
                // on the target device. We automatically except here since we can't really "cancel" the operation
                // from this side.
                args.Accept();

                // No need for a deferral since we don't need any decision from the user
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    ShowPairingPanel(
                        "Please enter this PIN on the device you are pairing with: " + args.Pin,
                        args.PairingKind);
                });

                break;

            case DevicePairingKinds.ProvidePin:
                // A PIN may be shown on the target device and the user needs to enter the matching PIN on
                // this Windows device. Get a deferral so we can perform the async request to the user.
                var collectPinDeferral = args.GetDeferral();

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    string pin = await GetPinFromUserAsync();
                    if (!string.IsNullOrEmpty(pin))
                    {
                        args.Accept(pin);
                    }

                    collectPinDeferral.Complete();
                });

                break;

            case DevicePairingKinds.ConfirmPinMatch:
                // We show the PIN here and the user responds with whether the PIN matches what they see
                // on the target device. Response comes back and we set it on the PinComparePairingRequestedData
                // then complete the deferral.
                var displayMessageDeferral = args.GetDeferral();

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    bool accept = await GetUserConfirmationAsync(args.Pin);
                    if (accept)
                    {
                        args.Accept();
                    }

                    displayMessageDeferral.Complete();
                });

                break;
            }
        }
Ejemplo n.º 18
0
 private void CustomPairing_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     args.Accept("123456");
 }
Ejemplo n.º 19
0
 private static void Custom_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     args.Accept();
     //throw new NotImplementedException();
 }
Ejemplo n.º 20
0
        private async void CustomPairInfo_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
        {
            Deferral PairDeferral = args.GetDeferral();

            try
            {
                PairConfirmaion = new TaskCompletionSource <bool>();

                switch (args.PairingKind)
                {
                case DevicePairingKinds.ConfirmPinMatch:
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            Tips.Text             = $"{Globalization.GetString("BluetoothUI_Tips_Text_5")}{Environment.NewLine}{args.Pin}";
                            Tips.Visibility       = Visibility.Visible;
                            PinConfirm.Visibility = Visibility.Visible;
                            PinRefuse.Visibility  = Visibility.Visible;
                        });

                    if (await PairConfirmaion.Task)
                    {
                        args.Accept(args.Pin);
                    }

                    break;
                }

                case DevicePairingKinds.ConfirmOnly:
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            Tips.Text             = Globalization.GetString("BluetoothUI_Tips_Text_6");
                            Tips.Visibility       = Visibility.Visible;
                            PinConfirm.Visibility = Visibility.Visible;
                            PinRefuse.Visibility  = Visibility.Visible;
                        });

                    if (await PairConfirmaion.Task)
                    {
                        args.Accept();
                    }

                    break;
                }
                }
            }
            catch (Exception ex)
            {
                LogTracer.Log(ex, $"An exception was threw in {nameof(CustomPairInfo_PairingRequested)}, pair with bluetooth failed");
            }
            finally
            {
                PairDeferral.Complete();
            }
        }
Ejemplo n.º 21
0
        private async void CustomPairInfo_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
        {
            Deferral PairDeferral = args.GetDeferral();

            switch (args.PairingKind)
            {
            case DevicePairingKinds.ConfirmPinMatch:
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Tips.Text             = $"{Globalization.GetString("BluetoothUI_Tips_Text_5")}{Environment.NewLine}{args.Pin}";
                        Tips.Visibility       = Visibility.Visible;
                        PinConfirm.Visibility = Visibility.Visible;
                        PinRefuse.Visibility  = Visibility.Visible;
                    });

                break;
            }

            case DevicePairingKinds.ConfirmOnly:
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Tips.Text             = Globalization.GetString("BluetoothUI_Tips_Text_6");
                        Tips.Visibility       = Visibility.Visible;
                        PinConfirm.Visibility = Visibility.Visible;
                        PinRefuse.Visibility  = Visibility.Visible;
                    });

                break;
            }
            }
            await Task.Run(() =>
            {
                PinLock.WaitOne();

                if (IsPinConfirm)
                {
                    args.Accept();
                }
            }).ConfigureAwait(false);

            PairDeferral.Complete();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Called when custom pairing is initiated so that we can handle the custom ceremony
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void PairingRequestedHandler(
            DeviceInformationCustomPairing sender,
            DevicePairingRequestedEventArgs args)
        {
            // Save the args for use in ProvidePin case
            pairingRequestedHandlerArgs = args;

            // Save the deferral away and complete it where necessary.
            if (args.PairingKind != DevicePairingKinds.DisplayPin)
            {
                deferral = args.GetDeferral();
            }

            string confirmationMessage;

            switch (args.PairingKind)
            {
                case DevicePairingKinds.ConfirmOnly:
                    // Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile
                    // If this is an App for Athens where there is no Windows Consent UX, you may want to provide your own confirmation.
                    {
                        confirmationMessage = string.Format(bluetoothConfirmOnlyFormatString, args.DeviceInformation.Name, args.DeviceInformation.Id);
                        DisplayMessagePanel(confirmationMessage, MessageType.InformationalMessage);
                        // Accept the pairing which also completes the deferral
                        AcceptPairing();
                    }
                    break;

                case DevicePairingKinds.DisplayPin:
                    // We just show the PIN on this side. The ceremony is actually completed when the user enters the PIN
                    // on the target device
                    {
                        confirmationMessage = string.Format(bluetoothDisplayPinFormatString, args.Pin);
                        DisplayMessagePanel(confirmationMessage, MessageType.OKMessage);
                    }
                    break;

                case DevicePairingKinds.ProvidePin:
                    // A PIN may be shown on the target device and the user needs to enter the matching PIN on 
                    // this Windows device.
                    await MainPage.Current.UIThreadDispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        // PIN Entry
                        inProgressPairButton.Flyout = savedPairButtonFlyout;
                        inProgressPairButton.Flyout.ShowAt(inProgressPairButton);
                    });
                    break;

                case DevicePairingKinds.ConfirmPinMatch:
                    // We show the PIN here and the user responds with whether the PIN matches what they see
                    // on the target device. Response comes back and we set it on the PinComparePairingRequestedData
                    // then complete the deferral.
                    {
                        confirmationMessage = string.Format(bluetoothConfirmPinMatchFormatString, args.Pin);
                        DisplayMessagePanel(confirmationMessage, MessageType.YesNoMessage);
                    }
                    break;
            }
        }
 private void OnPairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     Utils.HandlePairing(Dispatcher, args);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// ペアリング要求時のハンドラ
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private static void PairingRequestedHandler(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     switch (args.PairingKind)
     {
     case DevicePairingKinds.ConfirmOnly:
         args.Accept();
         break;
     }
 }
 private static void OnPairingRequested(DeviceInformationCustomPairing pairing, DevicePairingRequestedEventArgs args)
 {
     args.Accept("0");
 }
 private void OnPairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     Utils.HandlePairing(Dispatcher, args);
 }
Ejemplo n.º 27
0
 private static void Custom_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     sender.PairingRequested -= Custom_PairingRequested;
     args.Accept(pinMappings[args.DeviceInformation.Id]);
     pinMappings.Remove(args.DeviceInformation.Id);
 }
Ejemplo n.º 28
0
 private async void PairingRequestedHandler(
     DeviceInformationCustomPairing sender,
     DevicePairingRequestedEventArgs args)
 {
     await PairingRequestedHandler2(args, args.PairingKind);
 }
Ejemplo n.º 29
0
 private void PairingRequestedHandler(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
 {
     args.Accept();
 }
Ejemplo n.º 30
0
 private void CustomOnPairingRequested(DeviceInformationCustomPairing sender,
                                       DevicePairingRequestedEventArgs args)
 {
     args.Accept(_pairingCode);
 }