-
Notifications
You must be signed in to change notification settings - Fork 108
feat: Add service data filtering support for BLE scanning across all platforms #777
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
base: main
Are you sure you want to change the base?
feat: Add service data filtering support for BLE scanning across all platforms #777
Conversation
- Add `serviceData` option and `ServiceDataFilter` docs to README (serviceUuid, dataPrefix, mask; mention OpenDroneID) - Remove rollup invocation from npm build script in package.json (use docgen + tsc only)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few very minors, but this looks in good shape to me.
Apologies for the delayed review, and thanks for your patience and contribution!
| "esModuleInterop": true, | ||
| "inlineSources": true, | ||
| "lib": ["dom", "es2017"], | ||
| "lib": ["dom", "es2018"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the changes to this file mandatory? I can't see any new browser APIs being used in the code you've added...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change to es2018 is required because the code uses Promise.prototype.finally() in src/timeout.ts:8. This method was introduced in ES2018/ES2019 spec.
Without this change, the TypeScript compiler throws
'error TS2550: Property 'finally' does not exist on type 'Promise'.
Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later.'
The finally() method is used in the timeout utility to ensure cleanup (clearing the timeout) happens regardless of whether the promise resolves or rejects. This is the only ES2018 feature being used, but it's essential for the proper cleanup logic.
… add rollup to build script
Pull Request: Add Service Data Filtering Support
Pull Request Title
Pull Request Description
📋 Summary
Adds comprehensive service data filtering capability to
requestLEScanandrequestDevicemethods, enabling filtering of BLE advertisements based on service-specific data payloads. This is particularly useful for protocols like OpenDroneID that use service data for device identification.🎯 Motivation
Previously, the plugin only supported filtering by:
Many BLE protocols (e.g., OpenDroneID) use service data fields in advertisement packets for identification and filtering. This PR adds native support for service data filtering across all platforms.
✨ Changes
TypeScript/Web (
src)ServiceDataFilterinterface withserviceUuid,dataPrefix, andmaskpropertiesRequestBleDeviceOptionsto include optionalserviceDataparameterBluetoothLeWeb.tsmatchesServiceDataFilter()method for advertisement filteringiOS (
ios/Plugin)ServiceDataFilterstruct inPlugin.swiftgetServiceDataFilters()method to parse filter optionspassesServiceDataFilter()method inDeviceManager.swiftfor filtering logicrequestDeviceandrequestLEScanto accept and apply service data filtersAndroid (
android/src/main/java/.../bluetoothle/)getScanFilters()inBluetoothLe.ktto handle service data filtersScanFilter.Builder().setServiceData()for hardware-level filtering📚 Usage Example
🧪 Testing
ScanFilter.setServiceData()📱 Platform Support
ScanFilter.setServiceData()passesServiceDataFilter()matchesServiceDataFilter()🔧 API Compatibility
serviceDatais optional📖 Related Issues
Closes #XXX (if applicable)
✅ Checklist