-
Notifications
You must be signed in to change notification settings - Fork 80
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
Conversation
zxzxwu
commented
Feb 2, 2024
•
edited
Loading
edited
- 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.
704db9f
to
e635902
Compare
bumble/rfcomm.py
Outdated
) | ||
) | ||
|
||
return records | ||
|
||
|
||
# ----------------------------------------------------------------------------- | ||
async def search_channels_from_sdp(connection: Connection) -> Dict[int, List[UUID]]: |
There was a problem hiding this comment.
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) andrfcomm.find_rfcomm_channel_with_uuid
(the refactored one moved over frombench.py
)
There was a problem hiding this comment.
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.
4b6159a
to
95d1a6d
Compare
|
||
|
||
# ----------------------------------------------------------------------------- | ||
async def find_rfcomm_channel_with_uuid( |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done