nRF52832 Sends 2KB data in less than 1s

Hi,

I am reading a chunk of 2KB data from a sensor every interrupt generated from the sensor. The interrupt occurs less than 1 second and I have to transmit it via Bluetooth. I got an NRF error code 19 when I divide the 2KB data into 20 frames before transmitting the data in a for loop. I was wondering if there is a better way to handle it.

Thanks in advance,

Peter

Parents
  • Hi Peter,

    Based on the error you describe I assume you are using the nRF5 SDK? Are you sending data as notifications? That will be the most efficient want. However, there is a limit to how much data that can be buffered, and when you get NRF_ERROR_RESOURCES (19) returned from sd_ble_gatts_hvx() you need to wait for the BLE_GATTS_EVT_HVN_TX_COMPLETE event before you attempt to send more.

    If this does not answer the question, then please describe a bit more what you are doing.

  • Hi Einar,

    Thank you so much for your reply. Yes I am using the nRF5 SDK and sending data as notification. I defined a global variable m_wait_ble_tx

    When NRF_ERROR_RESOURCES(19) is returned, the variable will be set as true and wait until it is completed

    if (err_code == NRF_ERROR_RESOURCES)
    {
    m_wait_ble_tx = true;
    while (m_wait_ble_tx)
    {
    nrf_pwr_mgmt_run();
    }
    // err_code should be 0 when try again
    err_code = sd_ble_gatts_hvx(p_biosig_svc->conn_handle, &hvx_params);
    }

    in the ble evt handler when the event you mentioned occurred the variable will be set as true:  case BLE_GATTS_EVT_HVN_TX_COMPLETE:
    m_wait_ble_tx = false;
    break;  

    But this still does not solve my issue. I was wondering if my workflow is correct.

    Thanks,

    Peter

  • Is your m_wait_ble_tx variable declared volatile?

    And I would include a k_msleep(3) or equivalent in your while() loop.

  • Hi wmuees,

    Thanks for your reply. That's a good point. I did not declare the variable volatile. I add some delay in the while loop but couldn't get rid of the error code. I am trying to increase the delay a little bit to see if it will work.

    Thanks,

    Peter

Reply Children
Related