This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Data transmitted twice and BLE_NUS_EVT_TX_RDY event received twice

Hi,

I'm using a custom board with nrf52840 and sdk 15.1.0.

I have altered the ble central and peripheral example(ble_app_hrs_rscs_relay) to support nus central and peripheral. I'm able to send and receive data from both peripheral and central connections. 

But when I send data through a peripheral connection, the BLE_NUS_EVT_TX_RDY event in "nus_data_handler" is triggered twice and the data is send twice even though I'm calling "ble_nus_data_send" only once.

else if(p_evt->type == BLE_NUS_EVT_TX_RDY)
{
NRF_LOG_DEBUG("Tx Completed %d ", ++complete_count);
}

LOG Output is:

Tx Completed 1

Tx Completed 2

when I try to send the data repeatedly in 20 second interval, each time its transmitted twice.

Any suggestions on this will be of great help.

Parents
  • Hi

    Due to the summer holidays in Norway, our support team is understaffed this week, and delayed replies must be expected. Sorry for the inconvenience!

    I've been assigned this case as Edvin is away, and what you'll have to do is what Edvin has already suggested. previously. Have you added

    ble_nus_c_evt.conn_handle = p_ble_evt->evt.gap_evt.conn_handle;

    before

    p_ble_nus_c->evt_handler(p_ble_nus_c, &ble_nus_c_evt); ?

    Also, you'll have to do everything as it is done in the ble_app_hrs_rscs_relay example as described previously.

    If you'd like, you can create a new ticket describing your problem, linking to this post, and uploading a project where we can reproduce it, and we'll try to figure out what's wrong.

    Best regards,

    Simon

  • Simon

       hi ,I having the same problem.I just follow your suggestion ,but the problem still existed . My code : 

    static void on_hvx(ble_nus_c_t * p_ble_nus_c, ble_evt_t const * p_ble_evt)
    {
    // HVX can only occur from client sending.
    if ( (p_ble_nus_c->handles.nus_tx_handle != BLE_GATT_HANDLE_INVALID)
    && (p_ble_evt->evt.gattc_evt.params.hvx.handle == p_ble_nus_c->handles.nus_tx_handle)
    && (p_ble_nus_c->evt_handler != NULL))
    {
    ble_nus_c_evt_t ble_nus_c_evt;

    ble_nus_c_evt.evt_type = BLE_NUS_C_EVT_NUS_TX_EVT;
    ble_nus_c_evt.p_data = (uint8_t *)p_ble_evt->evt.gattc_evt.params.hvx.data;
    ble_nus_c_evt.data_len = p_ble_evt->evt.gattc_evt.params.hvx.len;

    //20210130 add this func,due to rx. and printf twice
    ble_nus_c_evt.conn_handle = p_ble_evt->evt.gap_evt.conn_handle;

    p_ble_nus_c->evt_handler(p_ble_nus_c, &ble_nus_c_evt);
    NRF_LOG_DEBUG("Client sending data.");
    }
    }

    could you please give me more suggestion to solve it ?

      

  • Hi

    This case is more than two years old, and as I suggested in my last reply, if you're not able to solve your issue by what we have suggested earlier, please create a new ticket describing your problem, and linking to this post if relevant. We would also like to know what SDK version and SoftDevice you're using.

    Best regards,

    Simon

Reply Children
No Data
Related