Code Monkey home page Code Monkey logo

Comments (3)

klues avatar klues commented on August 15, 2024

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

from flipmouse.

benjaminaigner avatar benjaminaigner commented on August 15, 2024

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:

  • Serial interface to any BT board (the first attempt was an EZ-Key HID module on a breadboard, currently we use a
    custom ESP32 PCB with our firmware) in 9600Baud. So we need to consider this interface in any timing and buffering.
  • ESP32 handles via GAP & GATT events the connection to any paired device.
    (there is another issue there on how pairing is handled for the user).
  • ESP32 buffers the HID data and sends it via a GATT notification to the BT host (central device)

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 πŸ‘

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:

  • Enable/disable pairing mode in BT
  • Enable/disable the WebGUI on the FLipMouse
  • Fetch all paired devices
  • Delete on existing pairing
    (and maybe more)

from flipmouse.

klues avatar klues commented on August 15, 2024

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?!

from flipmouse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.