Skip to content

Commit a8d7330

Browse files
committed
Fix airtime estimate: use SF-dependent preamble length
estimateLoRaAirtimeFor() hardcoded a 16-symbol preamble, but MeshCore sets the preamble per-SF via RadioLibWrapper::preambleLengthForSF (32 symbols for SF<=8, 16 otherwise). On the default SF8/BW62.5 this made the estimate ~65ms low versus the radio's real getTimeOnAir(), skewing retransmit jitter and tightening the TX-expiry watchdog. Use the same SF<=8 ? 32 : 16 rule so the estimate matches the radio for default CR and only diverges when CR is actually overridden.
1 parent 45af602 commit a8d7330

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/Dispatcher.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ uint32_t Dispatcher::estimateLoRaAirtimeFor(int len_bytes, uint8_t sf, float bw_
7474
float low_data_rate_optimize = ldro_enabled ? 1.0f : 0.0f;
7575
float implicit_header = 0.0f;
7676
float crc_enabled = 1.0f;
77-
float preamble_symbols = 16.0f;
77+
// Preamble length is SF-dependent (RadioLibWrapper::preambleLengthForSF): 32 symbols for
78+
// SF<=8, else 16. Hardcoding 16 under-counts airtime by 16 symbols on SF7/SF8 (the default
79+
// is SF8), which would skew retransmit delays and the TX-expiry watchdog.
80+
float preamble_symbols = (sf <= 8) ? 32.0f : 16.0f;
7881
float payload_symbols = 8.0f + fmaxf(ceilf((8.0f * (float)len_bytes - 4.0f * (float)sf + 28.0f + 16.0f * crc_enabled - 20.0f * implicit_header) /
7982
(4.0f * (float)sf - 8.0f * low_data_rate_optimize)) * (float)cr, 0.0f);
8083
float total_symbols = preamble_symbols + payload_symbols + 4.25f;

0 commit comments

Comments
 (0)