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 using enum #47

Open
vincentdavis opened this issue Dec 14, 2023 · 3 comments
Open

Reverse_lookup using enum #47

vincentdavis opened this issue Dec 14, 2023 · 3 comments

Comments

@vincentdavis
Copy link
Contributor

@dlech request a feature in issue #42 using enum s for rever_lookup that works something like:

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

Looking into this a bit there is a problem with the uniqueness of the names and descriptions, of each id.
What to do?

>>> from bluetooth_numbers import company, oui, service, characteristic, descriptor
>>> print(f"Companies (count: unique names): ({len(company)}, {len(set(company.values()))})")
>>> print(f"oui (count: unique names): ({len(oui)}, {len(set(oui.values()))})")
>>> print(f"service (count: unique names): ({len(service)}, {len(set(service.values()))})")
>>> print(f"characteristic (count: unique names): ({len(characteristic)}, {len(set(characteristic.values()))})")
>>> print(f"descriptor (count: unique names): ({len(descriptor)}, {len(set(descriptor.values()))})")
Companies (count: unique names): (3236, 3231)
oui (count: unique names): (33938, 19016)
service (count: unique names): (707, 535)
characteristic (count: unique names): (603, 566)
descriptor (count: unique names): (16, 16)

looking into this a bit more:

>>> [(k, v) for k, v in Counter(characteristic.values()).items() if v>1]
[('Apple Reserved Characteristic', 38)]

and

>>> srv = [(k, v) for k, v in Counter(service.values()).items() if v>1]
>>> srv
[('Xiaomi Inc.', 5),
 ('Qualcomm Technologies, Inc.', 3),
 ('HP Inc.', 2),
 ('OMRON(DALIAN) CO,.LTD.', 2),
 ('Google LLC', 19),
 ('Smith & Nephew Medical Limited', 2),
 ('Samsara Networks, Inc', 3),
 ('ITT Industries', 3),
 ('Honor Device Co., Ltd.', 2),
 ('Leupold & Stevens, Inc.', 2),
 ('Barrot Technology Limited', 2),
 ('Luminostics, Inc.', 2),
 ('AEON MOTOR CO.,LTD.', 4),
 ('BRG Sports, Inc.', 2),
 ('Panasonic Corporation', 2),
 ('LEGIC Identsystems AG', 2),
 ('Samsung Electronics Co., Ltd', 2),
 ('3M', 2),
 ('GN Hearing A/S', 2),
 ('Huawei Technologies Co., Ltd.', 6),
 ('GD Midea Air\xadConditioning Equipment Co., Ltd.', 2),
 ('Sony Corporation', 2),
 ('The Access Technologies', 2),
 ('Bitstrata Systems Inc.', 2),
 ('Verkada Inc.', 2),
 ('Apple Inc.', 3),
 ('Sigma Elektro GmbH', 2),
 ('Samsung Electronics Co., Ltd.', 6),
 ('70mai Co.,Ltd.', 2),
 ('UTC Fire and Security', 3),
 ('Volvo Car Corporation', 2),
 ('Fitbit, Inc.', 2),
 ('Emerson', 4),
 ('Logitech International SA', 2),
 ('BRControls Products BV', 2),
 ('Insulet Corporation', 2),
 ('Withings', 4),
 ('Husqvarna AB', 2),
 ('Tile, Inc.', 3),
 ('Urbanminded LTD', 2),
 ('Groove X, Inc', 2),
 ('Inseego Corp.', 2),
 ('WWZN Information Technology Company Limited', 2),
 ('Houwa System Design, k.k.', 2),
 ('Proxy Technologies, Inc.', 2),
 ('LivaNova USA Inc.', 2),
 ('Comcast Cable Corporation', 2),
 ('California Things Inc.', 2),
 ('Hunter Douglas', 2),
 ('Baidu Online Network Technology (Beijing) Co., Ltd', 2),
 ('Eli Lilly and Company', 2),
 ('Fortin Electronic Systems', 2),
 ('Huawei Technologies Co., Ltd', 2),
 ('Bose Corporation', 3),
 ('Jiangsu Teranovo Tech Co., Ltd.', 2),
 ('Robert Bosch GmbH', 2),
 ('Tandem Diabetes Care', 2),
 ('Amazon.com Services, Inc.', 2),
 ('ruwido austria gmbh', 2),
 ('Procter & Gamble', 2),
 ('Tyto Life LLC', 2),
 ('Zoll Medical Corporation', 2),
 ('Apple, Inc.', 17),
 ('Volkswagen AG', 3),
 ('CHIPOLO d.o.o.', 2),
 ('HUAWEI Technologies Co., Ltd', 3),
 ('Spaceek LTD', 2),
 ('TTS Tooltechnic Systems AG & Co. KG', 2),
 ('BD Medical', 2),
 ('Inugo Systems Limited', 2),
 ('B&O Play A/S', 2),
 ('General Motors', 2),
 ('Nordic Semiconductor ASA', 3),
 ('Qualcomm Life Inc', 2),
 ('TASER International, Inc.', 2),
 ('The University of Tokyo', 2),
 ('Abbott (formerly St. Jude Medical, Inc.)', 2),
 ('TangoMe', 2),
 ('Hewlett\xadPackard Company', 2),
 ('Telit Wireless Solutions (Formerly Stollmann E+V GmbH)', 2),
 ('Doppler Lab', 2),
 ('Medtronic Inc.', 2),
 ('RF Digital Corp', 2),
 ('CSR', 3),
 ('OttoQ In', 2),
 ('Tesla Motors Inc.', 2),
 ('Currant Inc', 2),
 ('Intrepid Control Systems, Inc.', 2),
 ('GoPro, Inc.', 2),
 ('Savant Systems LLC', 2),
 ('Nokia', 4),
 ('Nest Labs Inc', 2),
 ('WiSilica Inc.', 2),
 ('Meta Platforms, Inc.', 2),
 ('KDDI Corporation', 2),
 ('Broadcom', 2),
 ('Jawbone', 2),
 ('Anhui Huami Information Technology Co., Ltd.', 2),
 ('Anki, Inc.', 2),
 ('Quintic Corp.', 2),
 ('Swirl Networks, Inc.', 2),
 ('Polar Electro Oy', 2),
 ('Aplix Corporation', 2),
 ('PayPal, Inc.', 2),
 ('Gimbal, Inc.', 2),
 ('FiRa Consortium service', 2),
 ('ZigBee Alliance service', 2),
 ('Apple Reserved Service', 4)]
