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

Convert HCI role and transport into enums #332

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zxzxwu
Copy link
Collaborator

@zxzxwu zxzxwu commented Nov 15, 2023

As they are widely used as parameters, making them enums can significantly improve the static check.

bumble/core.py Outdated
BT_CENTRAL_ROLE = Role.CENTRAL
BT_PERIPHERAL_ROLE = Role.PERIPHERAL

class Transport(enum.IntEnum):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend naming this TransportType, not to confuse with the Transport object from bumble.transport.common

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about BtTransport?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mode ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe PhysicalTransport, since that's the term used in the BT spec?

bumble/core.py Outdated
Comment on lines 38 to 45

BT_CENTRAL_ROLE = Role.CENTRAL
BT_PERIPHERAL_ROLE = Role.PERIPHERAL

BT_BR_EDR_TRANSPORT = PhysicalTransport.BR_EDR
BT_LE_TRANSPORT = PhysicalTransport.LE

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason for these defines? could they be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's for backward compatibility. There have been an significant usage of these primitive constants, so removing them here will be irresponsible.

As they are widely used as parameters, making them enums can significantly improve the static check.
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

Successfully merging this pull request may close these issues.

4 participants