1

edit

it's A known problem with some microsoft security issue https://social.msdn.microsoft.com/Forums/en-US/58da3fdb-a0e1-4161-8af3-778b6839f4e1/bluetooth-bluetoothledevicefromidasync-does-not-complete-on-10015063?forum=wdk

adding registery CoInitializeSecurity values as mentioned fixed the problem!

i'm trying to read A BLE device services using An Advertisment watcher. i've implemnted the service read inside the listenter, the Code:

   private async void OnAdvertisementReceived(BluetoothLEAdvertisementWatcher watcher, BluetoothLEAdvertisementReceivedEventArgs args)
    {

        if (!gotSignal)
        {
            gotSignal = true;
            device = await Windows.Devices.Bluetooth.BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress);
            service = await GattDeviceService.FromIdAsync(device.DeviceId);

        }
          ...
     }

the problem is that I can't get the BluetoothLEDevice object, when I reach this line, it is not getting back any value and it skips the next lines inside the listener. NOTE: I've installed windows creators update and before the installation, the function BluetoothLEDevice.FromBluetoothAddressAsync has worked.

Michael Gabbay
  • 413
  • 1
  • 4
  • 20
  • I asked a similar question yesterday: http://stackoverflow.com/q/43568096/3187714 Are you running as desktop/exe program or a UWP application? For me, this code works as a UWP app but not as a desktop exe. – JFar Apr 23 '17 at 13:01
  • I am running A desktop program too. – Michael Gabbay Apr 23 '17 at 13:06
  • I guess you need to pair the device first – Emil Apr 23 '17 at 15:16
  • I know, I'm intersted on getting the device services without pairing. – Michael Gabbay Apr 23 '17 at 15:23
  • The new Creators no pairing code also works fine in a UWP app. I too am interested in not having to pair with a windows desktop program. I updated my similar question because after a bit more research, I found my problem is the same as yours -- FromBluetoothAddressAsync never seems to return. – JFar Apr 23 '17 at 19:13
  • I did find if I added the optional second argument BluetoothAddressType.Public to FromBluetoothAddressAsync, the function returns, but unfortunately the return device is null... BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress, BluetoothAddressType.Public); – JFar Apr 23 '17 at 19:22
  • Thanks i'll try do something with the second argument – Michael Gabbay Apr 30 '17 at 07:59

1 Answers1

1

Solution

it's A known problem with some microsoft security issue https://social.msdn.microsoft.com/Forums/en-US/58da3fdb-a0e1-4161-8af3-778b6839f4e1/bluetooth-bluetoothledevicefromidasync-does-not-complete-on-10015063?forum=wdk

adding registery CoInitializeSecurity values as mentioned fixed the problem!

Michael Gabbay
  • 413
  • 1
  • 4
  • 20