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

Handle Bluetooth short UUIDs (uuid16) #191

Open
ukBaz opened this issue Sep 26, 2018 · 0 comments
Open

Handle Bluetooth short UUIDs (uuid16) #191

ukBaz opened this issue Sep 26, 2018 · 0 comments

Comments

@ukBaz
Copy link
Owner

ukBaz commented Sep 26, 2018

Bluezero should be able to handle UUIDs in a couple of different formats.
It should be supported for people to add UUIDs without the dashes and to enter 16-bit UUIDs if they a official Bluetooth support values. A Base UUID is used for calculating 128-bit UUIDs from short UUIDs

BASE_UUID = 00000000-0000-1000-8000-00805F9B34FB

An example of what could be added is:

def _add_uuid_dashes(uuid):
    return '{0}-{1}-{2}-{3}-{4}'.format(uuid[0:8], uuid[8:12],
                                        uuid[12:16], uuid[16:20], uuid[20:])

def _valid_uuid(uuid):
    if len(uuid) == 32:
        return _add_uuid_dashes(uuid)
    elif len(uuid) == 4:
        return '0000{0}-0000-1000-8000-00805F9B34FB'.format(uuid)
    else:
        return uuid
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