esp32_mouse_keyboard icon indicating copy to clipboard operation
esp32_mouse_keyboard copied to clipboard

Implemented rate limiter for HID reports.

Open ChrisVeigl opened this issue 5 years ago • 4 comments

Added new config variables for KConfig: -) enabling rate limiter -) set interval in microseconds -) Either accumulate mouse movements or discard reports when sent too fast

ChrisVeigl avatar Jul 17 '20 15:07 ChrisVeigl

I've moved all the rate limiter stuff to the esp_hidd_prf_api.c file, because it is more reasonable to it there. The rate limiter is using an esp_timer in accumulate mode, discard mode is working just with a timestamp.

Every packet is sent via the timer, because the default value is set to 500us, which is half the time of the USB request (1ms). With up to 50ms there is no noticeable delay (this setting should be sufficient for all devices, even for older ones).

benjaminaigner avatar Jul 21 '20 10:07 benjaminaigner

Every packet is sent via the timer, because the default value is set to 500us, which is half the time of the USB request (1ms). With up to 50ms there is no noticeable delay (this setting should be sufficient for all devices, even for older ones).

OK! i think we should test the response with different rate limits and devices. if we want to apply it in the FlipMouse, we need to remove the current rate limiter (which currently just drops everything < 20ms) in bluetooth.cpp: https://github.com/asterics/FLipMouse/blob/56b854f2b889f4f2fac8f5503f65db2b070b8f90/FLipWare/bluetooth.cpp#L19

And it we could make the rate limit adjustable via uart / a new FlipMouse AT-command (eg. AT BC to transfer bluetooth commands to the esp32 - for example "AT BC $RA 80" for setting the rate limiter to 80 ms) ?

ChrisVeigl avatar Jul 21 '20 22:07 ChrisVeigl

OK! i think we should test the response with different rate limits and devices. if we want to apply it in the FlipMouse, we need to remove the current rate limiter (which currently just drops everything < 20ms) in bluetooth.cpp: https://github.com/asterics/FLipMouse/blob/56b854f2b889f4f2fac8f5503f65db2b070b8f90/FLipWare/bluetooth.cpp#L19

I don't know if we should remove it completely. If we do that, we might run into the issue, that the serial buffer is full and packets are dropped within the FM?

benjaminaigner avatar Jul 27 '20 11:07 benjaminaigner

I don't know if we should remove it completely. If we do that, we might run into the issue, that the serial buffer is full and packets are dropped within the FM?

if we do not remove it, it will compromise the function of the rate limiter inside the esp32 add-on (becuaes it just drops commands), IMO the best implementation for the FlipMouse would be to limit the rate of commands as soon as possible (before USB or BT actions are created).

ChrisVeigl avatar Jul 27 '20 12:07 ChrisVeigl

This PR is also ~2years old and we don't have any problems with rate limiting.

benjaminaigner avatar Feb 16 '23 12:02 benjaminaigner