Using the nus central and peripheral examples from SDK_17.1.0 trying to transfer at least 1 kilobytes per second.
Peripheral on nRF52840 PCA10059, central on nrf52832 pca10040.
Successfully set BLE_GAP_PHY_2MBPS mode and buffer size 244 bytes.
MIN_CONN_INTERVAL MSEC_TO_UNITS(8, UNIT_1_25_MS)
MAX_CONN_INTERVAL MSEC_TO_UNITS(75, UNIT_1_25_MS)
The function of the data transfer is as follows:
void BLE_PeripheralSend(void)
{
uint32_t err_code;
unsigned short length;
if(BLE_connected==false) return;
length = BLE_TX_channel.get_count();
if(length == 0) return;
if(length > BLE_NUS_MAX_DATA_LEN)
{length = BLE_NUS_MAX_DATA_LEN;}
SETBIT(TEST_PIN2);
SETBIT(TEST_PIN);
//reload to local buffer
BLE_TX_channel.read((char*)data, (unsigned char)length);
//============================================
//Load in a loop until the block is transferred
do
{
if(BLE_connected==false) break;
err_code = ble_nus_data_send(&m_nus, data, &length, BLE_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);
}
}
while (err_code == NRF_ERROR_RESOURCES);
//============================================
CLRBIT(TEST_PIN2);
}
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
//the transmitter has sent packets and the buffer is free
case BLE_GATTS_EVT_HVN_TX_COMPLETE:
CLRBIT(TEST_PIN);
break;
No matter how many bytes are transferred. From one to 200, the transmission length is about 60 ms. If you start loading new data at this interval, the packets disappear. Instead of 1ms, it takes 60 times longer.
I have studied the topic devzone.nordicsemi.com/.../how-to-achieve-max-throughput-with-nus-service
Implemented all the recommendations from it. But it does not solve the problem. If you use NRF_SDH_BLE_GAP_EVENT_LENGTH more than 6, the application immediately fails.
The yellow line in the picture: the residence time in the BLE_PeripheralSend() function This is 60us. This is followed by waiting for packet transmission, green line. This is not less than 40ms and not more than 60ms. A packet cannot be shortened in any way, even if it is 1 byte.


