Addition: filter by service data UUID with mask#144
Open
gregorymarkthomas wants to merge 17 commits intoNordicSemiconductor:developfrom
Open
Addition: filter by service data UUID with mask#144gregorymarkthomas wants to merge 17 commits intoNordicSemiconductor:developfrom
gregorymarkthomas wants to merge 17 commits intoNordicSemiconductor:developfrom
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.
|
|
Author
|
In my limited testing of hardware filtering, this does require |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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