asterics / FLipMouse

The repository for FLipMouse (Finger and LipMouse)
https://www.asterics-foundation.org/projects/flipmouse
Other
36 stars 8 forks source link

BLE: rate limiter / commands to addon module in general #38

Open benjaminaigner opened 4 years ago

benjaminaigner commented 4 years ago

For adapting the rate limiter, a new AT command needs to be implemented.

But in general, I would prefer to use a general AT command, which is used to send arbitrary commands to an addon board.

Suggestion: AT BC <command (according to https://github.com/asterics/esp32_mouse_keyboard/pull/39 e.g., AT BC $RL80 sets the rate limiter of the esp32 addon to 80ms.

In general, these commands can/should be:

klues commented 4 years ago

What is the BLE rate limiter and in which cases it has to be adapted?

benjaminaigner commented 4 years ago

In general, there is a maximum sending frequency, because of the underlying protocol limitations. In case of the FLipmouse, there are 2 limits, depending on the used HID interface (Bluetooth or USB):

USB: USB-HID data is transferred by an endpoint in interrupt transfer mode. This results in repeating polling by the host, in an interval which is defined in the USB descriptor. The minimum interval is 1ms, so max. 1000 HID reports each second.

The limit is handled by the USB hardware integrated in the Teensy uC, so each time we call Mouse.move() we trust on the Mouse library to handle any buffering and data transfer. So no rate limit there, except a general "tick time" for the main loop.

Bluetooth: Bluetooth data is sent a little more complicated:

We experienced problems with some devices, which could not handle a high data rate very well (BT). The mouse moved with a noticeable delay in the movements (~500-1000ms), which renders the FM nearly unusable. To overcome this issue, we limited the BT sending in the FM by a timestamp based limitation and we discard any packages which are sent more often. For a rate limit which is a long time (e.g. 50-200ms) we loose many fine steps of mouse movement. A short time between HID data transmission might result in delays on some BT devices, but gives a precise mouse control and most of the devices.

So: we need a good default value and the possibility to adapt this value if necessary :+1:

Because the BT rate limiting (and an additional buffering specialized on mouse data) is implemented in the ESP32, we could introduce a general AT command which can send data to the BT addon. There are a few more use cases for this:

klues commented 4 years ago

Thanks for the detailed explanation! 👍

This results in repeating polling by the host, in an interval which is defined in the USB descriptor.

Crazy, normally one would think a mouse would be the perfect device to trigger events if something happens and not using polling by the host.

So: we need a good default value and the possibility to adapt this value if necessary 👍

OK, makes sense!

Do you know how other Bluetooth mouses deal with this problem? Do they simply have a good default value?!