Revisit message expiration
Due to the way Qz scans for TMC messages, the duration of a scan cycle varies greatly, depending on the number of radio stations in range, the percentage of RDS/TMC stations among them and the number of currently active messages.
Under certain circumstances, it may take longer than 15 minutes for Qz to return to the same station again, which exceeds the minimum expiration time. As a result, messages may expire and disappear because Qz is still busy with some other station, then reappear as Qz returns to that station.
This can be countered by interpreting message expiration slightly less stringently (by its nature, duration can never be more than an approximate value) and keeping messages in memory long enough for an update to be picked up.
A possible implementation is as follows:
- Keep track of how long the last scan cycle took. At a minimum, store a timestamp each time the frequency wraps around, compare it to the previous one and store the difference. Even better: store a timestamp for each frequency and compare against when that frequency was last reached—this results in the duration being updated once per frequency rather than once per scan cycle.
- Add to this the time spent scanning the previous frequency.
- Expiration time for a message cannot be less than the sum calculated in this manner.
- Optionally, put a cap on how far expiration time can be extended, e.g. extended duration cannot be more than twice the original duration.