@dlech
Copy link

dlech commented Dec 15, 2023

We could add an increasing value or the actual ID number as a suffix in cases of duplicates.

I suppose a problem with company names too is that they change over time if they get bought out or rebrand themselves.

@koenvervloesem
Copy link
Owner

koenvervloesem commented Dec 15, 2023

If some names/descriptions aren't unique, we should probably make them unique, for example by making them Services.XIAOMI_INC_1, Services.XIAOMI_INC_2, and so on? Edit: the actual ID number, like @dlech suggests, even seems better as a stable value.

There's another issue that I'm thinking about now. The data sources we're using (Bluetooth SIG, IEEE OUIs, Nordic's database) regularly change/update those descriptions, for example after a company acquisition. As a result, our enums will change. An application that is using the value Services.STOLLMANN_E_V_GMBH suddenly won't work anymore if it's called Services.TELIT_WIRELESS_SOLUTIONS_FORMERLY_STOLLMANN_E_V_GMBH in a new version of the database. This will require careful communication of breaking changes in each release.

@dlech
Copy link

dlech commented Dec 15, 2023

An application that is using the value Services.STOLLMANN_E_V_GMBH suddenly won't work anymore if it's called Services.TELIT_WIRELESS_SOLUTIONS_FORMERLY_STOLLMANN_E_V_GMBH in a new version of the database.

Ideally we wouldn't remove Services.STOLLMANN_E_V_GMBH and we would have Services.TELIT_WIRELESS_SOLUTIONS without the formerly part with both enums having the same value. But this would be difficult to automate.

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

3 participants