-
Notifications
You must be signed in to change notification settings - Fork 18
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 notify_cb option to gatt!
characteristics.
#39
Conversation
Reworked that patch so that the notification is part of the |
This is a useful addition - unfortunately CI is failing currently |
Sorry about that, CI should be fixed now. |
Thanks! I will be able to give it a proper review tomorrow |
Mind adding a test to #[test]
fn test6() {
let mut my_read_function = |_offset: usize, data: &mut [u8]| {
data[..5].copy_from_slice(&b"Hola!"[..]);
5
};
let mut my_write_function = |_offset, data: &[u8]| {
println!("{:?}", data);
};
let mut my_notify = |enabled: bool| {
println!("enabled = {enabled}");
};
gatt!([service {
uuid: "9e7312e0-2354-11eb-9f10-fbc30a62cf38",
characteristics: [characteristic {
uuid: "9e7312e0-2354-11eb-9f10-fbc30a62cf38",
notify: true,
notify_cb: my_notify,
read: my_read_function,
write: my_write_function,
},],
},]);
println!("{:x?}", gatt_attributes);
} |
Being able to take action when a characteristic's notifications are enabled are disabled is useful when the data source needs some action to be taken to start or stop the data source like enabling interrupts or powering on a sensor.
Thanks for the review. Removed vestigial |
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.
LGTM - Thanks a lot for this useful contribution
Being able to take action when a characteristic's notifications are enabled are disabled is useful when the data source needs some action to be taken to start or stop the data source like enabling interrupts or powering on a sensor.