Microsoft's SDK Bluetooth LE sample works on some machines but not others

CB 46 Reputation points
2020-09-18T12:38:23.05+00:00

I tried asking this question on the Github page but the MS employee who wrote it sent me here.

I have a very very common Bluetooth-LE UART module. Using the Microsoft Windows SDK UWP, BluetoothLE app, I can successfully Pair, Connect, Subscribe to a Characteristic, and exchange data both ways. On THIS PC. I installed the same app on a Microsoft Surface Pro (6 I think), and several other machines, the software Pairs, but cannot Connect. It reports "Device Unavailable".

As a developer, I need to know why this is and what to do about it. Right? That's why I am here. Why do some machines connect, while others (fully patched to date) do not. I can point to the exact line of code where it chokes.

This is where the SDK is a black box; what goes on inside those BLE libraries is a mystery.

The device in question is working fine with the manufacturer supplied Droid and IOS app. So its not the parts. Its what Windows is doing to connect and how to fix it.

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. CB 46 Reputation points
    2020-09-21T13:19:06.97+00:00

    RoyLi, I ran the busiotool commands shown in the Readme.md on both machines, but I dont know where it saves the logs. Let me know and I will include them.

    Thanks for the help.

    All test PCs are running updated Windows 10 Pro, 2004, 19041.508

    Bluetooth level on Test PCs:
    Intel HCI 9.265/LMP 9.256 - Falcon NW Initial app development PC(works)
    Marvel Avastar HCI 8.33536/LMP 8.37138 -- Surface Pro 6 fails
    Belkin 4.0 adapter LMP 7.xxx - OriginPC (works)
    Qualcomm QCA9565 HCI 6.12545/ LMP6.1 - Dell sometimes yes, sometimes no

    Application code is from Windows-universal-samples-master archive: BluetoothLE

    Device under test: Microchip RN4870, a transparent UART.
    https://www.microchip.com/wwwproducts/en/RN4870
    Latest firmware 1.4 installed, BT 5 Certified device. I have several of them to test, but they all act similarly.

    BluetoothLE App - All machines Enumerate and Pair successfully.
    The result of the next step, Connect, varies, or is inconsistent.

    This occurs in Scenario2_Client.xaml.cs, Line 130
    GattDeviceServicesResult result = await bluetoothLeDevice.GetGattServicesAsync(BluetoothCacheMode.Uncached);

    In a good system the result = Success, in a bad Device_Unreachable. I have been trying to zero in on what might be the cause (as I need to deploy my app to a Surface eventually).
    To reach that line it means the bluetoothLeDevice = await BluetoothLEDevice.FromIdAsync(SelectedBleDeviceId); result is not Null. It sees the device.

    Just a Theory:
    IsConnectable - an object called DeviceWatcher updates a list of BT devices. I noticed that the variable IsConnectable flickers true/false in the RN4870 entry. I am wondering if that state or timeout might be why the device is choppy or doesn’t lock in the response.

    I have tried to hack at the example and was, at least in one attempt able to get the Surface to connect. So its not dead.. its just not working in the app as given on several systems. I have not figured out a solid work around to force it. I was not able to tie the issue into bluetooth revision level of the modems. Worked on an earlier, worked on a later, swapping fobs did not cure the issue for the surface.
    ![26090-a.png][1]


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.