Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Enabling Notify on 2 Characteristics

Hi,

I'm having some trouble when trying to implement a custom service with two characteristics (SDK 15.0). My central application is not able to write to the cccd handle for the second characteristic. I get the error: NRF_ERROR_BUSY, which I traced back to the missing write response from the first cccd write. In the infocenter and the devzone I found the answer to wait for a BLE_GATTC_EVT_WRITE_RSP.

I'm not quite clear on how to do that, since BLE_GATTC_EVT_WRITE_RSP is a BLE event and my cccd writes are executed inside my service event handler (ble_cus_c_evt_handler).

Do I simply add a ble_evt variable to my service event handler function header?, or what is the way to go about this?

I'm happy to give more information about my issue if needed.

Best,

Nick

Parents
  • Hi,

    I'm not sure if I quite understand your question. But if you take a look at the ble_app_rscs_c example, you can see how to implement a queue of read and write operations. Take a look at the functions cccd_configure() and tx_buffer_process() in ble_rscs_c.c. I suppose you can expand upon these functions and queue up your writes to the CCCD handles. 

  • Thanks for the reply Martin.

    Ok, I will have a look at this. So far, I've solved my issue by simply writing to the cccd handle without response. But that is probably not an optimal solution.

    I could have worded my question above a bit more generally:

    How can I access softdevice events (e.g BLE_GATTC_EVT_WRITE_RSP) inside an application event handler (ble_cus_c_evt_handler)?

    Because if I want to wait for a BLE_GATTC_EVT_WRITE_RSP event, as described in the infocenter , I would like to access this softdevice event from the same function as I enable notifications.

    Best,

    Nick

  • If you really need to do this I suppose adding a ble_evt variable to your service event handler function header could be the easiest route. Note however, that some functions that call the event handler don't have any ble_evt variable to pass into the event handler (like ble_nus_c_on_db_disc_evt()). A simple if(ble_evt == NULL) check might fix this though. 

Reply
  • If you really need to do this I suppose adding a ble_evt variable to your service event handler function header could be the easiest route. Note however, that some functions that call the event handler don't have any ble_evt variable to pass into the event handler (like ble_nus_c_on_db_disc_evt()). A simple if(ble_evt == NULL) check might fix this though. 

Children
No Data
Related