capacitor-community / bluetooth-le

Capacitor plugin for Bluetooth Low Energy
MIT License
281 stars 85 forks source link

iOS supports requestLEScan without service filter, but the plugin prevents it #582

Closed Maximvdw closed 11 months ago

Maximvdw commented 1 year ago

iOS supports the scanning of BLE devices without specifying a service list. This requires the service list to be nil: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518986-scanforperipherals#discussion

However, on this line: https://github.com/capacitor-community/bluetooth-le/blob/main/ios/Plugin/Plugin.swift#L509 an empty array is used when no services are provided in the call, preventing any possibility to get nil.

Since an empty array would not do anything, I propose to return nil in the aforementioned getServiceUUIDs method. ~If developers still want the scanning of an empty array for some reason, they can just pass it along.~

EDIT: After reading up on it, there does not seem to be a valid reason to 'scan' for an empty list, as this would not start a scan

pwespi commented 1 year ago

EDIT: After reading up on it, there does not seem to be a valid reason to 'scan' for an empty list, as this would not start a scan

Where did you read this? In my tests, whether services is nil or an empty array doesn't matter and I obtain the same scan results.

github-actions[bot] commented 11 months ago

It looks like this issue didn't get the information it needed, so I'll close it for now. If I made a mistake, sorry! I am just a bot.

Have a great day! Capacitor Community Bot 💙