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

How to resolve packet drops during large data transfer?

Hi there,

I need to transmit 33995520 bytes from nrf52 peripheral device to a Windows/Android device. Currently it takes about 13 to 14 minutes to complete the data transfer with some packet drops. My connection parameters are as follows-

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(7.5, UNIT_1_25_MS)	/**< Minimum acceptable connection interval (0.1 seconds). */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(15, UNIT_1_25_MS)     /**< Maximum acceptable connection interval (0.2 second). */
#define SLAVE_LATENCY                   0                                           /**< Slave latency. */
#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(10000, UNIT_10_MS)    /**< Connection supervisory timeout (4 seconds). */

#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH
#define NRF_SDH_BLE_GAP_EVENT_LENGTH 400//6	
#endif

#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 230//247//35//23
#endif

#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH
#define NRF_SDH_BLE_GAP_DATA_LENGTH 234//233//27
#endif

case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
        {
            NRF_LOG_DEBUG("PHY update request.");
            ble_gap_phys_t const phys =
            {
                .rx_phys = BLE_GAP_PHY_2MBPS,
                .tx_phys = BLE_GAP_PHY_2MBPS,
            };
            err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
            APP_ERROR_CHECK(err_code);
        }break;

Overall, I see ~6 packets getting dropped. 

I tried to add more checks like tracking BLE_GATTS_EVT_HVN_TX_COMPLETE or looking out for NRF_SUCCESS but then I lose more data. I also tried to increase the connection interval to 50 to 100 ms, still the same result. Do you have any suggestions?

Parents
  • Hi

    Have you checked out the Object transfer service example we have available in the SDK, which is made specifically to transfer larger files safely over established L2CAP channel(s), with an event triggering on the server-side when the write is complete.

    Regarding the lost packets you're seeing. Is this consistent or seemingly random? Do you see the lost ones come at the end of the transaction for example? It seems very strange that the checks would cause you to lose more data. The only thing that would make sense there would be that you start sending before the TX complete event is triggered. Do you wait for the TX_COMPLETE event before sending the next packet in these cases, or not?

    Best regards,

    Simon

  • Is the OTS fast and reliable? I'm using SDK 16, can I use OTS with SDK 16?

    Random packets are dropped. As per your advice, I'm checking for TX_COMPLETE after sending a packet and I see some improvement. 

Reply Children
No Data
Related