BluetoothDevice::FromIdAsync() failure with E_INVALIDARG (0x80070057) RRS feed

  • Question

  • I have a code that enumerates Bluetooth device using Windows.Devices.Enumeration.DeviceWatcher, and obtain the Windows.Devices.Bluetooth.BluetoothDevice object using BluetoothDevice.FromIdAsync() method.  The actual code looks like the following (in cppwinrt)

    DeviceWatcher watcher = DeviceInformation::CreateWatcher(BluetoothDevice::GetDeviceSelector());
    watcher.Added([](const DeviceWatcher&, const DeviceInformation& devInfo) {
        hstring name = devInfo.Name();
        hstring id = devInfo.Id();
        BluetoothDevice bthDev = BluetoothDevice::FromIdAsync(id).get();

    I think this is a very common sequence for enumerating Bluetooth devices with WinRT.

    This piece of the code works fine for most of the cases (>95%), but I occasionally see BluetoothDevice::FromIdAsync() to fail with E_INVALIDARG (0x80070057).  At first, I suspected this error happens when the device is just paired or connected.  But, it was not the case.  This error occurred with the devices that have been paired, connected and operational for some time.

    Has anyone seen this problem?  And, if so, what's causing this problem, and is there a way to get BluetoothDevice object for such device?

    Monday, September 17, 2018 5:56 PM