SDK: nRF5_SDK_11.0.0
Softdevice: s132_nrf52_2.0.0_softdevice
project:\examples\ble_peripheral\ble_app_uart\pca10040\s132\arm4\ble_app_uart_s132_pca10040.uvproj
II would like to use nRF52832 get the maximum throughput, I set the minimum connection interval to 50ms, the following is my modified part of the code:
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(50, UNIT_1_25_MS) /**< Minimum acceptable connection interval (50 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(50, UNIT_1_25_MS) /**< Maximum acceptable connection interval (50 ms), Connection interval uses 1.25 ms units. */
typedef struct blk_send_msg_tag
{
uint32_t start; //发送的起始地址
uint32_t max_len; //待发送数据总长度
uint8_t *pdata;
}blk_send_msg;
blk_send_msg g_send_msg;
uint8_t g_data[500];
uint32_t ble_send_data(uint8_t *pdata, uint32_t len)
{
if (NULL == pdata || len <= 0){ return NRF_ERROR_INVALID_PARAM;}
uint8_t temp_len;
uint32_t err_code;
g_send_msg.start = 0;
g_send_msg.max_len = len;
g_send_msg.pdata = pdata;
temp_len = len>20 ? 20 : len;
err_code = ble_nus_string_send(&m_nus, pdata, temp_len);
if (NRF_SUCCESS == err_code)
{
g_send_msg.start += temp_len;
}
return err_code;
}
uint32_t ble_send_more_data()
{
uint32_t err_code;
uint32_t dif_value;
dif_value = g_send_msg.max_len - g_send_msg.start;
if (0 == dif_value || NULL == g_send_msg.pdata)
{
return NRF_SUCCESS;
}
uint8_t temp_len;
temp_len = dif_value>20 ? 20 : dif_value;
err_code = ble_nus_string_send(&m_nus,g_send_msg.pdata + g_send_msg.start, temp_len);
if (NRF_SUCCESS == err_code)
{
g_send_msg.start += temp_len;
}
return err_code;
}
Add BLE_EVT_TX_COMPLETE to on_ble_evt():
case BLE_EVT_TX_COMPLETE:
printf("\r\nBLE_EVT_TX_COMPLETE\r");
ble_send_more_data();
break;
And then send the data:
ble_send_data(g_data, 500);
Through the serial port found every 100ms received a BLE_EVT_TX_COMPLETE
The following figure is my capturing packet data:
Why not 50ms received a packet, if I want a connection incident to send 6 packets how to operate?