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

reverse lookup #42

Open
dlech opened this issue Nov 15, 2023 · 5 comments
Open

reverse lookup #42

dlech opened this issue Nov 15, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@dlech
Copy link

dlech commented Nov 15, 2023

It would be useful to have enums or a second dictionary for each data type to be able to look up the number by a human-readable name.

@koenvervloesem koenvervloesem added the enhancement New feature or request label Nov 17, 2023
@vincentdavis
Copy link
Contributor

vincentdavis commented Dec 10, 2023

I have an idea for this and am working on it, hope to have something soon.

@koenvervloesem
Copy link
Owner

@dlech Could you maybe take a look at #43 for some suggestions before we merge this?

@dlech
Copy link
Author

dlech commented Dec 12, 2023

I was hoping for an enum in order to get autocomplete. Without that, we still have to look up names somewhere, which doesn't really save any time and we might as well hard-code our own constants.

I'm not sure I see the use of returning multiple matches. For all of the use cases I have, I only want one value returned.

For example, I want to be able to write:

LEGO_CID = Companies.LEGO_SYSTEM_AS
# instead of
LEGO_CID = 0x0397

How would this look with the proposed PR?

@koenvervloesem
Copy link
Owner

Good points. I like the idea of having autocomplete for this.

@vincentdavis:

@vincentdavis
Copy link
Contributor

vincentdavis commented Dec 12, 2023

@koenvervloesem @dlech I like the auto-complete, enum idea.
My personal use case is that I am working on ble scanner to find devices, services, ... that are related to cycling power or heartrate. Rather than keep track of multiple sources of SIG/uuids I would like to use bluetooth_numbers.reverse_lookup like a reference tool.
by the way, reverse_lookup('LEGO SYSTEM AS', uuid_type=['company']) would return set(0x0397) if there is only one match, and if there is more than one that would be good to know.

If I already know that Companies.LEGO_SYSTEM_AS is a valid Company, then I probably already know the uuid is 0x0397 Thats not to dicount the much cleaner, more readable code of using LEGO_CID = Companies.LEGO_SYSTEM_AS

I would like to keep the reverse_lookup as a useful reference tool.
I will work on implementing an enum-type solution as this would also be useful to me.

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

No branches or pull requests

3 participants