bluejay icon indicating copy to clipboard operation
bluejay copied to clipboard

Move blacklisting a device from scanning scan outside of scan itself

Open nbrooke opened this issue 8 years ago • 1 comments

Right now the only interface for blacklisting devices is to return a value from the scan callback. This works fine if you can determine it's not the right device from the name to advertising packet, but in the specific case I've got I need to connect to the device to read the serial number, which means stopping the scan. At that point there's no way to add the device to the blacklist for future scans, you have to keep your own list anyway. That workaround isn't complicated, but since (AFAIK), we only added the blacklisting to support that use case in this specific project, we should probably either make it fully support it, or consider remove the feature.

A reasonable solution would be to add functions to the Bluejay object to add a device to the blacklist and clear the blacklist. Those would be used as starting blacklist for scans.

There are a couple open design questions we'd need to think about here (I don't have a strong intuition on the correct solution):

  • Should the global blacklist just be modelled as a Set<PeripheralIdentifier> (though see #114 for why we can't do that right now) instead of some functions?
  • Does adding something to the global blacklist affect an in progress scan or only scans started after the device is added?
  • Does blacklisting a device via the scan callback return affect the global blacklist or just the current scan.
  • Should we tweak the interface a little to remove some of the potential inconsistencies (maybe you don't return from he scan callback to blacklist things at all, you only have the global blacklist).

nbrooke avatar Nov 08 '17 22:11 nbrooke

  • remove the 'blacklist` enum
  • persist the blacklist array
  • add public getter and setter for the blacklist array

sakuraehikaru avatar Jan 15 '19 22:01 sakuraehikaru