-
Notifications
You must be signed in to change notification settings - Fork 157
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
Addition: filter by service data UUID with mask #144
base: develop
Are you sure you want to change the base?
Addition: filter by service data UUID with mask #144
Conversation
…an one file was found with OS independent path 'README.txt'' issue on compilation.
…ceData() filter in ScanFilter class. These were based on the setServiceUuid() tests that also has a uuid mask as an optional input.
…ouches most aspects of this class. Added new setServiceData() implementations which include a mask input for the serviceDataUuid input. I opted to create new functions instead of editing the original ones so that anyone who uses the originals in their code can continue using them as is. As of right now the new tests placed in ScanFilterTest->testsetServiceDataFilter() currently FAIL - I am working on this.
…a can be retrieved for a MASKED service data uuid. This function will throw an exception if more than one UUID is picked up from the list of service UUIDs it checks - this is because we only want to return one set of data. If this occurs, this is either because there is an exact duplicate of an uuid in the list, or that the provided mask is too broad and is picking up more than one uuid. Moved matches..() functions from ScanFilter to a dedicated ScanRecordMatchers class, where all functions have been made static; this is so ScanFilter and ScanRecord can access these functions (ScanRecord, due to the addition of the new getServiceData() function now needs access to matchesServiceUuid(uuid, mask, uuids)). Some minor reindenting of test code. The changes above allow all existing and new tests pass.
…functions package-private.
…riginal library has trouble handling masks with all zeros.
…tests to fail and not because a mask of zeros did not work.
…rash if it does not exist. Added some logging to the maskable service data uuid function which grabs data for the given masked uuid, and also turned the IllegalArgumentException into an error log.
Removed original readme info and just added my changes to the library.
Randomised UUID
…t project into this forked version.
Updated some tests to use the new way of asserting booleans.
|
In my limited testing of hardware filtering, this does require |
Hi NordicSemiconductor + contributors,
Firstly, thankyou for Android-Scanner-Compat-Library! It has really helped me in developing a Bluetooth project that supports Android SDK versions 19 to 34....
This is my first ever attempt at a pull request, so, please let me know if I am missing anything.
Additions to NordicSemiconductor's Android-Scanner-Compat-Library
My fork of the library allows for the filtering of advertising packets by service data, the same as NordicSemiconductor's Android-Scanner-Compat-Library, but also allows for a mask to be set on the service data UUID. This addition is useful if your Android app receives a dynamic service data UUID.
Sample
Use this library fork in the same way as NordicSemiconductor's Android-Scanner-Compat-Library, but, if you want to filter by a masked service data UUID, do so like this:
I have run the tests on Android 14/11/7/5.1.1 devices: all passes (bar BluetoothLeScannerImplOreoTest -> toImpl() on Android 7/5.1.1, as designed I assume).
The gradle version upgrade might be unnecessary - I cannot remember if it was a requirement for Android Studio Hedgehog 2023.1.1 or not.
Let me know if any changes are needed.
Best regards,
Gregory Thomas