pyxyyy/gesture-drumkit

Explore sending messages in batches

Closed this issue · 2 comments

Each transmission is received about 40ms apart on the phone.
The watch produces 2 messages every 5ms. (2 sensors)
We can batch messages to reduce backpressure in the sensor data stream.

  • each packet sent should consist of multiple messages (Alex, Done)
  • devise a scheme to cache messages and send 1 packet after some time interval

Testing with pthread.h suggests that the sensor callback function is called only by the main thread.
We probably don't have to deal with concurrency issues.
It also explains the UI slowing down significantly when sending data.

Simple approach:
Cache data, and send only when we have enough of data,
Increment the amount of data if there is still backpressure.
Can use multi threading to send data at a later stage..

// edit:
There's no value in ensuring we send data in timestamp delimited groups, since doing so doesn't change latency