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

More example #37

Open
alberk8 opened this issue Jun 10, 2019 · 2 comments
Open

More example #37

alberk8 opened this issue Jun 10, 2019 · 2 comments

Comments

@alberk8
Copy link

alberk8 commented Jun 10, 2019

I am a newbie with rust. I would like to a sample/example of writing to a BLE characteristics with notify. I really appreciate if someone is kind enough give me a helping hand. Thank you,

@alberk8
Copy link
Author

alberk8 commented Jun 18, 2019

Hi,
Would love for someone to show me how to pass a known ble MAC address string to the peripheral. Thank you.

@felsweg
Copy link

felsweg commented Sep 2, 2019

I can't give you a full blown example, but the basic idea is to scan for peripherals from your central device (that is the adapter in ble terminology):

let predicate = ...
let p = central.peripherals().into_iter().find(predicate)

if you have a peripheral, scan for characteristics:

let chars = p.discover_characteristics()

then find your characteristic

let rx_char = chars
            .clone()
            .into_iter()
            .find(|c| RECEIVE_CHARACTERISTIC == c.uuid)
            .expect("Could not find given characteristic");

RECEIVE_CHARACTERISTIC is a UUID. From here, you can call methods like subscribe, send , on_notification and so on. Hope that helps.

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

No branches or pull requests

2 participants