esp32s3 BLE proxy performance

ataractic
Posts: 3
Joined: Sun Feb 11, 2024 7:55 pm

esp32s3 BLE proxy performance

Postby ataractic » Sun Feb 11, 2024 8:19 pm

hello,

i made my esp32s3 as a proxy between my mouse and my computer and notice significant lag/stuttering when moving it. i combined the two examples esp_hid_device and esp_hid_host from esp-idf. it works like this: the esp32s3 first connects to the computer then the mouse connects to the esp32s3 and finally when the esp32s3 recieves an input event, it sends it to the computer directly. it works with bluedroid.

the issue is that there is much more lag/stuttering when moving the mouse proxied with my solution than when the mouse is connected directly to the computer and i'd like to fix this issue. i know the esp32 is very powerful and a project like mine shouldn't impact the inputs that much, as i basically just want to stream the inputs.

i've read a bit about MTU and i think reducing the size of the packets can stop the lag, but it cannot be configured in menuconfig with bluedroid, and switching to NimBLE is not possible, or would be a real hassle, also i think bluedroid can be made fast enough for input streaming. problem is i have no clue how to do it.

any thoughts?

DrMickeyLauer
Posts: 168
Joined: Sun May 22, 2022 2:42 pm

Re: esp32s3 BLE proxy performance

Postby DrMickeyLauer » Mon Feb 12, 2024 9:18 am

BLE performance is a complex story and very hard to optimize, given there are so many layers and systems involved.

What may help you is to a) enable the BLE 5 + LE 2M PHY support in `sdkconfig` and b) make sure you update the connection parameters (in particular the connection interval and the latency values) after the GAP connection has been established.

ataractic
Posts: 3
Joined: Sun Feb 11, 2024 7:55 pm

Re: esp32s3 BLE proxy performance

Postby ataractic » Mon Feb 12, 2024 1:34 pm

hello,

thanks for your reply, i'm still new to the field and i still don't understand a few things:

a. i turned on the ble5 in the config but i don't see any macro to enable LE 2M PHY support. however as soon as i turn off ble4.2 features (in menuconfig) the program won't compile.
b. it seem to be a few different apis to control the gap latency and interval values which looks the same. which one is the right one? from the docs:
- esp_ble_gap_set_prefer_conn_params(): before connexion, master role only
- esp_ble_gap_update_conn_params(): update connexion parameters when connexion is up
- esp_ble_gap_prefer_ext_connect_params_set(): set aux parameters

i'll try them all in the meantime.

ataractic
Posts: 3
Joined: Sun Feb 11, 2024 7:55 pm

Re: esp32s3 BLE proxy performance

Postby ataractic » Mon Feb 12, 2024 3:34 pm

hello,

i just tried with esp_ble_gap_update_conn_params() but unfortunately, no matter what settings i enter, the function doesnt change the parameters, and the stuttering won't go away:

code:

Code: Select all

esp_ble_conn_update_params_t conn_params = {0};

memcpy(conn_params.bda, mouse.address, 6);
conn_params.min_int = 0x06;
conn_params.max_int = 0x06;
conn_params.latency = 0x00;
conn_params.timeout = 0xA0;

ESP_ERROR_CHECK(esp_ble_gap_update_conn_params(&conn_params));
getting output with esp_ble_get_current_conn_params() (doesn't change):

Code: Select all

W (140367) proxy: conn_params: interval=18, latency=0, timeout=600
it seems like i can't use esp_ble_gap_set_prefer_conn_params() either since the mouse connects everytime with a new address.

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 148 guests