ruuvi / com.ruuvi.station

BSD 3-Clause "New" or "Revised" License
72 stars 39 forks source link

Deduplicate incoming data by MAC+measurement counter, consider downsampling in DB #166

Closed andreevdenis closed 3 years ago

DG12 commented 3 years ago

Can you post (somewhere) a sample of duplicate packets. Do you see these often? only under certain conditions? very nearby? noisy environments? Thank you

andreevdenis commented 3 years ago

@ojousima can you give more details for this issue?

ojousima commented 3 years ago

Firmware is allowed to send duplicate data to increase chance of receivers hearing packet while saving power by not redoing measurements.

Most notably, after NFC scan RuuviTag assumes that user wants to connect and advertises at 100 ms interval for 60 s. Data is updated at 1.285 s interval while fast advertising, leading to ~12 duplicated data points. It doesn't make sense to store the same data many times.

This check can be as simple as "If last measurement on this MAC has same measurement sequence counter, do not store to DB". Although architecture-wise, I'd prefer to have a hashmap of seen MACs and the last advertisement at com.ruuvi.bluetooth.default level and not forward repeated data to application callback.

andreevdenis commented 3 years ago

Not sure it will be possible to test it

markoaamunkajo commented 3 years ago

Moving to done at this point.