Closed tthiery closed 4 years ago
BLE advertisment does not include a name field. The device actually has it. Query device during discovery
Actually, the advertisement data does include "Local Name" in the scan response data.
Thanks for noticing. I also looked into it. The LocalName was empty for me. I will have a second look into it. Maybe I need to adjust the watcher or something else so the field gets populated.
It use the ShortName.
@tthiery take a look here: https://github.com/tessel/bleadvertise
There are two different advertisements, one with the ScanResponse
flag set and one without (https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.advertisement.bluetoothleadvertisementtype?view=winrt-19041). I forget the terminology, but I think you have to do something like an "active" scan to get the scan response type data.
After reading, testing etc ... I came to a surprising end ;)
So WinRT API is a bit ... strange.
watcher.ScanningMode = BluetoothLEScanningMode.Active;
.LocalName
would need to be in a data section with DataType 8 (shortened) or 9 (complete). However, the TechnicMediumHub only returns 1 (Flags), 7 (CompleteService128BitUuids) and 255 (ManufacturerSpecificData). I actually do not receive any ScanResponse flagged advertisment not alone with that ;)using (var device = BluetoothLEDevice.FromBluetoothAddressAsync(eventArgs.BluetoothAddress).AsTask().Result)
{
info.Name = device.Name;
}
... which is literally what I did before the complete excurse. According to the docs this should not even create a connection.
Strange is only: How does Windows know the name? Maybe it cuts the the data sections.
I let this open for another day or two ... some more experiments ... but i may let it settle like that.
Close it for now. Have tried it again but could not achieve more.
By BLE advertisment name
Lessons Learnt from #49