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

Add RFCOMM and SDP context manager and search helper #420

Merged
merged 1 commit into from Feb 3, 2024

Conversation

zxzxwu
Copy link
Collaborator

@zxzxwu zxzxwu commented Feb 2, 2024

  • Add an RFCOMM (Client, Server) and SDP(Client only because Server is managed by device) context manager.
  • Add an RFCOMM helper function to search channel from SDP.
  • And some test cases.

@zxzxwu zxzxwu changed the title Add RFCOMM and SDP helpers Add RFCOMM and SDP context manager and search helper Feb 2, 2024
bumble/rfcomm.py Outdated Show resolved Hide resolved
bumble/rfcomm.py Outdated
)
)

return records


# -----------------------------------------------------------------------------
async def search_channels_from_sdp(connection: Connection) -> Dict[int, List[UUID]]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a similar helper in bench.py. The other one doesn't return a list, but looks just for one specific UUID. I think both are useful.
Maybe the single-uuid version from bench.py could be re-written by using this one, and moved to rfcomm.py.
We'd end up with:

  • rfcomm.find_rfcomm_channels (this one, just different name) and
  • rfcomm.find_rfcomm_channel_with_uuid (the refactored one moved over from bench.py)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was wondering whether it should be a directional search or general search, but it seems not bad to have both.



# -----------------------------------------------------------------------------
async def find_rfcomm_channel_with_uuid(
Copy link
Collaborator

Choose a reason for hiding this comment

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

That function could be implemented by calling the generic find functions, then looking for the UUID in the resulting dict (less duplicated code)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@zxzxwu zxzxwu merged commit 1ee1ff0 into google:main Feb 3, 2024
51 checks passed
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.

None yet

2 participants