This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Trouble to read, write and activate notification

Hello comunnity,

I am trying to read, write and activite notification from my server using a central device. The problem is when I use more than 2 times, I got an error of NRF_ERROR_INVALID_DATA But When i do it separetly the code works. Screenshoot

I attached a picture of my output, First I read the Hz, then I write a new HZ, after this I read again the HZ and the end I activate some notifications. Eventhought, after each sentence I put a delay and it's having the same problem

Why is this behavior?

Regards, David Caraveo

Parents Reply Children
  • Hi Sigurd, the funcions that I am using are the followin: Activating the notifications: err_code = sd_ble_gattc_write(m_conn_handle[conn_nummber], &write_params); Reading: err_code = sd_ble_gattc_read(m_conn_handle[conn_nummber],FREQUUID,0);

    Set the Freque. err_code = sd_ble_gattc_write(m_conn_handle[conn_nummber], & write_params_SR);

    uint8_t p_value[2] = {0x01, 0x01}; /*/ uint8_t sample_rate = 0x64; /*/

    static ble_gattc_write_params_t const write_params = { .write_op = BLE_GATT_OP_WRITE_REQ, .handle = QUATERNIOSUUID, .offset = 0, .len = 2, .p_value = (uint8_t *)&p_value };

    static ble_gattc_write_params_t write_params_SR = { .write_op = BLE_GATT_OP_WRITE_REQ, .handle = FREQUUID, .offset = 0, .len = sizeof(sample_rate), .p_value = (uint8_t *)&sample_rate };

  • it doesn´t matter in which order i put them, the first will work correctly but the second and the third will have an error

  • Hi,

    When calling sd_ble_gattc_write you will get a BLE_EVT_TX_COMPLETE / BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE when the packet has been transmitted for write commands(write without response). For write requests you will get a BLE_GATTC_EVT_WRITE_RSP when the packet is received by the peer.

    sd_ble_gattc_write() will return NRF_SUCCESS when it has started the write procedure. When you are doing write request you it will return NRF_ERROR_BUSY(=0x11) if a write request procedure is already ongoing,e.g. you have not received a BLE_GATTC_EVT_WRITE_RSP for your previous write request.

    Only one write with response procedure can be ongoing per connection at a time. If the application tries to write with response while another write with response procedure is ongoing, the function call will return NRF_ERROR_BUSY. Either wait for the event BLE_GATTC_EVT_WRITE_RSP before calling sd_ble_gattc_write(), or do Write without Response.

    Relevant Message Sequence Chart:

    image description

  • Thanks! it was so usefull!

Related