NimBLE - ESP32-S3 - ESP IDF - blecent example transmission is slow

kurtisblow
Posts: 8
Joined: Fri Oct 23, 2020 6:41 am

NimBLE - ESP32-S3 - ESP IDF - blecent example transmission is slow

Postby kurtisblow » 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:

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);
    
}

irahul
Posts: 46
Joined: Fri Jun 18, 2021 10:07 am

Re: NimBLE - ESP32-S3 - ESP IDF - blecent example transmission is slow

Postby irahul » Tue Aug 16, 2022 6:30 am

kurtisblow wrote:
Wed Aug 10, 2022 7:47 am
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.
The blecent sample application uses gatt write with response. So basically, client sends a packet, the server acknowledges it and then the next packet is sent.

One suggestion i have is to use ble_gattc_write_no_rsp_flat APIs. The throughput example available as part of IDF has usage of this API. This will not wait for response from remote and keep sending data. This should be faster than the method of waiting for ack. If this suits your use case, you can give this a try.

Who is online

Users browsing this forum: No registered users and 145 guests