2

Since i'm currently working with automated testing of windows devices I need to test bluetooth capability of DUT (Device under test), using built-in libraries from Windows 10 (build 10536), because devices are factory reset before testing. For testing I made custom UWP app to test different aspects of device. Now I'm messing with bluetooth. For testing purposes i have n-amount of bluetooth (rfComm) devices and device needs to automatically connect to selected bluetooth device (sent from different device, this part is already developed). No I need to make part which upon request from TCP, an app scans for unpaired devices and pairs with certain one (given with ID).

Scan result is collected in observablecollection.

My current try on pairing with device:

 public async Task<int> PairWithSelectedAsync(string SSIDToPairWith)
    {
        int returnvalue = 0;
        foreach (RfcommChatDeviceDisplay rfcommInfoDisp in ResultCollection)
        {
            if (rfcommInfoDisp.Id == SSIDToPairWith)
            {
                Debug.WriteLine("Found device to connect to");
                Debug.WriteLine(rfcommInfoDisp.Name);
                Debug.WriteLine(rfcommInfoDisp.Id);
                if(rfcommInfoDisp.DeviceInformation.Pairing.CanPair == true)
                {
                    //rfcommInfoDisp.DeviceInformation.Properties.
                    DevicePairingResult pairingResult= await rfcommInfoDisp.DeviceInformation.Pairing.PairAsync();
                    if(pairingResult.Status == 0)
                    {
                        Debug.WriteLine("Connected");
                        returnvalue = 0;
                    }
                    else
                    {
                        returnvalue = (int)pairingResult.Status;

                    }
                }
                //Debug.WriteLine("\n");
            }
        }
        return returnvalue;
    }

Now current problem is: This kind of pairing requires user prompt to continue: popup appears on screen and operator needs to tap it. Is it possible to modify current code in a way it doesn't need prompt to pair with device?

I also looked this thread but it seems this solution doesn't work with "stock" library: Pairing with 32feetnet Also This topic seems to be dead end without anyone finding answer from there. Any suggestion or help is appreciated.

LempsPC
  • 125
  • 1
  • 1
  • 9
  • You must disable authentication agent. Because4 of UWP limitation there is no easy way to do it in UWP. – Mike Petrichenko Oct 26 '18 at 15:48
  • @MikePetrichenko What is Authentication agent in windows 10? Where is it located? How can this be disabled, can it be done in powershell before launching UWP app? – LempsPC Oct 29 '18 at 08:29
  • 1
    Authentication agent is a part of BTTray app. It handles Authentication (pairing) requests and shows a popup dialog to pair device. It can be probabl;y disable with powershell. – Mike Petrichenko Oct 29 '18 at 09:52
  • Any news on that @LempsPC ? – Persike Mar 24 '20 at 15:20

0 Answers0