nrf-softdevice icon indicating copy to clipboard operation
nrf-softdevice copied to clipboard

Receive notifications in gatt_client

Open albertskog opened this issue 3 years ago • 1 comments

Is there a way for gatt_client to receive notifications? I am trying to understand nrf-softdevice-macro and I see there is some sort of event generated in nrf-softdevice-macro/src/lib.rs:

if notify {
    let case_notification = format_ident!("{}Notification", name_pascal);
    code_event_enum.extend(quote_spanned!(ch.span=>
        #case_notification(#ty),
    ));
}

But how do I capture it, there is no gatt_client::run() like there is with gatt_server? Maybe I'm looking in the wrong places..

Happy to contribute documentation and/or code if I can just get a little hint!

albertskog avatar Feb 24 '22 14:02 albertskog

It doesn't look like notifications are currently supported. You would need to add handling for the BLE_GATTC_EVT_HVX event to gatt_client.rs and add support for writing to the Client Configuration Characteristic Descriptor to enable/disable notifications. PRs are welcome.

alexmoon avatar Sep 22 '22 14:09 alexmoon