Reducing the Time Required to Read 16 KB of Data

Hi,

I want to reduce the time required to read 16 KB of data from the datalogger. Currently, it takes about 6 seconds to read all the data. How can I decrease this time?

#define MIN_CONN_INTERVAL MSEC_TO_UNITS(12, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(12, UNIT_1_25_MS)
#define SLAVE_LATENCY 0
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)



///////////////////////////////////////////ALLICATION SEND DATA
for(char i=0;i<66;i++)
{
DATA_SEND_BLUE_TX[0]=i+1;
nrf_fstorage_read(&f_storage,0x28000+i*240, &DATA_SEND_BLUE_TX[1],240);
DATA_SEND_BLUE_TX[241]=Chksum8_2sComplement(&DATA_SEND_BLUE_TX[1],240);
SEND_TO_APP( DATA_SEND_BLUE_TX,242);// 242 //56
}
//////////////////////////////////////////////////////////////////

void SEND_TO_APP(uint8_t * data_array, uint16_t index)
{
uint32_t err_code;
uint16_t length = index; count_send=0;
do
{
err_code = ble_data_send(&m_data, data_array, length, m_conn_handle);
if ((err_code != NRF_ERROR_INVALID_STATE) &&
(err_code != NRF_ERROR_RESOURCES) &&
(err_code != NRF_ERROR_NOT_FOUND))
{
APP_ERROR_CHECK(err_code);
}
count_send++;
} while (err_code == NRF_ERROR_RESOURCES);

}

uint32_t ble_data_send(ble_data_t * p_dat,
uint8_t *p_data,
uint16_t p_length,
uint16_t conn_handle)
{
ble_gatts_value_t gatts_value;
memset(&gatts_value, 0, sizeof(gatts_value));
gatts_value.len = p_length;
gatts_value.offset = 0;
gatts_value.p_value = p_data;
return sd_ble_gatts_value_set(p_dat->conn_handle, p_dat->tx_handles.value_handle, &gatts_value);
}

Parents
  • Hi Loc, 

    Could you explain how you send data to the peer device? 
    I can see you are setting the value of the characteristic using sd_ble_gatts_value_set() in ble_data_send() 
    But then there is no guarantee that the value is notified to the peer device. 
    Usually to send data to the peer device (the client) the server send a notification. 

    Are you familiar with our example in the SDK, for example ble_app_hrs ? or ble_app_uart ?

  • Hi Hung, 

    I am using the ble_app_uart example. The Android application sends a command to the BLE device, and then waits for the device to send back 66 data packets.

    Thanks,

  • Hi Loc, 
    Could you explain why you use sd_ble_gatts_value_set() . This only set the value of the characteristic, not sending the content to the peer. 
    If you look at the ble_nus_data_send() in ble_nus.c you can find that we are using sd_ble_gatts_hvx() instead. 


    Please also be aware that nRF5 SDK is very old and has been deprecated for a few years already. If you are developing a new product, it's recommended that you start with nRF Connect SDK . 

  • Hi Hung,


    My current implementation is based on the ble_app_uart example using nRF5 SDK v16, where sd_ble_gatts_value_set() is used.
    I am planning to try the nRF Connect SDK. If I migrate to the new SDK, will the total time required to read all data be reduced or improved compared to nRF5 SDK

    Thanks,

Reply Children
No Data
Related