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

Feat: CentralState #366

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

szymonlesisz
Copy link

@szymonlesisz szymonlesisz commented Feb 19, 2024

Hi,

I'm working on bluetooth integration for trezor-suite app and i would like to use btleplug as a bridge between the electron app and bluetooth device.
To make it work i would like to contribute and address some missing features and issues

CentralState

Implementation of #280 for macos, windows and linux.

I wasn't sure should i extend existing adapter_info method or just add new adapter_state, just for clarity i've added new function. I'm leaving this decision to you.
Also i'm not sure about the naming adapter_state() -> CentralState i didn't want to mess up current naming convention.
Feel free to nitpick anything.

Tested on Windows 10, macOS sonoma, linux nixOS

Commits

@qwandor qwandor changed the base branch from master to dev February 19, 2024 15:22
Copy link
Collaborator

@qwandor qwandor left a comment

Choose a reason for hiding this comment

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

Looks good for BlueZ and CoreBluetooth, apart from some minor comments.

@@ -22,6 +23,13 @@ impl Adapter {
}
}

fn get_central_state(state: bool) -> CentralState {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Call the parameter powered rather than state.

Copy link
Author

Choose a reason for hiding this comment

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

done bcf31a7

} if id == adapter_id => match adapter_event {
AdapterEvent::Powered { powered } => {
let state = get_central_state(powered);
Some(CentralEvent::StateUpdate(state.into()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need the .into() here?

Copy link
Author

Choose a reason for hiding this comment

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

i guess i dont need it :) fixed bcf31a7

@szymonlesisz
Copy link
Author

sorry for the force-push, too many fixes for cargo fmt

@qwandor qwandor requested a review from qdot February 19, 2024 16:07
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