yanshouwang / bluetooth_low_energy

A Flutter plugin for controlling the bluetooth low energy.
https://pub.dev/packages/bluetooth_low_energy
MIT License
50 stars 16 forks source link

Windows Scanner doesn't show devices names #34

Closed iBog closed 5 months ago

iBog commented 11 months ago

image

yanshouwang commented 11 months ago

This is because the peripheral's advertisement didn't contains a local name field, we use this name when discover advertisement, you can try the BluetoothLEAdvertisement sample of Microsoft, it's should have the same behavior(you should comment the watcher's filters code first) If the advertisement contains a local name field, you will see the name when run the example, you can try to run this example with an Android or iOS device which support PeripheralManager api, use the advertiser to advertise an advertisement, then run this example on Windows or other platforms, you can see the name(by default le12138) after scan. image

sampaioletti commented 8 months ago

I had this happen to me and like you mentioned the example works.

After some playing around with it, I believe there is a parsing issue. Names with non alpha-numeric characters don't show up.

Works unclebob image

doesn't work uncle bob (also tried variant uncle_bob which didn't work)

image

But all variants work on android, and on the windows 'add a device' dialog shown in the images they show up so I don't believe its a 'windows' issue.

yanshouwang commented 8 months ago

Thanks for your report, let me check the code to see how to resolve this issue.

yanshouwang commented 7 months ago

I had this happen to me and like you mentioned the example works.

After some playing around with it, I believe there is a parsing issue. Names with non alpha-numeric characters don't show up.

Works unclebob

doesn't work uncle bob (also tried variant uncle_bob which didn't work)

I tested on windows but can't reproduce this issue.

image

image

image

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 30 days with no activity.

sampaioletti commented 6 months ago

I'm still planning on looking into this further just haven't had time

yanshouwang commented 6 months ago

I'm still planning on looking into this further just haven't had time

I tested this a few days before, I believe this is a normal behaivor, you can run the Microsoft samples, it has the same behavior as this plugin.

Notice there are two ways to discover BLE devices on Windows, one way is to use the BluetoothLEAdvertisementWatcher, another way is to use the DeviceWatcher class.

The first way which this plugin used can only show the localName defined in the BLE advertisement.

The second way does show the device name but this name is not defined in the BLE advertisement, and use this way we can't get the BLE advertisement and RSSI.

PS: The first way sample from Microsoft is here. You need to comment the Advertisement filters before run this sample.

The second way sample from Microsoft is here.

yanshouwang commented 6 months ago

Good news! I have confirmed that the missed device name is included in the scan response or extended advertisement, which I ignored before, this will be fixed in the next version. Anyone can pull the 6.0.0 branch and run the example in the bluetooth_low_energy_windows to see the difference.

sampaioletti commented 6 months ago

Awesome I'll test that out...sorry I never had time to pursue. Thanks for the great lib.

yanshouwang commented 5 months ago

Fixed in 6.0.0