Skip to content
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

As a user, I would like iBeacon UUID filtering to be performed at hardware level, for it to consume less system resources #38

Open
agonper opened this issue May 13, 2022 · 1 comment

Comments

@agonper
Copy link
Collaborator

agonper commented May 13, 2022

As per @matey97 suggestion, native ScanFilters could be used. Like this one:

byte[] manufacturerData = new byte[] {
                0,0,
                uuid[0], uuid[1], uuid[2], uuid[3],
                uuid[4], uuid[5],
                uuid[6], uuid[7],
                uuid[8], uuid[9],
                uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15],
                0,0,
                0,0,
                0
        };

        byte[] manufacturerMask = new byte[] {
                0,0,
                1,1,1,1,
                1,1,
                1,1,
                1,1,
                1,1,1,1,1,1,
                0,0,
                0,0,
                0
        };

        scanFilters.add(new ScanFilter.Builder()
                .setManufacturerData(76, manufacturerData, manufacturerMask)
                .build());

To further investigate

@agonper
Copy link
Collaborator Author

agonper commented May 13, 2022

More context:

Raw UUIDs must be processed:

public static byte[] HexToSignedInt(String uuid) {
    int hexStep = 2;
    uuid = uuid.replace("-", "");

    byte[] uuid_bytes = new byte[uuid.length() / hexStep];

    for (int i = 0; i < uuid.length(); i += hexStep) {
        String part = uuid.substring(i, i + hexStep);
        uuid_bytes[i / hexStep] = (byte) Integer.parseInt(part,16);
    }

    return uuid_bytes;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant