Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find Hub by Name #59

Closed
tthiery opened this issue Jul 14, 2020 · 8 comments
Closed

Find Hub by Name #59

tthiery opened this issue Jul 14, 2020 · 8 comments
Labels
area-bt-winrt enhancement New feature or request
Milestone

Comments

@tthiery
Copy link
Member

tthiery commented Jul 14, 2020

By BLE advertisment name

Lessons Learnt from #49

@tthiery tthiery added the enhancement New feature or request label Jul 14, 2020
@tthiery tthiery added this to the v2.1 milestone Jul 14, 2020
tthiery added a commit that referenced this issue Jul 22, 2020
- Add example
- Query device during discovery to detect name

#59
@tthiery
Copy link
Member Author

tthiery commented Jul 22, 2020

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

@tthiery tthiery closed this as completed Jul 22, 2020
@dlech
Copy link

dlech commented Jul 22, 2020

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

@tthiery
Copy link
Member Author

tthiery commented Jul 23, 2020

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.

@tthiery tthiery reopened this Jul 23, 2020
@GianCann
Copy link

It use the ShortName.

@GianCann
Copy link

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

@dlech
Copy link

dlech commented Jul 23, 2020

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
Copy link
Member Author

tthiery commented Jul 23, 2020

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

So WinRT API is a bit ... strange.

  • I was actually actively scanning for advertisments watcher.ScanningMode = BluetoothLEScanningMode.Active;.
  • The advertisment 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 ;)
  • Then I was trying to install a watcher for the device from the windows internal registry of devices (unrelated to BT itself). That was painful and I failed doing it. I am not alone with that ;). I know it somehow works .. but it is late.
  • Then I looked it from a different perspective: If Windows has a device (and it has it) representing my hub, why I cannot retrieve it by a method using the Bluetooth Address. This again lead to the following code ...
    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.

@tthiery
Copy link
Member Author

tthiery commented Jul 27, 2020

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

@tthiery tthiery closed this as completed Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-bt-winrt enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants