From 730870300c623a6051086cf0d0e99b207c208611 Mon Sep 17 00:00:00 2001 From: Tao Gong Date: Thu, 5 Dec 2024 14:15:54 -0800 Subject: [PATCH] Fix SPort telemetry loss issue (#199) `cmpTimeUs(micros(), nextSendTime)` can overflow after 35 min if no MSP activity. --- src/main/telemetry/smartport.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c index 5bed450798..740ac8bd6d 100644 --- a/src/main/telemetry/smartport.c +++ b/src/main/telemetry/smartport.c @@ -591,10 +591,15 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear return; } + // We have a small chance that `nextSendTime` is indeed 0. + // This is a benign defect and just slows down MSP reply. if (nextSendTime != 0 && (cmpTimeUs(micros(), nextSendTime) <= 0)) { // Don't send sensor data now. This will improve the reception of the MSP message. return; } + + // Blackout window passed. Reset `nextSendTime`. + nextSendTime = 0; #endif // we can send back any data we want, our tables keep track of the order and frequency of each data type we send