-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Feat: CentralState #366
Conversation
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.
Looks good for BlueZ and CoreBluetooth, apart from some minor comments.
src/bluez/adapter.rs
Outdated
@@ -22,6 +23,13 @@ impl Adapter { | |||
} | |||
} | |||
|
|||
fn get_central_state(state: bool) -> CentralState { |
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.
Nit: Call the parameter powered
rather than state
.
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 bcf31a7
src/bluez/adapter.rs
Outdated
} if id == adapter_id => match adapter_event { | ||
AdapterEvent::Powered { powered } => { | ||
let state = get_central_state(powered); | ||
Some(CentralEvent::StateUpdate(state.into())) |
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.
Why do you need the .into()
here?
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 guess i dont need it :) fixed bcf31a7
087702b
to
bcf31a7
Compare
sorry for the force-push, too many fixes for |
wait this feature merged 😁 |
bcf31a7
to
523cc18
Compare
Hi, is there anything else i can do to push things forward? im expecting more conflicts with #388 |
523cc18
to
44d71ca
Compare
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.
Looks good to me once the build failure is fixed. Go ahead and squash your fixups when you're ready.
3e09084
to
03c6acd
Compare
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 newadapter_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
c244d41 add
CBManagerState
getter https://developer.apple.com/documentation/corebluetooth/cbmanagerstate incorebluetooth
delegate. The state is emitted inCentralDelegateEvent::DidUpdateState
event.6cdb170 add
api::Adapter.adapter_state
function andCentralEvent::StateUpdate
event, by default all targets returnsCentralState::Unknown
e13a5e1 implementation for corebluetooth using delegate
centralmanager_state
getter08ef9a1 implementation for bluez using
BluetoothEvent::Adapter
eventc608e55 implementation for winrtble using
Radio.State()
https://github.com/microsoft/windows-rs/blob/master/crates/libs/windows/src/Windows/Devices/Radios/mod.rs -there might be some side effects, not sure why sometimes i'm receiving same event twice, but i don't mind that