I am working with BluetoothLe on Android (min API : 21+). Currently the procedure of filtering service uuid's works, but not quite as expected. Below is a code segment used for setting up the basic scanner parameters, this is what currently works. Based on areas of other work with Ble, (iOS, Embedded Hardware) it becomes apparent that there are abilities to filter Ble devices based on their 16-bit UUID assignments only. Which brings me to Android... I realized android has had a rather rough start to Ble and its rather segmented ecosystem of devices, but I fail to see how/why android cant follow similar paths with the UUID's like other platforms. As all the UUID's coming from the Bluetooth SIG are 16-bit identifiers only with a mere definition of a UUID_BASE (00000000-0000-1000-8000-00805F9B34FB).
...
// devices UUID service
ParcelUuid parcelUuid = new ParcelUuid(UUID.fromString("1F0E0D0C-0B0A-0909-0807-060504030201"));
// devices UUID service mask
ParcelUuid parcelUuidMask = new ParcelUuid(UUID.fromString("00000D0C-0000-0000-0000-000000000000"));
// Filters and Settings
scanFilter = new ScanFilter.Builder().setServiceUuid(parcelUuid, parcelUuidMask).build();
scanFilterList.add(scanFilter);
scanSettings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_POWER).build();
// Scanning Started
mBluetoothLeScanner.startScan(scanFilterList, scanSettings, scanCallback);
...
With all that stated above, I have two Embedded Hardware devices broadcasting Two of their own UUID Services that are very similar to one another but different non the less. Below are those UUID's, in all accounts only the MSB(Most Signifigant Byte) is the differentiator amongst them all. Also there Device Names are different.
Device One:
Service 1 - 1F0E0D0C-0B0A-0909-0807-060504030201
Service 2 - 2F0E0D0C-0B0A-0909-0807-060504030201
Device Two:
Service 1 - EF0E0D0C-0B0A-0909-0807-060504030201
Service 2 - FF0E0D0C-0B0A-0909-0807-060504030201
Common Identifier amongst the UUID's:
0x0D0C
From the code segment provided earlier, the ParcelUuid that is used in the setServiceUuid method appears to require an exact match for the scanner to even return a device, despite the matching mask needed. How then, do you make the request to the drivers/hardware to filter only by 16-bit Identifiers instead of the full 128-bit Identifiers?? Because the model I have presented above with the two different devices, each with their own Service UUID's different from the other, isn't capable of scanning and returning all the devices wanted or expected.
I feel like the problem I'm having is two-fold but needs to addressed, because I cant seem to find the answer anywhere. I have searched high and low for all forum post, stack questions/answer that touch on this topic but none of them appear to pop out as what I'm looking for. I'm not sure if my understanding of filtering on android is faulty, if android is missing features, or inability to find such features in the supplied classes of android. I have a few thoughts on how to accomplish this "feature" in software but it will be rather ugly, time consuming, and taxing on the battery. One such example is scanning openly and filtering it manually. But I think there is or should be a feature to support 128-bit AND 16-bit UUID filtering when scanning through devices.
Can anyone help shed light on this????
Also, apologies for the length of this posted question...