Hello,
I'm using a development board PCA10040 with sdk 16.0
I'm trying to organize a data streaming between two devices. Nrf52 board collect data (27 bytes with interval of 500us) from sensor board via SPI and send it via NUS.
At other side I have a dongle PCA10059 as a central with usbd_ble_uart.
It works fine with little data size and single send.
The problem is at BLE transfer. For first test I'm trying to send 18 packets (27*18 = 486 bytes).
Sensor board send packets all the time via SPI, I need only read
for(uint8_t idx = 0; idx < 18; ++idx)
{
spi_xfer_done = false;
memset(data, 0, sizeof(data));
err_code = nrf_drv_spi_transfer(&spi, 0x00, 0, data, 27);
APP_ERROR_CHECK(err_code);
while (!spi_xfer_done) {__WFE();}
uint16_t length = (uint16_t)sizeof(data);
err_code = ble_nus_data_send(&m_nus, data, &length, m_conn_handle);
APP_ERROR_CHECK(err_code);
}But I receive only 5 arrays (27*5) and controller goes reboot.
1. Why this happend? RTT viewer shows nothing about this
But I found by debuger error code 13.
If I will take-off error check from ble_nus_data_send, I can receive 9 packets (243 bytes) without errors. But no more...
Ok, here looks like BLE buffer is full and was sent completely but only once.
2. Second test. I tried by other way. If I will form one 243 bytes array composed by 9 arrays with 27 bytes.
for(uint8_t idy = 0; idy < 10; ++idy)
{
memset(data, 0, sizeof(data));
for(uint8_t idx = 0; idx < 9; ++idx)
{
spi_xfer_done = false;
memset(data_one, 0, sizeof(data_one));
err_code = nrf_drv_spi_transfer(&spi, 0x00, 0, data_one, 27);
APP_ERROR_CHECK(err_code);
while (!spi_xfer_done) {__WFE();}
memcpy(data + idx*27, data_one, 27*sizeof(uint8_t));
}
uint16_t length = (uint16_t)sizeof(ECG_data);
//err_code =
ble_nus_data_send(&m_nus, ECG_data, &length, m_conn_handle);
//APP_ERROR_CHECK(err_code);
}The cycle idy happend 10 times but I receive only 3 times (3*243 = 729 bytes) without errors.
But it only works without app_error_check.
Ok, much better...
But why not 10 times?
3. Looks like I have some problem with connection, isn't it?
I tried to adjust some configuration but without success... Parameters are:
sdk_config.h NRF_SDH_BLE_GAP_EVENT_LENGTH 6 //if change this parameter it give me reboot loop NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247 nrf_ble_gatt.c BLE_GAP_DATA_LENGTH_DEFAULT 247 BLE_GAP_DATA_LENGTH_MAX 251 main.c MIN_CONN_INTERVAL 20 //units MAX_CONN_INTERVAL 75
Dongle configured by the same.
4. The final idea is to send and receive 54 kB at minimal time.
Sincerely,