afauch / BluetoothWatcher

2 stars 0 forks source link

BluetoothLEDevice.DeviceId is different format when running on Desktop vs. HoloLens #1

Open afauch opened 6 years ago

afauch commented 6 years ago

When running on Desktop (resulting in successful data stream):

About to loop through.
Searching for BLE device for \\?\BTHLE#Dev_ff48d5ef1cc8#7&31040fb9&0&ff48d5ef1cc8#{781aee18-7733-4ce4-add0-91f41c67b592}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-ff:48:d5:ef:1c:c8
Searching for BLE device for \\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_ff48d5ef1cc8#8&3d7b3d&0&0001#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-ff:48:d5:ef:1c:c8
Searching for BLE device for \\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_ff48d5ef1cc8#8&3d7b3d&0&0001#{00001800-0000-1000-8000-00805f9b34fb}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-ff:48:d5:ef:1c:c8
Searching for BLE device for \\?\BTHLE#Dev_f0f6606afcde#7&31040fb9&0&f0f6606afcde#{781aee18-7733-4ce4-add0-91f41c67b592}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-f0:f6:60:6a:fc:de
yes, we have found our one true device
Searching for BLE device for \\?\BTHLEDevice#{00001801-0000-1000-8000-00805f9b34fb}_ff48d5ef1cc8#8&3d7b3d&0&0008#{00001801-0000-1000-8000-00805f9b34fb}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-ff:48:d5:ef:1c:c8
Searching for BLE device for \\?\BTHLEDevice#{00001801-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&307dd5da&8&0008#{00001801-0000-1000-8000-00805f9b34fb}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-f0:f6:60:6a:fc:de
yes, we have found our one true device
Searching for BLE device for \\?\BTHLE#Dev_ff48d5ef1cc8#7&31040fb9&0&ff48d5ef1cc8#{80795c47-03f0-446d-b1f2-e424b30db4da}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-ff:48:d5:ef:1c:c8
Searching for BLE device for \\?\BTHLEDevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_f0f6606afcde#8&307dd5da&8&000c#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-f0:f6:60:6a:fc:de
yes, we have found our one true device
Searching for BLE device for \\?\BTHLEDevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_f0f6606afcde#8&307dd5da&8&000c#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-f0:f6:60:6a:fc:de
yes, we have found our one true device
Searching for BLE device for \\?\BTHLE#Dev_f0f6606afcde#7&31040fb9&0&f0f6606afcde#{80795c47-03f0-446d-b1f2-e424b30db4da}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-f0:f6:60:6a:fc:de
yes, we have found our one true device
Searching for BLE device for \\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&307dd5da&8&0001#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-f0:f6:60:6a:fc:de
yes, we have found our one true device
Searching for BLE device for \\?\SWD#DAFWSDProvider#urn:uuid:564e4238-4a34-5737-3138-a08cfd129749#{b04bb22a-5c2b-4739-8362-5491665cfca2}\WSD Device Interface
Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.ni.dll
WinRT information: The provided device ID is not a valid BluetoothLEDevice object.
No BluetoothLEDevice Found for DeviceInformation \\?\SWD#DAFWSDProvider#urn:uuid:564e4238-4a34-5737-3138-a08cfd129749#{b04bb22a-5c2b-4739-8362-5491665cfca2}\WSD Device Interface
Searching for BLE device for \\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&307dd5da&8&0001#{00001800-0000-1000-8000-00805f9b34fb}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-f0:f6:60:6a:fc:de
yes, we have found our one true device
Searching for BLE device for \\?\BTHLEDevice#{00001801-0000-1000-8000-00805f9b34fb}_ff48d5ef1cc8#8&3d7b3d&0&0008#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-ff:48:d5:ef:1c:c8
Searching for BLE device for \\?\BTHLEDevice#{00001801-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&307dd5da&8&0008#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Found Bluetooth Device: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-f0:f6:60:6a:fc:de
yes, we have found our one true device
Size of set: 2
Found Device? True

When looping through on Hololens:

About to loop through.
Searching for BLE device for \\?\BTHLE#Dev_f0f6606afcde#7&1c9e24b3&0&f0f6606afcde#{781aee18-7733-4ce4-add0-91f41c67b592}
Found Bluetooth Device: \\?\BTHLE#Dev_f0f6606afcde#7&1c9e24b3&0&f0f6606afcde#{781aee18-7733-4ce4-add0-91f41c67b592}
Searching for BLE device for \\?\BTHLEDevice#{00001801-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&172376d9&7&0008#{00001801-0000-1000-8000-00805f9b34fb}
Exception thrown: 'System.Exception' in System.Private.CoreLib.ni.dll
No BluetoothLEDevice Found for DeviceInformation \\?\BTHLEDevice#{00001801-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&172376d9&7&0008#{00001801-0000-1000-8000-00805f9b34fb}
Searching for BLE device for \\?\BTHLEDevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_f0f6606afcde#8&172376d9&7&000c#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}
Exception thrown: 'System.Exception' in System.Private.CoreLib.ni.dll
No BluetoothLEDevice Found for DeviceInformation \\?\BTHLEDevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_f0f6606afcde#8&172376d9&7&000c#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}
Searching for BLE device for \\?\BTHLEDevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_f0f6606afcde#8&172376d9&7&000c#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Found Bluetooth Device: \\?\BTHLEDevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_f0f6606afcde#8&172376d9&7&000c#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Searching for BLE device for \\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&172376d9&7&0001#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Found Bluetooth Device: \\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&172376d9&7&0001#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Searching for BLE device for \\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&172376d9&7&0001#{00001800-0000-1000-8000-00805f9b34fb}
Exception thrown: 'System.Exception' in System.Private.CoreLib.ni.dll
No BluetoothLEDevice Found for DeviceInformation \\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&172376d9&7&0001#{00001800-0000-1000-8000-00805f9b34fb}
Searching for BLE device for \\?\BTHLEDevice#{00001801-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&172376d9&7&0008#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Found Bluetooth Device: \\?\BTHLEDevice#{00001801-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&172376d9&7&0008#{6e3bb679-4372-40c8-9eaa-4509df260cd8}
Size of set: 4
Found Device? False

Key difference:

Desktop BluetoothLEDevice.DeviceID format: BluetoothLE#BluetoothLE44:85:00:a0:7f:e3-f0:f6:60:6a:fc:de

HoloLens BluetoothLEDevice.DeviceID format: \\?\BTHLEDevice#{00001801-0000-1000-8000-00805f9b34fb}_f0f6606afcde#8&172376d9&7&0008#{6e3bb679-4372-40c8-9eaa-4509df260cd8}

afauch commented 6 years ago

Note: This is when running the same exact code.

We were able to workaround by providing additional logic to search for the MAC address in multiple formats; yet, the HoloLens is still facing unique connection/reading issues even after the device has been selected.

afauch commented 6 years ago

The Windows IoT Core Version might have something to do with this?

https://stackoverflow.com/questions/43622548/cant-get-gatt-characteristics-c-sharp-unable-to-cast-bluetoothledevice-to-iblue?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa