sharpbrick / powered-up

.NET implementation of the LEGO PoweredUp Protocol
MIT License
100 stars 19 forks source link

Find Hub by Name #59

Closed tthiery closed 4 years ago

tthiery commented 4 years ago

By BLE advertisment name

Lessons Learnt from #49

tthiery commented 4 years ago

BLE advertisment does not include a name field. The device actually has it. Query device during discovery

dlech commented 4 years ago

Actually, the advertisement data does include "Local Name" in the scan response data.

tthiery commented 4 years ago

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.

GianCann commented 4 years ago

It use the ShortName.

GianCann commented 4 years ago

@tthiery take a look here: https://github.com/tessel/bleadvertise

dlech commented 4 years ago

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.

tthiery commented 4 years ago

After reading, testing etc ... I came to a surprising end ;)

So WinRT API is a bit ... strange.

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.

tthiery commented 4 years ago

Close it for now. Have tried it again but could not achieve more.