kenjdavidson / react-native-bluetooth-classic

⚛ Bluetooth classic Android(Bluetooth)/IOS(ExternalAccessory) module for serial communication
https://kenjdavidson.github.io/react-native-bluetooth-classic
MIT License
249 stars 93 forks source link

onDeviceDiscovered Duplicated Devices #249

Closed ValentinOsvaldo closed 1 year ago

ValentinOsvaldo commented 1 year ago

Hello

I have an issue with the onDeviceDiscovered method, it brings duplicated devices. So, looking at the code and reading, I found an issue where it had already been answered, so I wanted to suggest if the device list could be a set to avoid duplicates. Something like this:

private Set<NativeDevice> mDiscoveredDevices = new HashSet<>();

I hope this can solve the issue in some way without causing any major problems, since Java is not my forte.

kenjdavidson commented 1 year ago

The issue with this is that each entry has different strength values, so I left it in there to allow for client apps 5o choose what to do with duplicates, which is how I'd prefer it. There aren't that many, so it's not like it's a major performance hit, and give the power to the caller.

It should be easy enough for you to set them based on your own rules in Javascript.