NimBLE - ESP32-S3 - ESP IDF - blecent example transmission is slow
Posted: Wed Aug 10, 2022 7:47 am
Hi,
I try to send 60kByte of data over BLE between two ESP32. As a start, I used the blecent example from NimBLE/ESP-IDF and so far the communication works great and reliable, but the speed is extremly slow.
It seems, that I can only send exactly every 100ms a packet and I really don't see, where I could change this, at least in the project and inside the SDKConfig I could not find anything related to that. FreeRTOS is set to 1000Hz.
I try to send every 1ms, but I use the write callback to block the process as long as it is not called. The thing is, the callback comes only every 100ms. When I remove the "can_data_be_sent " flag, I can send much faster, but this seems to be error prone, at least at 1ms.
So, how can I change this callback timeout?
What I'm doing is:
I try to send 60kByte of data over BLE between two ESP32. As a start, I used the blecent example from NimBLE/ESP-IDF and so far the communication works great and reliable, but the speed is extremly slow.
It seems, that I can only send exactly every 100ms a packet and I really don't see, where I could change this, at least in the project and inside the SDKConfig I could not find anything related to that. FreeRTOS is set to 1000Hz.
I try to send every 1ms, but I use the write callback to block the process as long as it is not called. The thing is, the callback comes only every 100ms. When I remove the "can_data_be_sent " flag, I can send much faster, but this seems to be error prone, at least at 1ms.
So, how can I change this callback timeout?
What I'm doing is:
Code: Select all
void main()
{
...
write_chr(gatt_chr_dfu_data_uuid, &data_buf[data_ptr], 8*sizeof(uint8_t)); //inside for loop
vTaskDelay(pdMS_TO_TICKS(1));
...
}
/**
* Application callback. Called when the attempt to subscribe to notifications
* for the ANS Unread Alert Status characteristic has completed.
*/
static int
blecent_on_subscribe(uint16_t conn_handle,
const struct ble_gatt_error *error,
struct ble_gatt_attr *attr,
void *arg)
{
can_data_be_sent = true;
return 0;
}
void write_chr(const ble_uuid128_t uuid, uint8_t *data, uint32_t len)
{
const struct peer_chr *chr;
const struct peer *peer = peer_find(connection_handle_t);
can_data_be_sent = false;
chr = peer_chr_find_uuid(peer, BLE_UUID16_DECLARE(GATT_AKRO_SRV_UUID), &uuid.u);
ble_gattc_write_flat(connection_handle_t, chr->chr.val_handle, data, len, blecent_on_subscribe, NULL);
}