Re-introduce keep-alive mechanism
After measuring more than 1024 measurements, we get timeouts during reading the data. It appears the keepalive mechanism is needed for this case.
However, the implementation reads more keepalive responses than it sends:
- It sends every
num_data > 0 && num_data % 1024 == 0
- It reads every
num_data % 1024 == 0
.
This means that before the first measurement we also send out a keepalive and don't read anything back. This feels wrong.
Looking at a python implementation, this is confirmed: https://github.com/patrabu/dl120th/blob/master/dl-120th.py#L304
We have changed the code to reflect this logic, and now we can read more than 1024 measurements without timeouts or other apparent problems.