Closed konkers closed 7 months ago
Reworked that patch so that the notification is part of the AttData
trait.
This is a useful addition - unfortunately CI is failing currently
Sorry about that, CI should be fixed now.
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 bleps-macros/tests/macro_test.rs
? It's just a simple compile test but helpful to not break things in future. Something like this
#[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);
}
Thanks for the review. Removed vestigial notify_cb_call
code and added suggested test code.
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.