0

Is there any proper reason from Android team why BLE filter is not working for Android 4.3 and 4.4 devices? I need to explain this issue to my client.

private List<UUID> parseUuids(byte[] advertisedData) {
    List<UUID> uuids = new ArrayList<UUID>();

    ByteBuffer buffer = ByteBuffer.wrap(advertisedData).order(ByteOrder.LITTLE_ENDIAN);
    while (buffer.remaining() > 2) {
        byte length = buffer.get();
        if (length == 0) break;

        byte type = buffer.get();
        switch (type) {
            case 0x02: // Partial list of 16-bit UUIDs
            case 0x03: // Complete list of 16-bit UUIDs
                while (length >= 2) {
                    uuids.add(UUID.fromString(String.format(
                            "%08x-0000-1000-8000-00805f9b34fb", buffer.getShort())));
                    length -= 2;
                }
                break;

            case 0x06: // Partial list of 128-bit UUIDs
            case 0x07: // Complete list of 128-bit UUIDs
                while (length >= 16) {
                    long lsb = buffer.getLong();
                    long msb = buffer.getLong();
                    uuids.add(new UUID(msb, lsb));
                    length -= 16;
                }
                break;

            default:
                buffer.position(buffer.position() + length - 1);
                break;
        }
    }

    return uuids;
}
Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
Venkat
  • 3,268
  • 6
  • 36
  • 60
  • Where is the code of your implementation of Bluetooth Low Energy? And do you know, there is different API for <4.4.2 and >5.0? – R. Zagórski May 22 '17 at 09:45
  • yes I know @R.Zagórski check this link if you have any doubts http://stackoverflow.com/questions/19502853/android-4-3-ble-filtering-behaviour-of-startlescan?rq=1 – Venkat May 22 '17 at 09:48
  • @R.Zagórski https://stackoverflow.com/questions/44126450/getting-different-byte-scanrecord-data-for-same-ble-device-while-scanning-with – Venkat May 23 '17 at 06:46

0 Answers0